Preliminary collection of cache.

@param string $iblockType Type of info block.
@param string $iblockCode Code of info block.
509851
public static function runCacheCollector($iblockType = null, $iblockCode = null)
    {
        if (!$iblockType || !$iblockCode) {
            $iblock = IblockTable::query()
                ->setFilter(['!CODE' => false])
                ->setLimit(1)
                ->setSelect(['IBLOCK_TYPE_ID', 'CODE'])
                ->exec()
                ->fetch();

            $iblockType = $iblock['IBLOCK_TYPE_ID'];
            $iblockCode = $iblock['CODE'];
        }

        $finder = new static(['type' => $iblockType, 'code' => $iblockCode]);
        $finder->code();
    }
942282
public function setLock(Lock $lock)
    {
        // Make sure that the subject from the given lock instance is this object.
        if ($lock->getSubject() !== $this) {
            throw new InvalidLockInstance('Invalid Lock instance given for current object.');
        }

        $this->lock = $lock;
    }
232144
private void primAdd(IEntityLock lock, Date expiration) throws LockingException {
        long now = System.currentTimeMillis();
        long willExpire = expiration.getTime();
        long cacheIntervalSecs = (willExpire - now) / 1000;

        if (cacheIntervalSecs > 0) {
            SmartCache sc = (SmartCache) getLockCache(lock.getEntityType());

            synchronized (sc) {
                sc.put(getCacheKey(lock), lock, (cacheIntervalSecs));
            }
        }
        // Else the lock has already expired.
    }
228924
private boolean isLocked(Class entityType, String entityKey, Integer lockType)
            throws LockingException {
        IEntityLock[] locks = retrieveLocks(entityType, entityKey, lockType);
        return locks.length > 0;
    }
1109331
private function generatePhpDocBlockReturn(): void
  {
    $return = $this->getDocBlockReturnType();
    if ($return!=='')
    {
      $this->codeStore->append(' *', false);
      $this->codeStore->append(' * @return '.$return, false);
    }
  }
257168
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
        {
            $cached->is_locked = true;
            touch($cached->lock_id);
        }
68072
protected function IblockSetFields($id, array $fields)
    {
        $iblock = $this->iblockLocate($id);
        $oldFields = CIBlock::getFields($iblock['ID']);
        $fields = array_merge($oldFields, $fields);
        CIBlock::setFields($iblock['ID'], $fields);

        return ["Set fields for iblock {$iblock['CODE']}({$iblock['ID']})"];
    }
1054369
@Override
    public void visitCode(Code obj) {
        Method m = getMethod();

        if (isIgnorableMethod(m)) {
            return;
        }

        stack.resetForMethodEntry(this);
        syncBlockBranchResetValues.clear();
        syncBlockCount = 0;
        super.visitCode(obj);
    }
933495
public function saved(BlockTypeInterface $blockType)
    {
        if ($blockType->isDirty('is_shared')) {
            DynamicBlock::fromTable($blockType->getAttribute('identifier'))->update(['is_shared' => $blockType->getAttribute('is_shared')]);
        }

        if ($blockType->isDirty('identifier')) {
            DynamicBlock::fromTable($blockType->getAttribute('identifier'))->update(['is_shared' => $blockType->getAttribute('is_shared')]);
        }

        if (! $blockType->dynamicTableExists()) {
            $blockType->createTable();
        }
    }
443966
public function deleteKey($bt)
    {
        $btID = (int) (is_object($bt) ? $bt->getBlockTypeID() : $bt);
        if ($btID !== 0) {
            $app = Application::getFacadeApplication();
            $db = $app->make(Connection::class);
            $db->delete('BlockTypeSetBlockTypes', ['btsID' => $this->getBlockTypeSetID(), 'btID' => $btID]);
            $this->rescanDisplayOrder();
        }
    }
180632
private boolean writeLockAvailable(int type) {
        if (mReadLocks == 0 && mWriteLockHeld == null) {
            return (type == UPGRADABLE) ? true : mUpgradableLockHeld == null;
        }
        return false;
    }
600587
private ILockableEntityGroup ifindLockableGroup(String key, String lockOwner)
            throws GroupsException {
        return compositeGroupService.findGroupWithLock(key, lockOwner);
    }
489148
protected function IblockUpdate(array $data, array $fields = null)
    {
        $return = [];

        if (!empty($data['ID'])) {
            $iblock = $this->iblockLocate($data['ID']);
            unset($data['ID']);
        } elseif (!empty($data['CODE'])) {
            $iblock = $this->iblockLocate($data['CODE']);
            unset($data['CODE']);
        } else {
            throw new Exception('You must set iblock CODE param or iblock ID param');
        }

        $ib = new CIBlock();
        $res = $ib->Update($iblock['ID'], $data);
        if ($res) {
            $return[] = "Iblock {$iblock['CODE']}({$iblock['ID']}) updated";
            if ($fields) {
                $return = array_merge(
                    $return,
                    $this->IblockSetFields($iblock['ID'], $fields)
                );
            }
        } else {
            throw new Exception("Can't update {$iblock['CODE']}({$iblock['ID']}) iblock: {$ib->LAST_ERROR}");
        }

        return $return;
    }
239850
@Override
    public void setBlockedDestinationCode(Integer code) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setBlockedDestinationCode", code);

        updateProperty(JmsInternalConstants.BLOCKED_DESTINATION, code);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setBlockedDestinationCode");
    }
630911
private function validateChangeCollectionType(Block $block, string $collectionIdentifier, int $newType, string $queryType): void
    {
        $this->validate(
            $newType,
            [
                new Constraints\NotBlank(),
                new Constraints\Choice(
                    [
                        'choices' => [
                            Collection::TYPE_MANUAL,
                            Collection::TYPE_DYNAMIC,
                        ],
                        'strict' => true,
                    ]
                ),
            ],
            'new_type'
        );

        $blockDefinition = $block->getDefinition();
        if (!$blockDefinition->hasCollection($collectionIdentifier)) {
            return;
        }

        $collectionConfig = $blockDefinition->getCollection($collectionIdentifier);

        if ($newType === Collection::TYPE_DYNAMIC) {
            if (!$collectionConfig->isValidQueryType($queryType)) {
                throw ValidationException::validationFailed(
                    'new_type',
                    sprintf(
                        'Query type "%s" is not allowed in selected block.',
                        $queryType
                    )
                );
            }
        } elseif ($newType === Collection::TYPE_MANUAL) {
            if ($collectionConfig->getValidItemTypes() === []) {
                throw ValidationException::validationFailed(
                    'new_type',
                    'Selected block does not allow manual collections.'
                );
            }
        }
    }
1364074
public function exportElementForm($iblockId, $params = array()) {
        $this->initializeVars($iblockId);

        $params = array_merge(array(
            'name_prefix' => 'form_element_',
            'category' => 'form',
        ), $params);

        $params['name'] = $params['name_prefix'] . $iblockId;


        $option = \CUserOptions::GetOption($params['category'], $params['name'], false, false);

        $extractedTabs = array();

        if (!$option || empty($option['tabs'])) {
            return $extractedTabs;
        }

        $optionTabs = explode(';', $option['tabs']);
        foreach ($optionTabs as $tabStrings) {
            $extractedFields = array();
            $tabTitle = '';

            $columnString = explode(',', $tabStrings);

            foreach ($columnString as $fieldIndex => $fieldString) {
                if (!strpos($fieldString, '#')) {
                    continue;
                }

                list($fieldCode, $fieldTitle) = explode('#', $fieldString);

                $fieldCode = str_replace('--', '', strval($fieldCode));
                $fieldTitle = str_replace('--', '', strval($fieldTitle));

                $fieldCode = trim($fieldCode, '*');
                $fieldTitle = trim($fieldTitle, '*');

                if ($fieldIndex == 0) {
                    $tabTitle = $fieldTitle;
                } else {
                    $fieldCode = $this->revertCode($fieldCode);
                    $extractedFields[$fieldCode] = $fieldTitle;
                }
            }

            if ($tabTitle) {
                $extractedTabs[$tabTitle] = $extractedFields;
            }

        }

        return $extractedTabs;

    }
1351731
protected function ensure_cachelock_available() {
        if ($this->cachelockinstance === null) {
            $this->cachelockinstance = cache_helper::get_cachelock_for_store($this->get_store());
        }
    }