/** * Perform the actions of a page purging * @return bool */ public function doPurge() { global $wgUseSquid; if ( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) { return false; } // Invalidate the cache $this->mTitle->invalidateCache(); if ( $wgUseSquid ) { // Commit the transaction before the purge is sent $dbw = wfGetDB( DB_MASTER ); $dbw->commit( __METHOD__ ); // Send purge $update = SquidUpdate::newSimplePurge( $this->mTitle ); $update->doUpdate(); } if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { // @todo move this logic to MessageCache if ( $this->exists() ) { // NOTE: use transclusion text for messages. // This is consistent with MessageCache::getMsgFromNamespace() $content = $this->getContent(); $text = $content === null ? null : $content->getWikitextForTransclusion(); if ( $text === null ) { $text = false; } } else { $text = false; } MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text ); } return true; }
/** * Perform the actions of a page purging */ public function doPurge() { global $wgUseSquid; if (!wfRunHooks('ArticlePurge', array(&$this))) { return false; } // Invalidate the cache $this->mTitle->invalidateCache(); $this->clear(); 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) { if ($this->getId() == 0) { $text = false; } else { $text = $this->getRawText(); } MessageCache::singleton()->replace($this->mTitle->getDBkey(), $text); } }
/** * 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); } }
/** * Perform the actions of a page purging * @return bool */ public function doPurge() { if (!Hooks::run('ArticlePurge', array(&$this))) { return false; } $title = $this->mTitle; wfGetDB(DB_MASTER)->onTransactionIdle(function () use($title) { global $wgUseSquid; // Invalidate the cache in auto-commit mode $title->invalidateCache(); if ($wgUseSquid) { // Send purge now that page_touched update was committed above $update = SquidUpdate::newSimplePurge($title); $update->doUpdate(); } }); if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { // @todo move this logic to MessageCache if ($this->exists()) { // NOTE: use transclusion text for messages. // This is consistent with MessageCache::getMsgFromNamespace() $content = $this->getContent(); $text = $content === null ? null : $content->getWikitextForTransclusion(); if ($text === null) { $text = false; } } else { $text = false; } MessageCache::singleton()->replace($this->mTitle->getDBkey(), $text); } return true; }
/** * Perform the actions of a page purging */ 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->immediateCommit(); // Send purge $update = SquidUpdate::newSimplePurge($this->mTitle); $update->doUpdate(); } $this->view(); }
/** * Actually go in the database and kill things. * @return message key string for success or failure message */ function hideRevision($dbw, $id) { global $wgUser; $dbw->begin(); $rev = Revision::newFromId($id); if (is_null($rev)) { $dbw->rollback(); return 'hiderevision-error-missing'; } if ($rev->isCurrent()) { $dbw->rollback(); return 'hiderevision-error-current'; } $title = $rev->getTitle(); // Our tasks: // Copy revision to "hidden" table $this->InsertRevision($dbw, $title, $rev); if ($dbw->affectedRows() != 1) { $dbw->rollback(); return 'hiderevision-error-delete'; } // Remove from "revision" $dbw->delete('revision', array('rev_id' => $id), __FUNCTION__); // Remove from "recentchanges" // The page ID is used to get us a relatively usable index $dbw->delete('recentchanges', array('rc_cur_id' => $rev->getPage(), 'rc_this_oldid' => $id), __METHOD__); // Invalidate cache of page history $title->invalidateCache(); // Done with all database pieces; commit! $dbw->commit(); // Also purge remote proxies. // Ideally this would be built into the above, but squid code is // old crappy style. global $wgUseSquid; if ($wgUseSquid) { // Send purge $update = SquidUpdate::newSimplePurge($title); $update->doUpdate(); } return 'hiderevision-success'; }
function wfPurgeTitle($title) { global $wgUseSquid; wfProfileIn(__METHOD__); $title->invalidateCache(); if ($wgUseSquid) { // Commit the transaction before the purge is sent $dbw = wfGetDB(DB_MASTER); $dbw->commit(); // Send purge $update = SquidUpdate::newSimplePurge($title); $update->doUpdate(); } wfProfileOut(__METHOD__); }
public static function purgeTitle($title, $fudgeSeconds = 0) { global $wgUseSquid, $wrPurgingTitles; $ts = time() + $fudgeSeconds; if (!isset($wrPurgingTitles) || @$wrPurgingTitles[$title->getPrefixedText()] != $ts) { $title->invalidateCache($ts); if ($wgUseSquid) { // Send purge $update = SquidUpdate::newSimplePurge($title); $update->doUpdate(); } } if (!isset($wrPurgingTitles)) { $wrPurgingTitles = array(); } $wrPurgingTitles[$title->getPrefixedText()] = $ts; }
/** * Purges the API key passed in. This is in config so that each implementation can * override it as needed. This particular implmentation is MediaWiki-specific. */ public static function purgeKey($apiKey) { global $wgUseSquid, $wgServer; wfProfileIn(__METHOD__); if ($wgUseSquid) { // Send purge to Fastly so that it re-checks the auth on the next API request. $title = $wgServer . "/api.php?checkKey={$apiKey}"; $update = SquidUpdate::newSimplePurge($title); $update->doUpdate(); } wfProfileOut(__METHOD__); }
/** * doSubmit * * parse tag attributes * * @author Krzysztof Krzyżaniak <*****@*****.**> * @access public * * @param object $request WebRequest object * * @return array rendered HTML answer and status of operation */ public function doSubmit(&$request) { global $wgUser, $wgTitle, $parserMemc; wfProfileIn(__METHOD__); $status = false; $vote = $request->getVal("wpPollRadio" . $this->mId, null); if (!is_null($vote)) { if ($this->doVote($vote)) { $status = wfMsg("ajaxpoll-thankyou"); // invalidate cache $wgTitle->invalidateCache(); // clear parser cache $oArticle = new Article($wgTitle); $parserCache =& ParserCache::singleton(); $parserMemc->set($parserCache->getKey($oArticle, $wgUser), null, 0); // Send purge $update = SquidUpdate::newSimplePurge($wgTitle); $update->doUpdate(); } else { $status = wfMsg("ajaxpoll-error"); } } list($votes, $total) = $this->getVotes(true); //true because we need DB_MASTER and we don't want to use memcache here $response = array("id" => $this->mId, "votes" => $votes, "total" => $total, "status" => $status); // Purge the vote stats. global $wgMemc; $memcKey = wfMemcKey(self::MEMC_PREFIX_GETVOTES, $this->mId); $wgMemc->delete($memcKey); wfProfileOut(__METHOD__); return $response; }