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


PHP DeferredUpdates::addUpdate方法代码示例

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


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

示例1: testPurgeMergeWeb

 public function testPurgeMergeWeb()
 {
     $this->setMwGlobals('wgCommandLineMode', false);
     $urls1 = array();
     $title = Title::newMainPage();
     $urls1[] = $title->getCanonicalURL('?x=1');
     $urls1[] = $title->getCanonicalURL('?x=2');
     $urls1[] = $title->getCanonicalURL('?x=3');
     $update1 = new CdnCacheUpdate($urls1);
     DeferredUpdates::addUpdate($update1);
     $urls2 = array();
     $urls2[] = $title->getCanonicalURL('?x=2');
     $urls2[] = $title->getCanonicalURL('?x=3');
     $urls2[] = $title->getCanonicalURL('?x=4');
     $update2 = new CdnCacheUpdate($urls2);
     DeferredUpdates::addUpdate($update2);
     $wrapper = TestingAccessWrapper::newFromObject($update1);
     $this->assertEquals(array_merge($urls1, $urls2), $wrapper->urls);
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:19,代码来源:CdnCacheUpdateTest.php

示例2: onUserLoadFromSession

 public static function onUserLoadFromSession($user, &$result)
 {
     $result = false;
     // don't attempt default auth process
     if (!isset($_SERVER['SSL_CLIENT_S_DN'])) {
         return true;
     }
     $parsed = self::parseDistinguishedName($_SERVER['SSL_CLIENT_S_DN']);
     if (!isset($parsed['CN'])) {
         return true;
     }
     $userName = $parsed['CN'];
     $localId = User::idFromName($userName);
     if ($localId === null) {
         // local user doesn't exists yet
         $user->loadDefaults($parsed['CN']);
         if (!User::isCreatableName($user->getName())) {
             wfDebug(__METHOD__ . ": Invalid username\n");
             return true;
         }
         $user->addToDatabase();
         if (isset($parsed['emailAddress'])) {
             $user->setEmail($parsed['emailAddress']);
         }
         $user->saveSettings();
         $user->addNewUserLogEntryAutoCreate();
         Hooks::run('AuthPluginAutoCreate', array($user));
         DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1));
     } else {
         $user->setID($localId);
         $user->loadFromId();
     }
     global $wgUser;
     $wgUser =& $user;
     $result = true;
     // this also aborts default auth process
     return true;
 }
开发者ID:WGH-,项目名称:SSLClientAuth,代码行数:38,代码来源:SSLClientAuthHooks.php

示例3: move

 /**
  * @param User $user
  * @param string $reason
  * @param bool $createRedirect
  * @return Status
  */
 public function move(User $user, $reason, $createRedirect)
 {
     global $wgCategoryCollation;
     Hooks::run('TitleMove', [$this->oldTitle, $this->newTitle, $user]);
     // If it is a file, move it first.
     // It is done before all other moving stuff is done because it's hard to revert.
     $dbw = wfGetDB(DB_MASTER);
     if ($this->oldTitle->getNamespace() == NS_FILE) {
         $file = wfLocalFile($this->oldTitle);
         $file->load(File::READ_LATEST);
         if ($file->exists()) {
             $status = $file->move($this->newTitle);
             if (!$status->isOK()) {
                 return $status;
             }
         }
         // Clear RepoGroup process cache
         RepoGroup::singleton()->clearCache($this->oldTitle);
         RepoGroup::singleton()->clearCache($this->newTitle);
         # clear false negative cache
     }
     $dbw->startAtomic(__METHOD__);
     Hooks::run('TitleMoveStarting', [$this->oldTitle, $this->newTitle, $user]);
     $pageid = $this->oldTitle->getArticleID(Title::GAID_FOR_UPDATE);
     $protected = $this->oldTitle->isProtected();
     // Do the actual move; if this fails, it will throw an MWException(!)
     $nullRevision = $this->moveToInternal($user, $this->newTitle, $reason, $createRedirect);
     // Refresh the sortkey for this row.  Be careful to avoid resetting
     // cl_timestamp, which may disturb time-based lists on some sites.
     // @todo This block should be killed, it's duplicating code
     // from LinksUpdate::getCategoryInsertions() and friends.
     $prefixes = $dbw->select('categorylinks', ['cl_sortkey_prefix', 'cl_to'], ['cl_from' => $pageid], __METHOD__);
     if ($this->newTitle->getNamespace() == NS_CATEGORY) {
         $type = 'subcat';
     } elseif ($this->newTitle->getNamespace() == NS_FILE) {
         $type = 'file';
     } else {
         $type = 'page';
     }
     foreach ($prefixes as $prefixRow) {
         $prefix = $prefixRow->cl_sortkey_prefix;
         $catTo = $prefixRow->cl_to;
         $dbw->update('categorylinks', ['cl_sortkey' => Collation::singleton()->getSortKey($this->newTitle->getCategorySortkey($prefix)), 'cl_collation' => $wgCategoryCollation, 'cl_type' => $type, 'cl_timestamp=cl_timestamp'], ['cl_from' => $pageid, 'cl_to' => $catTo], __METHOD__);
     }
     $redirid = $this->oldTitle->getArticleID();
     if ($protected) {
         # Protect the redirect title as the title used to be...
         $res = $dbw->select('page_restrictions', '*', ['pr_page' => $pageid], __METHOD__, 'FOR UPDATE');
         $rowsInsert = [];
         foreach ($res as $row) {
             $rowsInsert[] = ['pr_page' => $redirid, 'pr_type' => $row->pr_type, 'pr_level' => $row->pr_level, 'pr_cascade' => $row->pr_cascade, 'pr_user' => $row->pr_user, 'pr_expiry' => $row->pr_expiry];
         }
         $dbw->insert('page_restrictions', $rowsInsert, __METHOD__, ['IGNORE']);
         // Build comment for log
         $comment = wfMessage('prot_1movedto2', $this->oldTitle->getPrefixedText(), $this->newTitle->getPrefixedText())->inContentLanguage()->text();
         if ($reason) {
             $comment .= wfMessage('colon-separator')->inContentLanguage()->text() . $reason;
         }
         // reread inserted pr_ids for log relation
         $insertedPrIds = $dbw->select('page_restrictions', 'pr_id', ['pr_page' => $redirid], __METHOD__);
         $logRelationsValues = [];
         foreach ($insertedPrIds as $prid) {
             $logRelationsValues[] = $prid->pr_id;
         }
         // Update the protection log
         $logEntry = new ManualLogEntry('protect', 'move_prot');
         $logEntry->setTarget($this->newTitle);
         $logEntry->setComment($comment);
         $logEntry->setPerformer($user);
         $logEntry->setParameters(['4::oldtitle' => $this->oldTitle->getPrefixedText()]);
         $logEntry->setRelations(['pr_id' => $logRelationsValues]);
         $logId = $logEntry->insert();
         $logEntry->publish($logId);
     }
     // Update *_from_namespace fields as needed
     if ($this->oldTitle->getNamespace() != $this->newTitle->getNamespace()) {
         $dbw->update('pagelinks', ['pl_from_namespace' => $this->newTitle->getNamespace()], ['pl_from' => $pageid], __METHOD__);
         $dbw->update('templatelinks', ['tl_from_namespace' => $this->newTitle->getNamespace()], ['tl_from' => $pageid], __METHOD__);
         $dbw->update('imagelinks', ['il_from_namespace' => $this->newTitle->getNamespace()], ['il_from' => $pageid], __METHOD__);
     }
     # Update watchlists
     $oldtitle = $this->oldTitle->getDBkey();
     $newtitle = $this->newTitle->getDBkey();
     $oldsnamespace = MWNamespace::getSubject($this->oldTitle->getNamespace());
     $newsnamespace = MWNamespace::getSubject($this->newTitle->getNamespace());
     if ($oldsnamespace != $newsnamespace || $oldtitle != $newtitle) {
         $store = MediaWikiServices::getInstance()->getWatchedItemStore();
         $store->duplicateAllAssociatedEntries($this->oldTitle, $this->newTitle);
     }
     Hooks::run('TitleMoveCompleting', [$this->oldTitle, $this->newTitle, $user, $pageid, $redirid, $reason, $nullRevision]);
     $dbw->endAtomic(__METHOD__);
     $params = [&$this->oldTitle, &$this->newTitle, &$user, $pageid, $redirid, $reason, $nullRevision];
     // Keep each single hook handler atomic
     DeferredUpdates::addUpdate(new AtomicSectionUpdate($dbw, __METHOD__, function () use($params) {
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki,代码行数:101,代码来源:MovePage.php

示例4: doDeleteUpdates

	/**
	 * Do some database updates after deletion
	 *
	 * @param int $id page_id value of the page being deleted
	 * @param $content 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.
	 */
	public function doDeleteUpdates( $id, Content $content = null ) {
		// update site status
		DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) );

		// remove secondary indexes, etc
		$updates = $this->getDeletionUpdates( $content );
		DataUpdate::runUpdates( $updates );

		// Clear caches
		WikiPage::onArticleDelete( $this->mTitle );

		// Reset this object and the Title object
		$this->loadFromRow( false, self::READ_LATEST );

		// Search engine
		DeferredUpdates::addUpdate( new SearchUpdate( $id, $this->mTitle ) );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:24,代码来源:WikiPage.php

示例5: finishImportPage

 /**
  * Mostly for hook use
  * @param Title $title
  * @param ForeignTitle $foreignTitle
  * @param int $revCount
  * @param int $sRevCount
  * @param array $pageInfo
  * @return bool
  */
 public function finishImportPage($title, $foreignTitle, $revCount, $sRevCount, $pageInfo)
 {
     // Update article count statistics (T42009)
     // The normal counting logic in WikiPage->doEditUpdates() is designed for
     // one-revision-at-a-time editing, not bulk imports. In this situation it
     // suffers from issues of slave lag. We let WikiPage handle the total page
     // and revision count, and we implement our own custom logic for the
     // article (content page) count.
     $page = WikiPage::factory($title);
     $page->loadPageData('fromdbmaster');
     $content = $page->getContent();
     if ($content === null) {
         wfDebug(__METHOD__ . ': Skipping article count adjustment for ' . $title . ' because WikiPage::getContent() returned null');
     } else {
         $editInfo = $page->prepareContentForEdit($content);
         $countKey = 'title_' . $title->getPrefixedText();
         $countable = $page->isCountable($editInfo);
         if (array_key_exists($countKey, $this->countableCache) && $countable != $this->countableCache[$countKey]) {
             DeferredUpdates::addUpdate(SiteStatsUpdate::factory(array('articles' => (int) $countable - (int) $this->countableCache[$countKey])));
         }
     }
     $args = func_get_args();
     return Hooks::run('AfterImportPage', $args);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:33,代码来源:Import.php

示例6: undeleteRevisions


//.........这里部分代码省略.........
         $previousRevId = 0;
         $previousTimestamp = 0;
     }
     $oldWhere = array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey());
     if (!$restoreAll) {
         $oldWhere['ar_timestamp'] = array_map(array(&$dbw, 'timestamp'), $timestamps);
     }
     $fields = array('ar_rev_id', 'ar_text', 'ar_comment', 'ar_user', 'ar_user_text', 'ar_timestamp', 'ar_minor_edit', 'ar_flags', 'ar_text_id', 'ar_deleted', 'ar_page_id', 'ar_len', 'ar_sha1');
     if ($this->config->get('ContentHandlerUseDB')) {
         $fields[] = 'ar_content_format';
         $fields[] = 'ar_content_model';
     }
     /**
      * Select each archived revision...
      */
     $result = $dbw->select('archive', $fields, $oldWhere, __METHOD__, array('ORDER BY' => 'ar_timestamp'));
     $rev_count = $result->numRows();
     if (!$rev_count) {
         wfDebug(__METHOD__ . ": no revisions to restore\n");
         $status = Status::newGood(0);
         $status->warning("undelete-no-results");
         return $status;
     }
     $result->seek($rev_count - 1);
     // move to last
     $row = $result->fetchObject();
     // get newest archived rev
     $oldPageId = (int) $row->ar_page_id;
     // pass this to ArticleUndelete hook
     $result->seek(0);
     // move back
     // grab the content to check consistency with global state before restoring the page.
     $revision = Revision::newFromArchiveRow($row, array('title' => $article->getTitle()));
     $user = User::newFromName($revision->getUserText(Revision::RAW), false);
     $content = $revision->getContent(Revision::RAW);
     // NOTE: article ID may not be known yet. prepareSave() should not modify the database.
     $status = $content->prepareSave($article, 0, -1, $user);
     if (!$status->isOK()) {
         return $status;
     }
     if ($makepage) {
         // Check the state of the newest to-be version...
         if (!$unsuppress && $row->ar_deleted & Revision::DELETED_TEXT) {
             return Status::newFatal("undeleterevdel");
         }
         // Safe to insert now...
         $newid = $article->insertOn($dbw, $row->ar_page_id);
         if ($newid === false) {
             // The old ID is reserved; let's pick another
             $newid = $article->insertOn($dbw);
         }
         $pageId = $newid;
     } else {
         // Check if a deleted revision will become the current revision...
         if ($row->ar_timestamp > $previousTimestamp) {
             // Check the state of the newest to-be version...
             if (!$unsuppress && $row->ar_deleted & Revision::DELETED_TEXT) {
                 return Status::newFatal("undeleterevdel");
             }
         }
         $newid = false;
         $pageId = $article->getId();
     }
     $revision = null;
     $restored = 0;
     foreach ($result as $row) {
         // Check for key dupes due to needed archive integrity.
         if ($row->ar_rev_id) {
             $exists = $dbw->selectField('revision', '1', array('rev_id' => $row->ar_rev_id), __METHOD__);
             if ($exists) {
                 continue;
                 // don't throw DB errors
             }
         }
         // Insert one revision at a time...maintaining deletion status
         // unless we are specifically removing all restrictions...
         $revision = Revision::newFromArchiveRow($row, array('page' => $pageId, 'title' => $this->title, 'deleted' => $unsuppress ? 0 : $row->ar_deleted));
         $revision->insertOn($dbw);
         $restored++;
         Hooks::run('ArticleRevisionUndeleted', array(&$this->title, $revision, $row->ar_page_id));
     }
     # Now that it's safely stored, take it out of the archive
     $dbw->delete('archive', $oldWhere, __METHOD__);
     // Was anything restored at all?
     if ($restored == 0) {
         return Status::newGood(0);
     }
     $created = (bool) $newid;
     // Attach the latest revision to the page...
     $wasnew = $article->updateIfNewerOn($dbw, $revision, $previousRevId);
     if ($created || $wasnew) {
         // Update site stats, link tables, etc
         $article->doEditUpdates($revision, User::newFromName($revision->getUserText(Revision::RAW), false), array('created' => $created, 'oldcountable' => $oldcountable, 'restored' => true));
     }
     Hooks::run('ArticleUndelete', array(&$this->title, $created, $comment, $oldPageId));
     if ($this->title->getNamespace() == NS_FILE) {
         DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->title, 'imagelinks'));
     }
     return Status::newGood($restored);
 }
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:101,代码来源:SpecialUndelete.php

示例7: doPurge

 /**
  * Override handling of action=purge
  * @return bool
  */
 public function doPurge()
 {
     $this->loadFile();
     if ($this->mFile->exists()) {
         wfDebug('ImagePage::doPurge purging ' . $this->mFile->getName() . "\n");
         DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->mTitle, 'imagelinks'));
         $this->mFile->purgeCache(['forThumbRefresh' => true]);
     } else {
         wfDebug('ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n");
         // even if the file supposedly doesn't exist, force any cached information
         // to be updated (in case the cached information is wrong)
         $this->mFile->purgeCache(['forThumbRefresh' => true]);
     }
     if ($this->mRepo) {
         // Purge redirect cache
         $this->mRepo->invalidateImageRedirect($this->mTitle);
     }
     return parent::doPurge();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:23,代码来源:WikiFilePage.php

示例8: invalidateProperties

 /**
  * Invalidate any necessary link lists related to page property changes
  * @param array $changed
  */
 private function invalidateProperties($changed)
 {
     global $wgPagePropLinkInvalidations;
     foreach ($changed as $name => $value) {
         if (isset($wgPagePropLinkInvalidations[$name])) {
             $inv = $wgPagePropLinkInvalidations[$name];
             if (!is_array($inv)) {
                 $inv = array($inv);
             }
             foreach ($inv as $table) {
                 DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->mTitle, $table));
             }
         }
     }
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:19,代码来源:LinksUpdate.php

示例9: initUser

 /**
  * Actually add a user to the database.
  * Give it a User object that has been initialised with a name.
  *
  * @param User $u
  * @param bool $autocreate True if this is an autocreation via auth plugin
  * @return Status Status object, with the User object in the value member on success
  * @private
  */
 function initUser($u, $autocreate)
 {
     global $wgAuth;
     $status = $u->addToDatabase();
     if (!$status->isOK()) {
         return $status;
     }
     if ($wgAuth->allowPasswordChange()) {
         $u->setPassword($this->mPassword);
     }
     $u->setEmail($this->mEmail);
     $u->setRealName($this->mRealName);
     $u->setToken();
     $wgAuth->initUser($u, $autocreate);
     $u->saveSettings();
     // Update user count
     DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1));
     // Watch user's userpage and talk page
     $u->addWatch($u->getUserPage(), WatchedItem::IGNORE_USER_RIGHTS);
     return Status::newGood($u);
 }
开发者ID:natebrunette,项目名称:sphericalcow,代码行数:30,代码来源:SpecialUserlogin.php

示例10: initUser

 /**
  * Actually add a user to the database.
  * Give it a User object that has been initialised with a name.
  *
  * @param $u User object.
  * @param $autocreate boolean -- true if this is an autocreation via auth plugin
  * @return User object.
  * @private
  */
 function initUser($u, $autocreate)
 {
     global $wgAuth;
     $u->addToDatabase();
     if ($wgAuth->allowPasswordChange()) {
         $u->setPassword($this->mPassword);
     }
     $u->setEmail($this->mEmail);
     $u->setRealName($this->mRealName);
     $u->setToken();
     $wgAuth->initUser($u, $autocreate);
     if ($this->mExtUser) {
         $this->mExtUser->linkToLocal($u->getId());
         $email = $this->mExtUser->getPref('emailaddress');
         if ($email && !$this->mEmail) {
             $u->setEmail($email);
         }
     }
     $u->setOption('rememberpassword', $this->mRemember ? 1 : 0);
     $u->saveSettings();
     # Update user count
     DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1));
     return $u;
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:33,代码来源:SpecialUserlogin.php

示例11: attemptAddUser

 /**
  * Attempt to add a user to the database
  * Does the required authentication checks and updates for auto-creation
  * @param $user User
  * @throws Exception
  * @return bool Success
  */
 static function attemptAddUser($user)
 {
     global $wgAuth, $wgCentralAuthCreateOnView;
     $userName = $user->getName();
     // Denied by configuration?
     if (!$wgAuth->autoCreate()) {
         wfDebug(__METHOD__ . ": denied by configuration\n");
         return false;
     }
     if (!$wgCentralAuthCreateOnView) {
         // Only create local accounts when we perform an active login...
         // Don't freak people out on every page view
         wfDebug(__METHOD__ . ": denied by \$wgCentralAuthCreateOnView\n");
         return false;
     }
     // Is the user blacklisted by the session?
     // This is just a cache to avoid expensive DB queries in $user->isAllowedToCreateAccount().
     // The user can log in via Special:UserLogin to bypass the blacklist and get a proper
     // error message.
     $session = CentralAuthUser::getSession();
     if (isset($session['auto-create-blacklist']) && in_array(wfWikiID(), (array) $session['auto-create-blacklist'])) {
         wfDebug(__METHOD__ . ": blacklisted by session\n");
         return false;
     }
     // Is the user blocked?
     $anon = new User();
     if (!$anon->isAllowedAny('createaccount', 'centralauth-autoaccount') || $anon->isBlockedFromCreateAccount()) {
         // Blacklist the user to avoid repeated DB queries subsequently
         // First load the session again in case it changed while the above DB query was in progress
         wfDebug(__METHOD__ . ": user is blocked from this wiki, blacklisting\n");
         $session['auto-create-blacklist'][] = wfWikiID();
         CentralAuthUser::setSession($session);
         return false;
     }
     // Check for validity of username
     if (!User::isCreatableName($userName)) {
         wfDebug(__METHOD__ . ": Invalid username\n");
         $session['auto-create-blacklist'][] = wfWikiID();
         CentralAuthUser::setSession($session);
         return false;
     }
     // Give other extensions a chance to stop auto creation.
     $user->loadDefaults($userName);
     $abortMessage = '';
     if (!Hooks::run('AbortAutoAccount', array($user, &$abortMessage))) {
         // In this case we have no way to return the message to the user,
         // but we can log it.
         wfDebug(__METHOD__ . ": denied by other extension: {$abortMessage}\n");
         $session['auto-create-blacklist'][] = wfWikiID();
         CentralAuthUser::setSession($session);
         return false;
     }
     // Make sure the name has not been changed
     if ($user->getName() !== $userName) {
         throw new Exception("AbortAutoAccount hook tried to change the user name");
     }
     // Checks passed, create the user
     $from = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'CLI';
     wfDebugLog('CentralAuth-Bug39996', __METHOD__ . ": creating new user ({$userName}) - from: {$from}\n");
     try {
         $status = $user->addToDatabase();
     } catch (Exception $e) {
         wfDebugLog('CentralAuth-Bug39996', __METHOD__ . " User::addToDatabase for \"{$userName}\" threw an exception:" . " {$e->getMessage()}");
         throw $e;
     }
     if ($status === null) {
         // MW before 1.21 -- ok, continue
     } elseif (!$status->isOK()) {
         wfDebugLog('CentralAuth-Bug39996', __METHOD__ . ": failed with message " . $status->getWikiText() . "\n");
         return false;
     }
     $wgAuth->initUser($user, true);
     # Notify hooks (e.g. Newuserlog)
     Hooks::run('AuthPluginAutoCreate', array($user));
     # Update user count
     DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1));
     return true;
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:85,代码来源:CentralAuthHooks.php

示例12: doDeleteUpdates

 /**
  * Do some database updates after deletion
  *
  * @param int $id The page_id value of the page being deleted
  * @param Content $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.
  */
 public function doDeleteUpdates($id, Content $content = null)
 {
     // update site status
     DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 1, -(int) $this->isCountable(), -1));
     // remove secondary indexes, etc
     $updates = $this->getDeletionUpdates($content);
     DataUpdate::runUpdates($updates);
     // 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);
     // Reset this object and the Title object
     $this->loadFromRow(false, self::READ_LATEST);
     // Search engine
     DeferredUpdates::addUpdate(new SearchUpdate($id, $this->mTitle));
 }
开发者ID:ucfengzhun,项目名称:mediawiki,代码行数:28,代码来源:WikiPage.php

示例13: setPageSearchText

 static function setPageSearchText($title, $text)
 {
     DeferredUpdates::addUpdate(new SearchUpdate($title->getArticleID(), $title->getText(), $text));
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:4,代码来源:ApprovedRevs_body.php

示例14: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     $main = $this->getMain();
     if (!$main->isInternalMode() && !$main->getRequest()->wasPosted()) {
         $this->logFeatureUsage('purge-via-GET');
         $this->setWarning('Use of action=purge via GET is deprecated. Use POST instead.');
     }
     $params = $this->extractRequestParams();
     $continuationManager = new ApiContinuationManager($this, [], []);
     $this->setContinuationManager($continuationManager);
     $forceLinkUpdate = $params['forcelinkupdate'];
     $forceRecursiveLinkUpdate = $params['forcerecursivelinkupdate'];
     $pageSet = $this->getPageSet();
     $pageSet->execute();
     $result = $pageSet->getInvalidTitlesAndRevisions();
     $user = $this->getUser();
     foreach ($pageSet->getGoodTitles() as $title) {
         $r = [];
         ApiQueryBase::addTitleInfo($r, $title);
         $page = WikiPage::factory($title);
         if (!$user->pingLimiter('purge')) {
             $flags = WikiPage::PURGE_ALL;
             if (!$this->getRequest()->wasPosted()) {
                 $flags ^= WikiPage::PURGE_GLOBAL_PCACHE;
                 // skip DB_MASTER write
             }
             // Directly purge and skip the UI part of purge()
             $page->doPurge($flags);
             $r['purged'] = true;
         } else {
             $error = $this->parseMsg(['actionthrottledtext']);
             $this->setWarning($error['info']);
         }
         if ($forceLinkUpdate || $forceRecursiveLinkUpdate) {
             if (!$user->pingLimiter('linkpurge')) {
                 $popts = $page->makeParserOptions('canonical');
                 # Parse content; note that HTML generation is only needed if we want to cache the result.
                 $content = $page->getContent(Revision::RAW);
                 if ($content) {
                     $enableParserCache = $this->getConfig()->get('EnableParserCache');
                     $p_result = $content->getParserOutput($title, $page->getLatest(), $popts, $enableParserCache);
                     # Logging to better see expensive usage patterns
                     if ($forceRecursiveLinkUpdate) {
                         LoggerFactory::getInstance('RecursiveLinkPurge')->info("Recursive link purge enqueued for {title}", ['user' => $this->getUser()->getName(), 'title' => $title->getPrefixedText()]);
                     }
                     # Update the links tables
                     $updates = $content->getSecondaryDataUpdates($title, null, $forceRecursiveLinkUpdate, $p_result);
                     foreach ($updates as $update) {
                         DeferredUpdates::addUpdate($update, DeferredUpdates::PRESEND);
                     }
                     $r['linkupdate'] = true;
                     if ($enableParserCache) {
                         $pcache = ParserCache::singleton();
                         $pcache->save($p_result, $page, $popts);
                     }
                 }
             } else {
                 $error = $this->parseMsg(['actionthrottledtext']);
                 $this->setWarning($error['info']);
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     ApiResult::setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
     $values = $pageSet->getNormalizedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'normalized', $values);
     }
     $values = $pageSet->getConvertedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'converted', $values);
     }
     $values = $pageSet->getRedirectTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'redirects', $values);
     }
     $this->setContinuationManager(null);
     $continuationManager->setContinuationIntoResult($apiResult);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:85,代码来源:ApiPurge.php

示例15: autoCreateUser


//.........这里部分代码省略.........
         $user->setId(0);
         $user->loadFromId();
         return Status::newFatal('noname');
     }
     // Is the IP user able to create accounts?
     $anon = new User();
     if (!$anon->isAllowedAny('createaccount', 'autocreateaccount')) {
         $this->logger->debug(__METHOD__ . ': IP lacks the ability to create or autocreate accounts', ['username' => $username, 'ip' => $anon->getName()]);
         $session->set('AuthManager::AutoCreateBlacklist', 'authmanager-autocreate-noperm', 600);
         $session->persist();
         $user->setId(0);
         $user->loadFromId();
         return Status::newFatal('authmanager-autocreate-noperm');
     }
     // Avoid account creation races on double submissions
     $cache = \ObjectCache::getLocalClusterInstance();
     $lock = $cache->getScopedLock($cache->makeGlobalKey('account', md5($username)));
     if (!$lock) {
         $this->logger->debug(__METHOD__ . ': Could not acquire account creation lock', ['user' => $username]);
         $user->setId(0);
         $user->loadFromId();
         return Status::newFatal('usernameinprogress');
     }
     // Denied by providers?
     $providers = $this->getPreAuthenticationProviders() + $this->getPrimaryAuthenticationProviders() + $this->getSecondaryAuthenticationProviders();
     foreach ($providers as $provider) {
         $status = $provider->testUserForCreation($user, $source);
         if (!$status->isGood()) {
             $ret = Status::wrap($status);
             $this->logger->debug(__METHOD__ . ': Provider denied creation of {username}: {reason}', ['username' => $username, 'reason' => $ret->getWikiText(null, null, 'en')]);
             $session->set('AuthManager::AutoCreateBlacklist', $status, 600);
             $user->setId(0);
             $user->loadFromId();
             return $ret;
         }
     }
     // Ignore warnings about master connections/writes...hard to avoid here
     \Profiler::instance()->getTransactionProfiler()->resetExpectations();
     $backoffKey = wfMemcKey('AuthManager', 'autocreate-failed', md5($username));
     if ($cache->get($backoffKey)) {
         $this->logger->debug(__METHOD__ . ': {username} denied by prior creation attempt failures', ['username' => $username]);
         $user->setId(0);
         $user->loadFromId();
         return Status::newFatal('authmanager-autocreate-exception');
     }
     // Checks passed, create the user...
     $from = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'CLI';
     $this->logger->info(__METHOD__ . ': creating new user ({username}) - from: {from}', ['username' => $username, 'from' => $from]);
     try {
         $status = $user->addToDatabase();
         if (!$status->isOk()) {
             // double-check for a race condition (T70012)
             $localId = User::idFromName($username, User::READ_LATEST);
             if ($localId) {
                 $this->logger->info(__METHOD__ . ': {username} already exists locally (race)', ['username' => $username]);
                 $user->setId($localId);
                 $user->loadFromId(User::READ_LATEST);
                 if ($login) {
                     $this->setSessionDataForUser($user);
                 }
                 $status = Status::newGood();
                 $status->warning('userexists');
             } else {
                 $this->logger->error(__METHOD__ . ': {username} failed with message {message}', ['username' => $username, 'message' => $status->getWikiText(null, null, 'en')]);
                 $user->setId(0);
                 $user->loadFromId();
             }
             return $status;
         }
     } catch (\Exception $ex) {
         $this->logger->error(__METHOD__ . ': {username} failed with exception {exception}', ['username' => $username, 'exception' => $ex]);
         // Do not keep throwing errors for a while
         $cache->set($backoffKey, 1, 600);
         // Bubble up error; which should normally trigger DB rollbacks
         throw $ex;
     }
     $this->setDefaultUserOptions($user, true);
     // Inform the providers
     $this->callMethodOnProviders(6, 'autoCreatedAccount', [$user, $source]);
     \Hooks::run('AuthPluginAutoCreate', [$user], '1.27');
     \Hooks::run('LocalUserCreated', [$user, true]);
     $user->saveSettings();
     // Update user count
     \DeferredUpdates::addUpdate(new \SiteStatsUpdate(0, 0, 0, 0, 1));
     // Watch user's userpage and talk page
     $user->addWatch($user->getUserPage(), User::IGNORE_USER_RIGHTS);
     // Log the creation
     if ($this->config->get('NewUserLog')) {
         $logEntry = new \ManualLogEntry('newusers', 'autocreate');
         $logEntry->setPerformer($user);
         $logEntry->setTarget($user->getUserPage());
         $logEntry->setComment('');
         $logEntry->setParameters(['4::userid' => $user->getId()]);
         $logid = $logEntry->insert();
     }
     if ($login) {
         $this->setSessionDataForUser($user);
     }
     return Status::newGood();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:101,代码来源:AuthManager.php


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