Exemplo n.º 1
0
 /**
  * Do some database updates after deletion
  *
  * @param int $id The page_id value of the page being deleted
  * @param Content|null $content Optional page content to be used when determining
  *   the required updates. This may be needed because $this->getContent()
  *   may already return null when the page proper was deleted.
  * @param Revision|null $revision The latest page revision
  */
 public function doDeleteUpdates($id, Content $content = null, Revision $revision = null)
 {
     try {
         $countable = $this->isCountable();
     } catch (Exception $ex) {
         // fallback for deleting broken pages for which we cannot load the content for
         // some reason. Note that doDeleteArticleReal() already logged this problem.
         $countable = false;
     }
     // Update site status
     DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 1, -(int) $countable, -1));
     // Delete pagelinks, update secondary indexes, etc
     $updates = $this->getDeletionUpdates($content);
     foreach ($updates as $update) {
         DeferredUpdates::addUpdate($update);
     }
     // Reparse any pages transcluding this page
     LinksUpdate::queueRecursiveJobsForTable($this->mTitle, 'templatelinks');
     // Reparse any pages including this image
     if ($this->mTitle->getNamespace() == NS_FILE) {
         LinksUpdate::queueRecursiveJobsForTable($this->mTitle, 'imagelinks');
     }
     // Clear caches
     WikiPage::onArticleDelete($this->mTitle);
     ResourceLoaderWikiModule::invalidateModuleCache($this->mTitle, $revision, null, wfWikiID());
     // Reset this object and the Title object
     $this->loadFromRow(false, self::READ_LATEST);
     // Search engine
     DeferredUpdates::addUpdate(new SearchUpdate($id, $this->mTitle));
 }
Exemplo n.º 2
0
 /**
  * Updates page_touched for this page; called from LinksUpdate.php
  *
  * @param string $purgeTime [optional] TS_MW timestamp
  * @return bool True if the update succeeded
  */
 public function invalidateCache($purgeTime = null)
 {
     if (wfReadOnly()) {
         return false;
     } elseif ($this->mArticleID === 0) {
         return true;
         // avoid gap locking if we know it's not there
     }
     $dbw = wfGetDB(DB_MASTER);
     $dbw->onTransactionPreCommitOrIdle(function () {
         ResourceLoaderWikiModule::invalidateModuleCache($this, null, null, wfWikiID());
     });
     $conds = $this->pageCond();
     DeferredUpdates::addUpdate(new AutoCommitUpdate($dbw, __METHOD__, function (IDatabase $dbw, $fname) use($conds, $purgeTime) {
         $dbTimestamp = $dbw->timestamp($purgeTime ?: time());
         $dbw->update('page', ['page_touched' => $dbTimestamp], $conds + ['page_touched < ' . $dbw->addQuotes($dbTimestamp)], $fname);
         MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle($this);
     }), DeferredUpdates::PRESEND);
     return true;
 }