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


PHP DeferredUpdates类代码示例

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


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

示例1: autoreview_current

 protected function autoreview_current(User $user)
 {
     $this->output("Auto-reviewing all current page versions...\n");
     if (!$user->getID()) {
         $this->output("Invalid user specified.\n");
         return;
     } elseif (!$user->isAllowed('review')) {
         $this->output("User specified (id: {$user->getID()}) does not have \"review\" rights.\n");
         return;
     }
     $db = wfGetDB(DB_MASTER);
     $this->output("Reviewer username: " . $user->getName() . "\n");
     $start = $db->selectField('page', 'MIN(page_id)', false, __METHOD__);
     $end = $db->selectField('page', 'MAX(page_id)', false, __METHOD__);
     if (is_null($start) || is_null($end)) {
         $this->output("...page table seems to be empty.\n");
         return;
     }
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     $count = 0;
     $changed = 0;
     $flags = FlaggedRevs::quickTags(FR_CHECKED);
     // Assume basic level
     while ($blockEnd <= $end) {
         $this->output("...doing page_id from {$blockStart} to {$blockEnd}\n");
         $res = $db->select(array('page', 'revision'), '*', array("page_id BETWEEN {$blockStart} AND {$blockEnd}", 'page_namespace' => FlaggedRevs::getReviewNamespaces(), 'rev_id = page_latest'), __METHOD__);
         # Go through and autoreview the current version of every page...
         foreach ($res as $row) {
             $title = Title::newFromRow($row);
             $rev = Revision::newFromRow($row);
             # Is it already reviewed?
             $frev = FlaggedRevision::newFromTitle($title, $row->page_latest, FR_MASTER);
             # Rev should exist, but to be safe...
             if (!$frev && $rev) {
                 $article = new Article($title);
                 $db->begin();
                 FlaggedRevs::autoReviewEdit($article, $user, $rev, $flags, true);
                 FlaggedRevs::HTMLCacheUpdates($article->getTitle());
                 $db->commit();
                 $changed++;
             }
             $count++;
         }
         $db->freeResult($res);
         $blockStart += $this->mBatchSize - 1;
         $blockEnd += $this->mBatchSize - 1;
         // XXX: Don't let deferred jobs array get absurdly large (bug 24375)
         DeferredUpdates::doUpdates('commit');
         wfWaitForSlaves(5);
     }
     $this->output("Auto-reviewing of all pages complete ..." . "{$count} rows [{$changed} changed]\n");
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:55,代码来源:reviewAllPages.php

示例2: enableCXBetaFeature

 public function enableCXBetaFeature()
 {
     $user = $this->getUser();
     $out = $this->getOutput();
     $user->setOption('cx', '1');
     // Promise to persist the setting post-send
     DeferredUpdates::addCallableUpdate(function () use($user) {
         $user->saveSettings();
     });
     $out->addModules('ext.cx.beta.notification');
 }
开发者ID:Rjaylyn,项目名称:mediawiki-extensions-ContentTranslation,代码行数:11,代码来源:SpecialContentTranslation.php

示例3: execute

 public function execute()
 {
     $user = $this->getUser();
     if ($this->getRequest()->wasPosted()) {
         $user->setNewtalk(false);
     } else {
         DeferredUpdates::addCallableUpdate(function () use($user) {
             $user->setNewtalk(false);
         });
     }
     $this->getResult()->addValue(null, $this->getModuleName(), 'success');
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:ApiClearHasMsg.php

示例4: execute

 public function execute($par)
 {
     $this->useTransactionalTimeLimit();
     $this->checkReadOnly();
     $this->setHeaders();
     $this->outputHeader();
     $request = $this->getRequest();
     $target = !is_null($par) ? $par : $request->getVal('target');
     // Yes, the use of getVal() and getText() is wanted, see bug 20365
     $oldTitleText = $request->getVal('wpOldTitle', $target);
     $this->oldTitle = Title::newFromText($oldTitleText);
     if (!$this->oldTitle) {
         // Either oldTitle wasn't passed, or newFromText returned null
         throw new ErrorPageError('notargettitle', 'notargettext');
     }
     if (!$this->oldTitle->exists()) {
         throw new ErrorPageError('nopagetitle', 'nopagetext');
     }
     $newTitleTextMain = $request->getText('wpNewTitleMain');
     $newTitleTextNs = $request->getInt('wpNewTitleNs', $this->oldTitle->getNamespace());
     // Backwards compatibility for forms submitting here from other sources
     // which is more common than it should be..
     $newTitleText_bc = $request->getText('wpNewTitle');
     $this->newTitle = strlen($newTitleText_bc) > 0 ? Title::newFromText($newTitleText_bc) : Title::makeTitleSafe($newTitleTextNs, $newTitleTextMain);
     $user = $this->getUser();
     # Check rights
     $permErrors = $this->oldTitle->getUserPermissionsErrors('move', $user);
     if (count($permErrors)) {
         // Auto-block user's IP if the account was "hard" blocked
         DeferredUpdates::addCallableUpdate(function () use($user) {
             $user->spreadAnyEditBlock();
         });
         throw new PermissionsError('move', $permErrors);
     }
     $def = !$request->wasPosted();
     $this->reason = $request->getText('wpReason');
     $this->moveTalk = $request->getBool('wpMovetalk', $def);
     $this->fixRedirects = $request->getBool('wpFixRedirects', $def);
     $this->leaveRedirect = $request->getBool('wpLeaveRedirect', $def);
     $this->moveSubpages = $request->getBool('wpMovesubpages', false);
     $this->deleteAndMove = $request->getBool('wpDeleteAndMove') && $request->getBool('wpConfirm');
     $this->moveOverShared = $request->getBool('wpMoveOverSharedFile', false);
     $this->watch = $request->getCheck('wpWatch') && $user->isLoggedIn();
     if ('submit' == $request->getVal('action') && $request->wasPosted() && $user->matchEditToken($request->getVal('wpEditToken'))) {
         $this->doSubmit();
     } else {
         $this->showForm(array());
     }
 }
开发者ID:foxlog,项目名称:wiki,代码行数:49,代码来源:SpecialMovepage.php

示例5: doUpdate

 public function doUpdate()
 {
     global $wgSiteStatsAsyncFactor;
     $this->doUpdateContextStats();
     $rate = $wgSiteStatsAsyncFactor;
     // convenience
     // If set to do so, only do actual DB updates 1 every $rate times.
     // The other times, just update "pending delta" values in memcached.
     if ($rate && ($rate < 0 || mt_rand(0, $rate - 1) != 0)) {
         $this->doUpdatePendingDeltas();
     } else {
         // Need a separate transaction because this a global lock
         DeferredUpdates::addCallableUpdate([$this, 'tryDBUpdateInternal']);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:SiteStatsUpdate.php

示例6: testDoUpdates

 public function testDoUpdates()
 {
     $updates = array('1' => 'deferred update 1', '2' => 'deferred update 2', '3' => 'deferred update 3', '2-1' => 'deferred update 1 within deferred update 2');
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['1'];
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['2'];
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['2-1'];
         });
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates[3];
     });
     $this->expectOutputString(implode('', $updates));
     DeferredUpdates::doUpdates();
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:18,代码来源:DeferredUpdatesTest.php

示例7: testDoUpdatesCLI

 public function testDoUpdatesCLI()
 {
     $this->setMwGlobals('wgCommandLineMode', true);
     $updates = array('1' => 'deferred update 1', '2' => 'deferred update 2', '2-1' => 'deferred update 1 within deferred update 2', '3' => 'deferred update 3');
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['1'];
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['2'];
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['2-1'];
         });
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates[3];
     });
     $this->expectOutputString(implode('', $updates));
     DeferredUpdates::doUpdates();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:19,代码来源:DeferredUpdatesTest.php

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

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

示例10: setUp

 protected function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
     $tmpDir = $this->getNewTempDirectory();
     $tmpGlobals = [];
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = ['class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => new FSFileBackend(['name' => 'local-backend', 'wikiId' => wfWikiID(), 'containerPaths' => ['local-public' => "{$tmpDir}/test-repo/public", 'local-thumb' => "{$tmpDir}/test-repo/thumb", 'local-temp' => "{$tmpDir}/test-repo/temp", 'local-deleted' => "{$tmpDir}/test-repo/delete"]])];
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgParserCacheType = CACHE_NONE;
     DeferredUpdates::clearPendingUpdates();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     RequestContext::resetMain();
     $context = RequestContext::getMain();
     $wgUser = new User();
     $wgLang = $context->getLanguage();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], [$wgParserConf]);
     $wgRequest = $context->getRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:38,代码来源:UploadFromUrlTestSuite.php

示例11: executeWhenAvailable

 /**
  * Render the special page
  * @param string $par parameter submitted as subpage
  */
 function executeWhenAvailable($par)
 {
     // Anons don't get a watchlist
     $this->requireLogin('mobile-frontend-watchlist-purpose');
     $ctx = MobileContext::singleton();
     $this->usePageImages = !$ctx->imagesDisabled() && defined('PAGE_IMAGES_INSTALLED');
     $user = $this->getUser();
     $output = $this->getOutput();
     $output->addModules('skins.minerva.special.watchlist.scripts');
     // FIXME: Loads twice with JS enabled (T87871)
     $output->addModuleStyles(array('skins.minerva.special.watchlist.styles', 'mobile.pagelist.styles', 'mobile.pagesummary.styles'));
     $req = $this->getRequest();
     $this->view = $req->getVal('watchlistview', 'a-z');
     $this->filter = $req->getVal('filter', 'all');
     $this->fromPageTitle = Title::newFromText($req->getVal('from', false));
     $output->setPageTitle($this->msg('watchlist'));
     // This needs to be done before calling getWatchlistHeader
     $this->updateStickyTabs();
     if ($this->optionsChanged) {
         DeferredUpdates::addCallableUpdate(function () use($user) {
             $user->saveSettings();
         });
     }
     if ($this->view === 'feed') {
         $output->addHtml($this->getWatchlistHeader($user));
         $output->addHtml(Html::openElement('div', array('class' => 'content-unstyled')));
         $this->showRecentChangesHeader();
         $res = $this->doFeedQuery();
         if ($res->numRows()) {
             $this->showFeedResults($res);
         } else {
             $this->showEmptyList(true);
         }
         $output->addHtml(Html::closeElement('div'));
     } else {
         $output->redirect(SpecialPage::getTitleFor('EditWatchlist')->getLocalURL());
     }
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:42,代码来源:SpecialMobileWatchlist.php

示例12: trackGroup

 /**
  * Keeps track of recently used message groups per user.
  */
 public static function trackGroup(MessageGroup $group, User $user)
 {
     if ($user->isAnon()) {
         return true;
     }
     $groups = $user->getOption('translate-recent-groups', '');
     if ($groups === '') {
         $groups = array();
     } else {
         $groups = explode('|', $groups);
     }
     if (isset($groups[0]) && $groups[0] === $group->getId()) {
         return true;
     }
     array_unshift($groups, $group->getId());
     $groups = array_unique($groups);
     $groups = array_slice($groups, 0, 5);
     $user->setOption('translate-recent-groups', implode('|', $groups));
     // Promise to persist the data post-send
     DeferredUpdates::addCallableUpdate(function () use($user) {
         $user->saveSettings();
     });
     return true;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:27,代码来源:ApiTranslateUser.php

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

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

示例15: onArticleEdit

 /**
  * Purge caches on page update etc
  *
  * @param Title $title
  * @param Revision|null $revision Revision that was just saved, may be null
  */
 public static function onArticleEdit(Title $title, Revision $revision = null)
 {
     // Invalidate caches of articles which include this page
     DeferredUpdates::addUpdate(new HTMLCacheUpdate($title, 'templatelinks'));
     // Invalidate the caches of all pages which redirect here
     DeferredUpdates::addUpdate(new HTMLCacheUpdate($title, 'redirect'));
     MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle($title);
     // Purge CDN for this page only
     $title->purgeSquid();
     // Clear file cache for this page only
     HTMLFileCache::clearFileCache($title);
     $revid = $revision ? $revision->getId() : null;
     DeferredUpdates::addCallableUpdate(function () use($title, $revid) {
         InfoAction::invalidateCache($title, $revid);
     });
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:22,代码来源:WikiPage.php


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