• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SquidUpdate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

 public function execute()
 {
     $stdin = $this->getStdin();
     $urls = array();
     while (!feof($stdin)) {
         $page = trim(fgets($stdin));
         if (substr($page, 0, 7) == 'http://') {
             $urls[] = $page;
         } elseif ($page !== '') {
             $title = Title::newFromText($page);
             if ($title) {
                 $url = $title->getFullUrl();
                 $this->output("{$url}\n");
                 $urls[] = $url;
                 if (isset($options['purge'])) {
                     $title->invalidateCache();
                 }
             } else {
                 $this->output("(Invalid title '{$page}')\n");
             }
         }
     }
     $this->output("Purging " . count($urls) . " urls...\n");
     $u = new SquidUpdate($urls);
     $u->doUpdate();
     $this->output("Done!\n");
 }
开发者ID:rocLv,项目名称:conference,代码行数:27,代码来源:purgeList.php


示例2: execute

 public function execute()
 {
     global $wgUser, $wgArticleFeedbackRatingTypes, $wgArticleFeedbackSMaxage, $wgArticleFeedbackNamespaces;
     $params = $this->extractRequestParams();
     // Anon token check
     if ($wgUser->isAnon()) {
         if (!isset($params['anontoken'])) {
             $this->dieUsageMsg(array('missingparam', 'anontoken'));
         } elseif (strlen($params['anontoken']) != 32) {
             $this->dieUsage('The anontoken is not 32 characters', 'invalidtoken');
         }
         $token = $params['anontoken'];
     } else {
         $token = '';
     }
     // Load check, is this page ArticleFeedback-enabled ?
     // Keep in sync with ext.articleFeedback.startup.js
     $title = Title::newFromID($params['pageid']);
     if (is_null($title) || !in_array($title->getNamespace(), $wgArticleFeedbackNamespaces) || $title->isRedirect()) {
         // ...then error out
         $this->dieUsage('ArticleFeedback is not enabled on this page', 'invalidpage');
     }
     $dbw = wfGetDB(DB_MASTER);
     // Query the latest ratings by this user for this page,
     // possibly for an older revision
     // Select from the master to prevent replag-induced bugs
     $res = $dbw->select('article_feedback', array('aa_rating_id', 'aa_rating_value', 'aa_revision'), array('aa_user_text' => $wgUser->getName(), 'aa_page_id' => $params['pageid'], 'aa_rating_id' => array_keys($wgArticleFeedbackRatingTypes), 'aa_user_anon_token' => $token), __METHOD__, array('ORDER BY' => 'aa_revision DESC', 'LIMIT' => count($wgArticleFeedbackRatingTypes)));
     $lastRatings = array();
     foreach ($res as $row) {
         $lastRatings[$row->aa_rating_id]['value'] = $row->aa_rating_value;
         $lastRatings[$row->aa_rating_id]['revision'] = $row->aa_revision;
     }
     $pageId = $params['pageid'];
     $revisionId = $params['revid'];
     foreach ($wgArticleFeedbackRatingTypes as $ratingID => $unused) {
         $lastPageRating = false;
         $lastRevRating = false;
         if (isset($lastRatings[$ratingID])) {
             $lastPageRating = intval($lastRatings[$ratingID]['value']);
             if (intval($lastRatings[$ratingID]['revision']) == $revisionId) {
                 $lastRevRating = $lastPageRating;
             }
         }
         $thisRating = false;
         if (isset($params["r{$ratingID}"])) {
             $thisRating = intval($params["r{$ratingID}"]);
         }
         $this->insertRevisionRating($pageId, $revisionId, $ratingID, $thisRating - $lastRevRating, $thisRating, $lastRevRating);
         $this->insertPageRating($pageId, $ratingID, $thisRating - $lastPageRating, $thisRating, $lastPageRating);
         $this->insertUserRatings($pageId, $revisionId, $wgUser, $token, $ratingID, $thisRating, $params['bucket']);
     }
     $this->insertProperties($revisionId, $wgUser, $token, $params);
     $squidUpdate = new SquidUpdate(array(wfAppendQuery(wfScript('api'), array('action' => 'query', 'format' => 'json', 'list' => 'articlefeedback', 'afpageid' => $pageId, 'afanontoken' => '', 'afuserrating' => 0, 'maxage' => 0, 'smaxage' => $wgArticleFeedbackSMaxage))));
     $squidUpdate->doUpdate();
     wfRunHooks('ArticleFeedbackChangeRating', array($params));
     $r = array('result' => 'Success');
     $this->getResult()->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:58,代码来源:ApiArticleFeedback.php


示例3: purgeVarnish

 public function purgeVarnish()
 {
     global $wgHubRssFeeds, $wgServer;
     echo "| Purging varnishen..." . PHP_EOL;
     $urls = [];
     foreach ($wgHubRssFeeds as $feedEndpoint) {
         $urls[] = SpecialPage::getTitleFor(HubRssFeedSpecialController::SPECIAL_NAME)->getFullUrl() . '/' . $feedEndpoint;
         $urls[] = implode('/', [$wgServer, 'rss', $feedEndpoint]);
     }
     $u = new SquidUpdate($urls);
     $u->doUpdate();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:rssCacheWarmer.php


示例4: renderTimeline

function renderTimeline($timelinesrc)
{
    global $wgUploadDirectory, $wgUploadPath, $IP, $wgTimelineSettings, $wgArticlePath, $wgTmpDirectory;
    $hash = md5($timelinesrc);
    $dest = $wgUploadDirectory . "/timeline/";
    if (!is_dir($dest)) {
        mkdir($dest, 0777);
    }
    if (!is_dir($wgTmpDirectory)) {
        mkdir($wgTmpDirectory, 0777);
    }
    $fname = $dest . $hash;
    $previouslyFailed = file_exists($fname . ".err");
    $previouslyRendered = file_exists($fname . ".png");
    $expired = $previouslyRendered && filemtime($fname . ".png") < wfTimestamp(TS_UNIX, $wgTimelineSettings->epochTimestamp);
    if ($expired || !$previouslyRendered && !$previouslyFailed) {
        $handle = fopen($fname, "w");
        fwrite($handle, $timelinesrc);
        fclose($handle);
        $cmdline = wfEscapeShellArg($wgTimelineSettings->perlCommand, $wgTimelineSettings->timelineFile) . " -i " . wfEscapeShellArg($fname) . " -m -P " . wfEscapeShellArg($wgTimelineSettings->ploticusCommand) . " -T " . wfEscapeShellArg($wgTmpDirectory) . " -A " . wfEscapeShellArg($wgArticlePath);
        $ret = `{$cmdline}`;
        unlink($fname);
        if ($ret == "") {
            // Message not localized, only relevant during install
            return "<div id=\"toc\"><tt>Timeline error: Executable not found. Command line was: {$cmdline}</tt></div>";
        }
    }
    @($err = file_get_contents($fname . ".err"));
    if ($err != "") {
        $txt = "<div id=\"toc\"><tt>{$err}</tt></div>";
    } else {
        @($map = file_get_contents($fname . ".map"));
        if (substr(php_uname(), 0, 7) == "Windows") {
            $ext = "gif";
        } else {
            $ext = "png";
        }
        $url = "{$wgUploadPath}/timeline/{$hash}.{$ext}";
        $txt = "<map name=\"{$hash}\">{$map}</map>" . "<img usemap=\"#{$hash}\" src=\"{$url}\">";
        if ($expired) {
            // Replacing an older file, we may need to purge the old one.
            global $wgUseSquid;
            if ($wgUseSquid) {
                $u = new SquidUpdate(array($url));
                $u->doUpdate();
            }
        }
    }
    return $txt;
}
开发者ID:akoehn,项目名称:wikireader,代码行数:50,代码来源:Timeline.php


示例5: purge

 /**
  * Purge the cache for backlinking pages (that is, pages containing
  * a reference to the Title associated with this task)
  *
  * @param string|array $tables
  */
 public function purge($tables)
 {
     global $wgUseFileCache, $wgUseSquid;
     $affectedTitles = $this->getAffectedTitles((array) $tables);
     $affectedCount = count($affectedTitles);
     $this->info("Purge Request", ['title' => $this->title->getPrefixedText(), 'count' => $affectedCount, 'tables' => $tables]);
     // abort if no pages link to the associated Title
     if ($affectedCount == 0) {
         return 0;
     }
     $dbw = wfGetDB(DB_MASTER);
     (new \WikiaSQL())->UPDATE('page')->SET('page_touched', $dbw->timestamp())->WHERE('page_id')->IN(array_map(function ($t) {
         return $t->getArticleID();
     }, $affectedTitles))->run($dbw);
     // Update squid/varnish
     if ($wgUseSquid) {
         \SquidUpdate::newFromTitles($affectedTitles)->doUpdate();
     }
     // Update file cache
     if ($wgUseFileCache) {
         foreach ($affectedTitles as $title) {
             \HTMLFileCache::clearFileCache($title);
         }
     }
     return $affectedCount;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:32,代码来源:HTMLCacheUpdateTask.class.php


示例6: invalidate

 /**
  * Invalidate a set of pages, right now
  */
 public function invalidate($startId = false, $endId = false)
 {
     global $wgUseFileCache, $wgUseSquid;
     $titleArray = $this->mCache->getLinks($this->mTable, $startId, $endId);
     if ($titleArray->count() == 0) {
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     $timestamp = $dbw->timestamp();
     # Get all IDs in this query into an array
     $ids = array();
     foreach ($titleArray as $title) {
         $ids[] = $title->getArticleID();
     }
     # Update page_touched
     $dbw->update('page', array('page_touched' => $timestamp), array('page_id IN (' . $dbw->makeList($ids) . ')'), __METHOD__);
     # Update squid
     if ($wgUseSquid) {
         $u = SquidUpdate::newFromTitles($titleArray);
         $u->doUpdate();
     }
     # Update file cache
     if ($wgUseFileCache) {
         foreach ($titleArray as $title) {
             HTMLFileCache::clearFileCache($title);
         }
     }
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:31,代码来源:HTMLCacheUpdate.php


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: purge

 /**
  * Add array of URLs to the purger queue
  *
  * @param Array $urlArr list of URLs to purge
  * @throws WikiaException
  */
 static function purge($urlArr)
 {
     global $wgEnableScribeReport;
     wfProfileIn(__METHOD__);
     if (empty($wgEnableScribeReport)) {
         wfProfileOut(__METHOD__);
         return;
     }
     foreach ($urlArr as $url) {
         if (!is_string($url)) {
             throw new WikiaException('Bad purge URL');
         }
         $url = SquidUpdate::expand($url);
         $method = self::getPurgeCaller();
         wfDebug("Purging URL {$url} from {$method} via Scribe\n");
         wfDebug("Purging backtrace: " . wfGetAllCallers(false) . "\n");
         // add to the queue, will be sent by onRestInPeace method
         self::$urls[$url] = ['url' => $url, 'time' => time(), 'method' => $method];
         self::$urlsCount++;
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:ScribePurge.class.php


示例13: invalidateTitles

 /**
  * Invalidate an array (or iterator) of Title objects, right now
  * @param $titleArray array
  */
 protected function invalidateTitles($titleArray)
 {
     global $wgUseFileCache, $wgUseSquid;
     $dbw = wfGetDB(DB_MASTER);
     $timestamp = $dbw->timestamp();
     # Get all IDs in this query into an array
     $ids = array();
     foreach ($titleArray as $title) {
         $ids[] = $title->getArticleID();
     }
     if (!$ids) {
         return;
     }
     # Update page_touched
     $batches = array_chunk($ids, $this->mRowsPerQuery);
     foreach ($batches as $batch) {
         $dbw->update('page', array('page_touched' => $timestamp), array('page_id' => $batch), __METHOD__);
     }
     # Update squid
     if ($wgUseSquid) {
         $u = SquidUpdate::newFromTitles($titleArray);
         $u->doUpdate();
     }
     # Update file cache
     if ($wgUseFileCache) {
         foreach ($titleArray as $title) {
             HTMLFileCache::clearFileCache($title);
         }
     }
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:34,代码来源:HTMLCacheUpdate.php


示例14: sendPurgeRequest

 /**
  * Helper to purge an array of $urls
  * @param array $urls List of URLS to purge from squids
  */
 private function sendPurgeRequest($urls)
 {
     if ($this->hasOption('delay')) {
         $delay = floatval($this->getOption('delay'));
         foreach ($urls as $url) {
             if ($this->hasOption('verbose')) {
                 $this->output($url . "\n");
             }
             $u = new SquidUpdate(array($url));
             $u->doUpdate();
             usleep($delay * 1000000.0);
         }
     } else {
         if ($this->hasOption('verbose')) {
             $this->output(implode("\n", $urls) . "\n");
         }
         $u = new SquidUpdate($urls);
         $u->doUpdate();
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:24,代码来源:purgeList.php


示例15: recordUpload

 function recordUpload($oldver, $desc, $copyStatus = '', $source = '', $watch = false)
 {
     global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
     global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
     $img = Image::newFromName($this->mUploadSaveName);
     $fname = 'Image::recordUpload';
     $dbw =& wfGetDB(DB_MASTER);
     Image::checkDBSchema($dbw);
     // Delete thumbnails and refresh the metadata cache
     $img->purgeCache();
     // Fail now if the image isn't there
     if (!$img->fileExists || $img->fromSharedDirectory) {
         wfDebug("Image::recordUpload: File " . $img->imagePath . " went missing!\n");
         return false;
     }
     if ($wgUseCopyrightUpload) {
         $textdesc = '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n" . '== ' . wfMsg('filestatus') . " ==\n" . $copyStatus . "\n" . '== ' . wfMsg('filesource') . " ==\n" . $source;
     } else {
         $textdesc = $desc;
     }
     $now = $dbw->timestamp();
     #split mime type
     if (strpos($img->mime, '/') !== false) {
         list($major, $minor) = explode('/', $img->mime, 2);
     } else {
         $major = $img->mime;
         $minor = "unknown";
     }
     # 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' => $img->name, 'img_size' => $img->size, 'img_width' => IntVal($img->width), 'img_height' => IntVal($img->height), 'img_bits' => $img->bits, 'img_media_type' => $img->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $img->metadata), $fname, 'IGNORE');
     $descTitle = $img->getTitle();
     $purgeURLs = array();
     $article = new Article($descTitle);
     $minor = false;
     $watch = $watch || $wgUser->isWatched($descTitle);
     $suppressRC = true;
     // There's already a log entry, so don't double the RC load
     if ($descTitle->exists()) {
         // TODO: insert a null revision into the page history for this update.
         if ($watch) {
             $wgUser->addWatch($descTitle);
         }
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $purgeURLs[] = $descTitle->getInternalURL();
     } else {
         $this->insertNewArticle($article, $textdesc, $desc, $minor, $watch, $suppressRC);
     }
     # Invalidate cache for all pages using this image
     $linksTo = $img->getLinksTo();
     if ($wgUseSquid) {
         $u = SquidUpdate::newFromTitles($linksTo, $purgeURLs);
         array_push($wgPostCommitUpdateList, $u);
     }
     Title::touchArray($linksTo);
     $log = new LogPage('upload');
     $log->addEntry('upload', $descTitle, $desc);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:61,代码来源:work.php


示例16: transform

 /**
  * Transform a media file
  *
  * @param array $params An associative array of handler-specific parameters. Typical
  *                      keys are width, height and page.
  * @param integer $flags A bitfield, may contain self::RENDER_NOW to force rendering
  * @return MediaTransformOutput
  */
 function transform($params, $flags = 0)
 {
     global $wgUseSquid, $wgIgnoreImageErrors;
     wfProfileIn(__METHOD__);
     do {
         if (!$this->canRender()) {
             // not a bitmap or renderable image, don't try.
             $thumb = $this->iconThumb();
             break;
         }
         $script = $this->getTransformScript();
         if ($script && !($flags & self::RENDER_NOW)) {
             // Use a script to transform on client request, if possible
             $thumb = $this->handler->getScriptedTransform($this, $script, $params);
             if ($thumb) {
                 break;
             }
         }
         $normalisedParams = $params;
         $this->handler->normaliseParams($this, $normalisedParams);
         $thumbName = $this->thumbName($normalisedParams);
         $thumbPath = $this->getThumbPath($thumbName);
         $thumbUrl = $this->getThumbUrl($thumbName);
         if ($this->repo->canTransformVia404() && !($flags & self::RENDER_NOW)) {
             $thumb = $this->handler->getTransform($this, $thumbPath, $thumbUrl, $params);
             break;
         }
         wfDebug(__METHOD__ . ": Doing stat for {$thumbPath}\n");
         $this->migrateThumbFile($thumbName);
         if (file_exists($thumbPath)) {
             $thumb = $this->handler->getTransform($this, $thumbPath, $thumbUrl, $params);
             break;
         }
         $thumb = $this->handler->doTransform($this, $thumbPath, $thumbUrl, $params);
         // Ignore errors if requested
         if (!$thumb) {
             $thumb = null;
         } elseif ($thumb->isError()) {
             $this->lastError = $thumb->toText();
             if ($wgIgnoreImageErrors && !($flags & self::RENDER_NOW)) {
                 $thumb = $this->handler->getTransform($this, $thumbPath, $thumbUrl, $params);
             }
         }
         // Purge. Useful in the event of Core -> Squid connection failure or squid
         // purge collisions from elsewhere during failure. Don't keep triggering for
         // "thumbs" which have the main image URL though (bug 13776)
         if ($wgUseSquid && (!$thumb || $thumb->isError() || $thumb->getUrl() != $this->getURL())) {
             SquidUpdate::purge(array($thumbUrl));
         }
     } while (false);
     wfProfileOut(__METHOD__);
     return $thumb;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:61,代码来源:File.php


示例17: 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


示例18: 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


示例19: doPurge

 /**
  * Perform the actions of a page purging
  */
 public function doPurge()
 {
     global $wgUseSquid;
     // Invalidate the cache
     $this->mTitle->invalidateCache();
     if ($wgUseSquid) {
         // Commit the transaction before the purge is sent
         $dbw = wfGetDB(DB_MASTER);
         $dbw->commit();
         // Send purge
         $update = SquidUpdate::newSimplePurge($this->mTitle);
         $update->doUpdate();
     }
     if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
         global $wgMessageCache;
         if ($this->getID() == 0) {
             $text = false;
         } else {
             $text = $this->getRawText();
         }
         $wgMessageCache->replace($this->mTitle->getDBkey(), $text);
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:26,代码来源:Article.php


示例20: queuePurge

 /**
  * Queue a purge operation
  *
  * @param string $url
  */
 public function queuePurge($url)
 {
     global $wgSquidPurgeUseHostHeader;
     $url = SquidUpdate::expand(str_replace("\n", '', $url));
     $request = array();
     if ($wgSquidPurgeUseHostHeader) {
         $url = wfParseUrl($url);
         $host = $url['host'];
         if (isset($url['port']) && strlen($url['port']) > 0) {
             $host .= ":" . $url['port'];
         }
         $path = $url['path'];
         if (isset($url['query']) && is_string($url['query'])) {
             $path = wfAppendQuery($path, $url['query']);
         }
         $request[] = "PURGE {$path} HTTP/1.1";
         $request[] = "Host: {$host}";
     } else {
         $request[] = "PURGE {$url} HTTP/1.0";
     }
     $request[] = "Connection: Keep-Alive";
     $request[] = "Proxy-Connection: Keep-Alive";
     $request[] = "User-Agent: " . Http::userAgent() . ' ' . __CLASS__;
     // Two ''s to create \r\n\r\n
     $request[] = '';
     $request[] = '';
     $this->requests[] = implode("\r\n", $request);
     if ($this->currentRequestIndex === null) {
         $this->nextRequest();
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:36,代码来源:SquidPurgeClient.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Stack类代码示例发布时间:2022-05-23
下一篇:
PHP Sqlite类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap