/**
  * Refreshes the package database.
  * 
  * @param	array<integer>		$packageUpdateServerIDs
  * @param	boolean			$ignoreCache
  */
 public function refreshPackageDatabase(array $packageUpdateServerIDs = array(), $ignoreCache = false)
 {
     // get update server data
     $tmp = PackageUpdateServer::getActiveUpdateServers($packageUpdateServerIDs);
     // loop servers
     $updateServers = array();
     $foundWoltLabServer = false;
     foreach ($tmp as $updateServer) {
         if ($ignoreCache || $updateServer->lastUpdateTime < TIME_NOW - 600) {
             // try to queue a woltlab.com update server first to probe for SSL support
             if (!$foundWoltLabServer && preg_match('~^https?://(?:update|store)\\.woltlab\\.com~', $updateServer->serverURL)) {
                 array_unshift($updateServers, $updateServer);
                 $foundWoltLabServer = true;
                 continue;
             }
             $updateServers[] = $updateServer;
         }
     }
     // loop servers
     $refreshedPackageLists = false;
     foreach ($updateServers as $updateServer) {
         $errorMessage = '';
         try {
             $this->getPackageUpdateXML($updateServer);
             $refreshedPackageLists = true;
         } catch (SystemException $e) {
             $errorMessage = $e->getMessage();
         } catch (PackageUpdateUnauthorizedException $e) {
             $reply = $e->getRequest()->getReply();
             list($errorMessage) = reset($reply['httpHeaders']);
         }
         if ($errorMessage) {
             // save error status
             $updateServerEditor = new PackageUpdateServerEditor($updateServer);
             $updateServerEditor->update(array('status' => 'offline', 'errorMessage' => $errorMessage));
         }
     }
     if ($refreshedPackageLists) {
         PackageUpdateCacheBuilder::getInstance()->reset();
     }
 }
 /**
  * @see	\wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     PackageUpdateCacheBuilder::getInstance()->reset();
 }
Ejemplo n.º 3
0
 /**
  * Returns number of available updates.
  * 
  * @return	integer
  */
 public function getAvailableUpdates()
 {
     $data = PackageUpdateCacheBuilder::getInstance()->getData();
     return $data['updates'];
 }