当前位置: 首页>>代码示例>>PHP>>正文


PHP SquidUpdate::purge方法代码示例

本文整理汇总了PHP中SquidUpdate::purge方法的典型用法代码示例。如果您正苦于以下问题:PHP SquidUpdate::purge方法的具体用法?PHP SquidUpdate::purge怎么用?PHP SquidUpdate::purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SquidUpdate的用法示例。


在下文中一共展示了SquidUpdate::purge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recordUpload2

 /**
  * Record a file upload in the upload log and the image table
  */
 function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
 {
     if (is_null($user)) {
         global $wgUser;
         $user = $wgUser;
     }
     $dbw = $this->repo->getMasterDB();
     $dbw->begin();
     if (!$props) {
         $props = $this->repo->getFileProps($this->getVirtualUrl());
     }
     $props['description'] = $comment;
     $props['user'] = $user->getId();
     $props['user_text'] = $user->getName();
     $props['timestamp'] = wfTimestamp(TS_MW);
     $this->setProps($props);
     // Delete thumbnails and refresh the metadata cache
     $this->purgeThumbnails();
     $this->saveToCache();
     SquidUpdate::purge(array($this->getURL()));
     /* Wikia change begin - @author: Marooned, see RT#44185 */
     global $wgLogo;
     if ($this->url == $wgLogo) {
         SquidUpdate::purge(array($this->url));
     }
     /* Wikia change end */
     // Fail now if the file isn't there
     if (!$this->fileExists) {
         wfDebug(__METHOD__ . ": File " . $this->getPath() . " went missing!\n");
         return false;
     }
     $reupload = false;
     if ($timestamp === false) {
         $timestamp = $dbw->timestamp();
     }
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
     if ($dbw->affectedRows() == 0) {
         $reupload = true;
         # Collision, this is an update of a file
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
     } else {
         # This is a new file
         # Update the image count
         $site_stats = $dbw->tableName('site_stats');
         $dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
     }
     # Commit the transaction now, in case something goes wrong later
     # The most important thing is that files don't get lost, especially archives
     $dbw->commit();
     # Invalidate cache for all pages using this file
     $update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
     $update->doUpdate();
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:63,代码来源:WikiaNoArticleLocalFile.class.php

示例2: purge

 private function purge($url, $var, $typeVal, $val, $likeVal)
 {
     $wikis = $this->getListOfWikisWithVar($var, $typeVal, $val, $likeVal);
     $purgeUrls = array();
     foreach ($wikis as $cityId => $wikiData) {
         $purgeUrls[] = $wikiData['u'] . $url;
     }
     SquidUpdate::purge($purgeUrls);
     return $purgeUrls;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:10,代码来源:BatchVarnishPurgeToolController.class.php

示例3: benchSquid

/** @todo document */
function benchSquid($urls, $trials = 1)
{
    $start = wfTime();
    for ($i = 0; $i < $trials; $i++) {
        SquidUpdate::purge($urls);
    }
    $delta = wfTime() - $start;
    $pertrial = $delta / $trials;
    $pertitle = $pertrial / count($urls);
    return sprintf("%4d titles in %6.2fms (%6.2fms each)", count($urls), $pertrial * 1000.0, $pertitle * 1000.0);
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:12,代码来源:benchmarkPurge.php

示例4: purgeThumb

 /**
  * Remove the thumb from DFS and purge it from CDN
  *
  * @param string $thumb
  */
 private function purgeThumb($thumb)
 {
     $url = sprintf("http://images.wikia.com/%s%s/%s", $this->storage->getContainerName(), $this->storage->getPathPrefix(), $thumb);
     #$this->output(sprintf("%s: %s <%s>...", __METHOD__, $thumb, $url));
     $this->output(sprintf("%s: '%s'... ", __METHOD__, $thumb));
     if ($this->isDryRun) {
         $this->output("dry run!\n");
     } else {
         $this->storage->remove($thumb);
         SquidUpdate::purge([$url]);
         $this->output("done\n");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:purgeWebPThumbs.php

示例5: execute

 public function execute()
 {
     $this->dryRun = $this->hasOption('dry-run');
     $this->verbose = $this->hasOption('verbose');
     $wikiId = $this->getOption('wikiId', '');
     if (empty($wikiId)) {
         die("Error: Empty wiki id.\n");
     }
     $dbname = WikiFactory::IDtoDB($wikiId);
     if (empty($dbname)) {
         die("Error: Cannot find dbname.\n");
     }
     $pageLimit = 20000;
     $totalLimit = $this->getOption('limit', $pageLimit);
     if (empty($totalLimit) || $totalLimit < -1) {
         die("Error: invalid limit.\n");
     }
     if ($totalLimit == -1) {
         $totalLimit = $this->getTotalPages($dbname);
     }
     $maxSet = ceil($totalLimit / $pageLimit);
     $limit = $totalLimit > $pageLimit ? $pageLimit : $totalLimit;
     $totalPages = 0;
     for ($set = 1; $set <= $maxSet; $set++) {
         $cnt = 0;
         if ($set == $maxSet) {
             $limit = $totalLimit - $pageLimit * ($set - 1);
         }
         $offset = ($set - 1) * $pageLimit;
         $pages = $this->getAllPages($dbname, $limit, $offset);
         $total = count($pages);
         foreach ($pages as $page) {
             $cnt++;
             echo "Wiki {$wikiId} - Page {$page['id']} [{$cnt} of {$total}, set {$set} of {$maxSet}]: ";
             $title = GlobalTitle::newFromId($page['id'], $wikiId);
             if ($title instanceof GlobalTitle) {
                 $url = $title->getFullURL();
                 echo "{$url}\n";
                 if (!$this->dryRun) {
                     SquidUpdate::purge([$url]);
                 }
                 $this->success++;
             } else {
                 echo "ERROR: Cannot find global title for {$page['title']}\n";
             }
         }
         $totalPages = $totalPages + $total;
     }
     echo "\nWiki {$wikiId}: Total pages: {$totalPages}, Success: {$this->success}, Failed: " . ($totalPages - $this->success) . "\n\n";
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:50,代码来源:purgeArticlePages.php

示例6: wfPurgeSquidServers

/**
 * This is obsolete, use SquidUpdate::purge()
 * @deprecated
 */
function wfPurgeSquidServers($urlArr)
{
    SquidUpdate::purge($urlArr);
}
开发者ID:josephdye,项目名称:wikireader,代码行数:8,代码来源:GlobalFunctions.php

示例7: purgeCommunityWidgetInVarnish

 /**
  * @author Maciej Błaszkowski <marooned at wikia-inc.com>
  */
 static function purgeCommunityWidgetInVarnish($title)
 {
     global $wgScript, $wgContentNamespaces, $wgContLang, $wgMemc;
     if (in_array($title->getNamespace(), $wgContentNamespaces)) {
         $lang = $wgContLang->getCode();
         $key = wfMemcKey('community_widget_v1', $lang);
         $wgMemc->delete($key);
         SquidUpdate::purge(array($wgScript . "?action=ajax&rs=CommunityWidgetAjax&uselang={$lang}"));
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:14,代码来源:ActivityFeedHelper.php

示例8: deleteOld

 /**
  * Delete an old version of the file.
  *
  * Moves the file into an archive directory (or deletes it)
  * and removes the database row.
  *
  * Cache purging is done; logging is caller's responsibility.
  *
  * @param string $archiveName
  * @param string $reason
  * @param bool $suppress
  * @throws MWException Exception on database or file store failure
  * @return FileRepoStatus
  */
 function deleteOld($archiveName, $reason, $suppress = false)
 {
     global $wgUseSquid;
     if ($this->getRepo()->getReadOnlyReason() !== false) {
         return $this->readOnlyFatalStatus();
     }
     $batch = new LocalFileDeleteBatch($this, $reason, $suppress);
     $this->lock();
     // begin
     $batch->addOld($archiveName);
     $status = $batch->execute();
     $this->unlock();
     // done
     $this->purgeOldThumbnails($archiveName);
     if ($status->isOK()) {
         $this->purgeDescription();
         $this->purgeHistory();
     }
     if ($wgUseSquid) {
         // Purge the squid
         SquidUpdate::purge(array($this->getArchiveUrl($archiveName)));
     }
     return $status;
 }
开发者ID:spring,项目名称:spring-website,代码行数:38,代码来源:LocalFile.php

示例9: execute

 /**
  * Run the transaction
  */
 function execute()
 {
     global $wgUseSquid;
     wfProfileIn(__METHOD__);
     $this->file->lock();
     // Leave private files alone
     $privateFiles = array();
     list($oldRels, $deleteCurrent) = $this->getOldRels();
     $dbw = $this->file->repo->getMasterDB();
     if (!empty($oldRels)) {
         $res = $dbw->select('oldimage', array('oi_archive_name'), array('oi_name' => $this->file->getName(), 'oi_archive_name IN (' . $dbw->makeList(array_keys($oldRels)) . ')', $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__);
         foreach ($res as $row) {
             $privateFiles[$row->oi_archive_name] = 1;
         }
     }
     // Prepare deletion batch
     $hashes = $this->getHashes();
     $this->deletionBatch = array();
     $ext = $this->file->getExtension();
     $dotExt = $ext === '' ? '' : ".{$ext}";
     foreach ($this->srcRels as $name => $srcRel) {
         // Skip files that have no hash (missing source).
         // Keep private files where they are.
         if (isset($hashes[$name]) && !array_key_exists($name, $privateFiles)) {
             $hash = $hashes[$name];
             $key = $hash . $dotExt;
             $dstRel = $this->file->repo->getDeletedHashPath($key) . $key;
             $this->deletionBatch[$name] = array($srcRel, $dstRel);
         }
     }
     // Lock the filearchive rows so that the files don't get deleted by a cleanup operation
     // We acquire this lock by running the inserts now, before the file operations.
     //
     // This potentially has poor lock contention characteristics -- an alternative
     // scheme would be to insert stub filearchive entries with no fa_name and commit
     // them in a separate transaction, then run the file ops, then update the fa_name fields.
     $this->doDBInserts();
     // Removes non-existent file from the batch, so we don't get errors.
     $this->deletionBatch = $this->removeNonexistentFiles($this->deletionBatch);
     // Execute the file deletion batch
     $status = $this->file->repo->deleteBatch($this->deletionBatch);
     if (!$status->isGood()) {
         $this->status->merge($status);
     }
     if (!$this->status->ok) {
         // Critical file deletion error
         // Roll back inserts, release lock and abort
         // TODO: delete the defunct filearchive rows if we are using a non-transactional DB
         $this->file->unlockAndRollback();
         wfProfileOut(__METHOD__);
         return $this->status;
     }
     // Purge squid
     if ($wgUseSquid) {
         $urls = array();
         foreach ($this->srcRels as $srcRel) {
             $urlRel = str_replace('%2F', '/', rawurlencode($srcRel));
             $urls[] = $this->file->repo->getZoneUrl('public') . '/' . $urlRel;
         }
         SquidUpdate::purge($urls);
     }
     // Delete image/oldimage rows
     $this->doDBDeletes();
     // Commit and return
     $this->file->unlock();
     wfProfileOut(__METHOD__);
     return $this->status;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:71,代码来源:LocalFile.php

示例10: PurgeReferringPages

 /**
  * Purges squids and invalidates caches of pages that link to $title
  * interwiki.
  */
 public static function PurgeReferringPages($title)
 {
     global $wgDBname, $wgInterwikiIntegrationPrefix;
     $mDb = wfGetDB(DB_MASTER);
     $titleName = str_replace(' ', '_', $title->getFullText());
     $prefix = array();
     $prefix = array_keys($wgInterwikiIntegrationPrefix, $wgDBname);
     $purgeArray = array();
     foreach ($prefix as $thisPrefix) {
         $thisPrefix = ucfirst($thisPrefix);
         $result = $mDb->selectRow(array('integration_iwlinks'), array('integration_iwl_from_url', 'integration_iwl_from_db', 'integration_iwl_from'), array('integration_iwl_prefix' => $thisPrefix, 'integration_iwl_title' => $titleName));
         if ($result) {
             $referringPage = $result->integration_iwl_from;
             $purgeArray[] = $result->integration_iwl_from_url;
             $referringDb = $result->integration_iwl_from_db;
             $dbwReferring = wfGetDB(DB_MASTER, array(), $referringDb);
             $dbwReferring->update('page', array('page_touched' => $dbwReferring->timestamp()), array('page_id' => $referringPage));
         }
     }
     if ($result) {
         SquidUpdate::purge($purgeArray);
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:28,代码来源:InterwikiIntegration.hooks.php

示例11: purgeUrl

 function purgeUrl()
 {
     // Purge the avatar URL and the proportions commonly used in Oasis.
     global $wgUseSquid;
     if ($wgUseSquid) {
         // FIXME: is there a way to know what sizes will be used w/o hardcoding them here?
         $urls = array($this->getPurgeUrl(), $this->getThumbnailPurgeUrl(20), $this->getThumbnailPurgeUrl(50), $this->getThumbnailPurgeUrl(100), $this->getThumbnailPurgeUrl(200));
         SquidUpdate::purge($urls);
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:10,代码来源:Masthead.class.php

示例12: purgeMultiTypePackageCache

 /**
  * Purges Varnish and Memcached data mapping to the specified set of paramenters
  *
  * @param array $options @see getMultiTypePackage
  */
 public function purgeMultiTypePackageCache(array $options)
 {
     SquidUpdate::purge(array(F::build('AssetsManager', array(), 'getInstance')->getMultiTypePackageURL($options)));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:9,代码来源:AssetsManagerController.class.php

示例13: purge

 /**
  * @param $title Title
  * @param $user User
  */
 public function purge($title, $user)
 {
     global $wgScript, $wgServer;
     AttributionCache::getInstance()->updateArticleContribs($title, $user);
     // invalidate varnish cache
     if ($user->getId() != 0) {
         SquidUpdate::purge(array("{$wgServer}{$wgScript}?action=ajax&rs=wfAnswersGetEditPointsAjax&userId={$user->getId()}"));
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:AttributionCache.class.php

示例14: purgeThumbnails

 /**
  * @brief remove thumbnails for avatar by cleaning up whole folder
  *
  * @author Krzysztof Krzyżaniak (eloy) <eloy@wikia-inc.com>
  * @access private
  *
  * @return boolean status of operation
  */
 private function purgeThumbnails()
 {
     global $wgAvatarsUseSwiftStorage, $wgBlogAvatarPath, $wgBlogAvatarSwiftContainer, $wgBlogAvatarSwiftPathPrefix;
     // get path to thumbnail folder
     wfProfileIn(__METHOD__);
     // dirty hack, should work in this case
     if (!empty($wgAvatarsUseSwiftStorage)) {
         $swift = $this->getSwiftStorage();
         $backend = FileBackendGroup::singleton()->get('swift-backend');
         $dir = sprintf('mwstore://swift-backend/%s%s%s', $wgBlogAvatarSwiftContainer, $wgBlogAvatarSwiftPathPrefix, $this->getLocalPath());
         $dir = $this->getThumbPath($dir);
         $avatarRemotePath = sprintf("thumb%s", $this->getLocalPath());
         $urls = [];
         $files = [];
         $iterator = $backend->getFileList(array('dir' => $dir));
         foreach ($iterator as $file) {
             $files[] = sprintf("%s/%s", $avatarRemotePath, $file);
         }
         // deleting files on file system and creating an array of URLs to purge
         if (!empty($files)) {
             foreach ($files as $file) {
                 $status = $swift->remove($file);
                 if (!$status->isOk()) {
                     wfDebugLog("avatar", __METHOD__ . ": {$file} exists but cannot be removed.\n", true);
                 } else {
                     $urls[] = wfReplaceImageServer($wgBlogAvatarPath) . "/{$file}";
                     wfDebugLog("avatar", __METHOD__ . ": {$file} removed.\n", true);
                 }
             }
         }
         wfDebugLog("avatar", __METHOD__ . ": all thumbs removed.\n", true);
     } else {
         $dir = $this->getFullPath();
         $dir = $this->getThumbPath($dir);
         if (is_dir($dir)) {
             $urls = [];
             $files = [];
             // copied from LocalFile->getThumbnails
             $handle = opendir($dir);
             if ($handle) {
                 while (false !== ($file = readdir($handle))) {
                     if ($file[0] != '.') {
                         $files[] = $file;
                     }
                 }
                 closedir($handle);
             }
             // partialy copied from LocalFile->purgeThumbnails()
             foreach ($files as $file) {
                 // deleting files on file system
                 @unlink("{$dir}/{$file}");
                 $urls[] = $this->getPurgeUrl('/thumb/') . "/{$file}";
                 wfDebugLog("avatar", __METHOD__ . ": removing {$dir}/{$file}\n", true);
             }
         } else {
             wfDebugLog("avatar", __METHOD__ . ": {$dir} exists but is not directory so not removed.\n", true);
         }
         wfDebugLog("avatar", __METHOD__ . ": all thumbs removed.\n", true);
     }
     // purging avatars urls
     SquidUpdate::purge($urls);
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:71,代码来源:Masthead.class.php

示例15: onGameGuidesContentSave

 /**
  * @brief Whenever data is saved in GG Content Managment Tool
  * purge Varnish cache for it
  *
  * @return bool
  */
 static function onGameGuidesContentSave()
 {
     $app = F::app();
     SquidUpdate::purge(array($app->wf->AppendQuery($app->wf->ExpandUrl($app->wg->Server . $app->wg->ScriptPath . '/wikia.php'), array('controller' => __CLASS__, 'method' => 'getTags'))));
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:12,代码来源:GameGuidesController.class.php


注:本文中的SquidUpdate::purge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。