Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/iblock/lib/orm/ |
Upload File : |
<?php /** * Bitrix Framework * @package bitrix * @subpackage iblock * @copyright 2001-2018 Bitrix */ namespace Bitrix\Iblock\ORM; use Bitrix\Main\ORM\Query\Filter\ConditionTree; use Bitrix\Main\ORM\Query\Join; use Bitrix\Main\ORM\Query\Query as BaseQuery; /** * Separate query to fix PropertyValue emulation in 2.0 * Collapses similar joins to b_iblock_element_prop_sX table into one join * * @package bitrix * @subpackage iblock */ class Query extends BaseQuery { protected function buildJoin() { // collapse v2.0 single value joins into one if ($this->entity instanceof ElementV2Entity) { // table alias for all the records (cut b_ prefix) $propSTable = $this->entity->getSingleValueTableName(); $commonAlias = mb_substr($propSTable, 2); // found first join and changed alias. all other joins to be removed $changed = false; // table aliases to be changed in chains $replacedAliases = []; // 1. collapse joins foreach ($this->join_map as $k => $join) { // check join if ($join['table'] === $propSTable && $join['type'] === Join::TYPE_INNER) { /** @var ConditionTree[]|string[] $join */ $conditions = $join['reference']->getConditions(); // check on condition if (count($conditions) === 1 && $conditions[0]->getColumn() === 'ID' && $conditions[0]->getOperator() === '=') { // collect table aliases to rewrite in chains $replacedAliases[$join['alias']] = true; if (!$changed) { // make the only one change $this->join_map[$k]['alias'] = $commonAlias; $changed = true; } else { // remove from registry unset($this->join_map[$k]); } } } } // 2. rewrite aliases foreach ($this->global_chains as $chain) { if (!empty($replacedAliases[$chain->getLastElement()->getParameter('talias')])) { $chain->getLastElement()->setParameter('talias', $commonAlias); } } } return parent::buildJoin(); } }