private static function recursiveReindex($rootPath, $path, $arSites, $maxExecutionTime = 0, &$ns) { $pathAbs = IO\Path::combine($rootPath, $path); $dir = new IO\Directory($pathAbs); if (!$dir->isExists()) { return 0; } $siteId = ""; foreach ($arSites as $site) { if (substr($pathAbs . "/", 0, strlen($site["path"] . "/")) == $site["path"] . "/") { $siteId = $site["site_id"]; break; } } if (empty($siteId)) { return 0; } $arChildren = $dir->getChildren(); foreach ($arChildren as $child) { if ($child->isDirectory()) { if ($child->isSystem()) { continue; } //this is not first step and we had stopped here, so go on to reindex if ($maxExecutionTime <= 0 || strlen($ns["FLG"]) <= 0 || strlen($ns["FLG"]) > 0 && substr($ns["ID"] . "/", 0, strlen($child->getPath() . "/")) == $child->getPath() . "/") { if (UrlRewriter::recursiveReindex($rootPath, substr($child->getPath(), strlen($rootPath)), $arSites, $maxExecutionTime, $ns) === false) { return false; } } else { continue; } } else { //not the first step and we found last file from previos one if ($maxExecutionTime > 0 && strlen($ns["FLG"]) > 0 && $ns["ID"] == $child->getPath()) { $ns["FLG"] = ""; } elseif (empty($ns["FLG"])) { $ID = UrlRewriter::reindexFile($siteId, $rootPath, substr($child->getPath(), strlen($rootPath)), $ns["max_file_size"]); if ($ID) { $ns["CNT"] = intval($ns["CNT"]) + 1; } } if ($maxExecutionTime > 0 && getmicrotime() - START_EXEC_TIME > $maxExecutionTime) { $ns["FLG"] = "Y"; $ns["ID"] = $child->getPath(); return false; } } } return true; }
/** * @param string $lang This variable is the value language. * @param bool $systemProcesses Installing the system processes. * @param string $path This variable is the path to the file to get the data. * @param array $fileData Array for loading the data. * @throws Main\ArgumentNullException * @throws Main\IO\FileNotFoundException */ public static function loadDataProcesses($lang, $systemProcesses = true, &$fileData, $path = null) { if (empty($lang)) { throw new Main\ArgumentNullException("lang"); } if (!empty($path)) { $path = $path . "/"; } else { if ($systemProcesses) { $path = Main\Loader::getDocumentRoot() . static::PATH . $lang . "/"; } else { $path = Main\Loader::getDocumentRoot() . static::PATH_USER_PROCESSES . $lang . "/"; } } $dir = new Main\IO\Directory($path); if ($dir->isExists()) { $children = $dir->getChildren(); foreach ($children as $key => $child) { /** @var Main\IO\File $child */ if ($child->isFile() && $child->getExtension() == "prc") { $data = self::getDataProcess($path . $child->getName()); $fileData[$data['CODE']]['FILE_NAME'] = $child->getName(); $fileData[$data['CODE']]['FILE_PATH'] = str_replace(Main\Loader::getDocumentRoot(), '', $child->getPath()); $fileData[$data['CODE']]['NAME'] = $data['NAME']; $fileData[$data['CODE']]['DESCRIPTION'] = $data['DESCRIPTION']; $fileData[$data['CODE']]['CODE'] = $data['CODE']; $fileData[$data['CODE']]['IBLOCK_TYPE_ID'] = $data['IBLOCK_TYPE_ID']; $fileData[$data['CODE']]['DIRECTORY_NAME'] = $child->getDirectory()->getName(); } elseif ($child->isDirectory()) { self::loadDataProcesses($lang, $systemProcesses, $fileData, $child->getPath()); } } } }
/** * @return Collector[] */ public function getNotAppliedCollectors() { $result = AppliedChangesLogTable::getList(array('select' => array('GROUP_LABEL'), 'group' => array('GROUP_LABEL'))); $usesGroups = array_map(function ($row) { return $row['GROUP_LABEL']; }, $result->fetchAll()); $dir = new Directory($this->_getFixFilesDir()); $collectors = array(); $files = array(); foreach ($dir->getChildren() as $file) { if ($file->isDirectory()) { continue; } if (in_array($file->getName(), $usesGroups)) { continue; } $files[$file->getName()] = $file; } ksort($files); foreach ($files as $file) { $collectors[] = Collector::createByFile($file->getPath(), $this); } return $collectors; }
protected function deleteOneDir($etime = 0) { $bDeleteFromQueue = false; $con = \Bitrix\Main\Application::getDbConnection(); $rs = $con->query("SELECT * from b_cache_tag WHERE TAG='*'", 0, 1); if ($ar = $rs->fetch()) { $dirName = IO\Path::convertRelativeToAbsolute($ar["RELATIVE_PATH"]); $dir = new IO\Directory($dirName); if ($dir->isExists()) { $arChildren = $dir->getChildren(); $Counter = 0; foreach ($arChildren as $child) { $child->delete(); $Counter++; if (time() > $etime) { break; } } if ($Counter == 0) { $dir->delete(); $bDeleteFromQueue = true; } } else { $bDeleteFromQueue = true; } if ($bDeleteFromQueue) { $con->queryExecute("DELETE FROM b_cache_tag\n\t\t\t\t\tWHERE SITE_ID = '" . $con->getSqlHelper()->forSql($ar["SITE_ID"]) . "'\n\t\t\t\t\tAND CACHE_SALT = '" . $con->getSqlHelper()->forSql($ar["CACHE_SALT"]) . "'\n\t\t\t\t\tAND RELATIVE_PATH = '" . $con->getSqlHelper()->forSql($ar["RELATIVE_PATH"]) . "'"); } } }