/** * Fetch from the remote marketplace the latest available versions of the core and the packages. * These operations are done only the first time or after at least APP_VERSION_LATEST_THRESHOLD seconds since the previous check. * * @return string|null Returns the latest available core version (eg. '5.7.3.1'). * If we can't retrieve the latest version and if this never succeeded previously, this function returns null. */ public static function getLatestAvailableVersionNumber() { // first, we check session $queryWS = false; Cache::disableAll(); $vNum = Config::get('concrete.misc.latest_version', true); Cache::enableAll(); $versionNum = null; if (is_object($vNum)) { $seconds = strtotime($vNum->timestamp); $version = $vNum->value; if (is_object($version)) { $versionNum = $version->version; } else { $versionNum = $version; } $diff = time() - $seconds; if ($diff > Config::get('concrete.updates.check_threshold')) { // we grab a new value from the service $queryWS = true; } } else { $queryWS = true; } if ($queryWS) { $mi = Marketplace::getInstance(); if ($mi->isConnected()) { Marketplace::checkPackageUpdates(); } $update = static::getLatestAvailableUpdate(); $versionNum = null; if (is_object($update)) { $versionNum = $update->getVersion(); } if ($versionNum) { Config::save('concrete.misc.latest_version', $versionNum); } else { // we don't know so we're going to assume we're it Config::save('concrete.misc.latest_version', APP_VERSION); } } return $versionNum; }
/** * Reindexes the search engine. */ public function reindexAll($fullReindex = false) { Cache::disableAll(); $db = Loader::db(); if ($fullReindex) { $db->Execute("truncate table PageSearchIndex"); } $pl = new PageList(); $pl->ignoreAliases(); $pl->ignorePermissions(); $pl->sortByCollectionIDAscending(); $pl->filter(false, '(c.cDateModified > psi.cDateLastIndexed or UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(psi.cDateLastIndexed) > ' . $this->searchReindexTimeout . ' or psi.cID is null or psi.cDateLastIndexed is null)'); $pl->filter(false, '(ak_exclude_search_index is null or ak_exclude_search_index = 0)'); $pages = $pl->get($this->searchBatchSize); $num = 0; foreach ($pages as $c) { // make sure something is approved $cv = $c->getVersionObject(); if (!$cv->cvIsApproved) { continue; } $c->reindex($this, true); ++$num; unset($c); } $pnum = Collection::reindexPendingPages(); $num = $num + $pnum; Cache::enableAll(); $result = new stdClass(); $result->count = $num; return $result; }