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


PHP DeferredUpdates::doUpdates方法代码示例

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


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

示例1: addUpdate

 /**
  * Add an update to the deferred list
  * @param DeferrableUpdate $update Some object that implements doUpdate()
  */
 public static function addUpdate(DeferrableUpdate $update)
 {
     global $wgCommandLineMode;
     array_push(self::$updates, $update);
     if (self::$forceDeferral) {
         return;
     }
     // CLI scripts may forget to periodically flush these updates,
     // so try to handle that rather than OOMing and losing them.
     // Try to run the updates as soon as there is no local transaction.
     static $waitingOnTrx = false;
     // de-duplicate callback
     if ($wgCommandLineMode && !$waitingOnTrx) {
         $lb = wfGetLB();
         $dbw = $lb->getAnyOpenConnection($lb->getWriterIndex());
         // Do the update as soon as there is no transaction
         if ($dbw && $dbw->trxLevel()) {
             $waitingOnTrx = true;
             $dbw->onTransactionIdle(function () use(&$waitingOnTrx) {
                 DeferredUpdates::doUpdates();
                 $waitingOnTrx = false;
             });
         } else {
             self::doUpdates();
         }
     }
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:31,代码来源:DeferredUpdates.php

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

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

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

示例5: testReportDupes

 /**
  * @covers BagOStuff::__construct
  * @covers BagOStuff::trackDuplicateKeys
  */
 public function testReportDupes()
 {
     $logger = $this->getMock('Psr\\Log\\NullLogger');
     $logger->expects($this->once())->method('warning')->with('Duplicate get(): "{key}" fetched {count} times', ['key' => 'foo', 'count' => 2]);
     $cache = new HashBagOStuff(['reportDupes' => true, 'asyncHandler' => 'DeferredUpdates::addCallableUpdate', 'logger' => $logger]);
     $cache->get('foo');
     $cache->get('bar');
     $cache->get('foo');
     DeferredUpdates::doUpdates();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:BagOStuffTest.php

示例6: restInPeace

 /**
  * Ends this task peacefully
  * @param string $mode Use 'fast' to always skip job running
  */
 public function restInPeace($mode = 'fast')
 {
     // Assure deferred updates are not in the main transaction
     wfGetLBFactory()->commitMasterChanges(__METHOD__);
     // Ignore things like master queries/connections on GET requests
     // as long as they are in deferred updates (which catch errors).
     Profiler::instance()->getTransactionProfiler()->resetExpectations();
     // Do any deferred jobs
     DeferredUpdates::doUpdates('enqueue');
     // Make sure any lazy jobs are pushed
     JobQueueGroup::pushLazyJobs();
     // Now that everything specific to this request is done,
     // try to occasionally run jobs (if enabled) from the queues
     if ($mode === 'normal') {
         $this->triggerJobs();
     }
     // Log profiling data, e.g. in the database or UDP
     wfLogProfilingData();
     // Commit and close up!
     $factory = wfGetLBFactory();
     $factory->commitMasterChanges(__METHOD__);
     $factory->shutdown(LBFactory::SHUTDOWN_NO_CHRONPROT);
     wfDebug("Request ended normally\n");
 }
开发者ID:xiebinyi,项目名称:mediawiki,代码行数:28,代码来源:MediaWiki.php

示例7: restInPeace

 /**
  * Ends this task peacefully
  */
 public function restInPeace()
 {
     // Ignore things like master queries/connections on GET requests
     // as long as they are in deferred updates (which catch errors).
     Profiler::instance()->getTransactionProfiler()->resetExpectations();
     // Do any deferred jobs
     DeferredUpdates::doUpdates('commit');
     // Make sure any lazy jobs are pushed
     JobQueueGroup::pushLazyJobs();
     // Log profiling data, e.g. in the database or UDP
     wfLogProfilingData();
     // Commit and close up!
     $factory = wfGetLBFactory();
     $factory->commitMasterChanges();
     $factory->shutdown();
     wfDebug("Request ended normally\n");
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:20,代码来源:MediaWiki.php

示例8: executeJob

 /**
  * @param Job $job
  * @param BufferingStatsdDataFactory $stats
  * @param float $popTime
  * @return array Map of status/error/timeMs
  */
 private function executeJob(Job $job, $stats, $popTime)
 {
     $jType = $job->getType();
     $msg = $job->toString() . " STARTING";
     $this->logger->debug($msg);
     $this->debugCallback($msg);
     // Run the job...
     $rssStart = $this->getMaxRssKb();
     $jobStartTime = microtime(true);
     try {
         $status = $job->run();
         $error = $job->getLastError();
         $this->commitMasterChanges($job);
         DeferredUpdates::doUpdates();
         $this->commitMasterChanges($job);
     } catch (Exception $e) {
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         $status = false;
         $error = get_class($e) . ': ' . $e->getMessage();
         MWExceptionHandler::logException($e);
     }
     // Commit all outstanding connections that are in a transaction
     // to get a fresh repeatable read snapshot on every connection.
     // Note that jobs are still responsible for handling slave lag.
     wfGetLBFactory()->commitAll(__METHOD__);
     // Clear out title cache data from prior snapshots
     LinkCache::singleton()->clear();
     $timeMs = intval((microtime(true) - $jobStartTime) * 1000);
     $rssEnd = $this->getMaxRssKb();
     // Record how long jobs wait before getting popped
     $readyTs = $job->getReadyTimestamp();
     if ($readyTs) {
         $pickupDelay = max(0, $popTime - $readyTs);
         $stats->timing('jobqueue.pickup_delay.all', 1000 * $pickupDelay);
         $stats->timing("jobqueue.pickup_delay.{$jType}", 1000 * $pickupDelay);
     }
     // Record root job age for jobs being run
     $root = $job->getRootJobParams();
     if ($root['rootJobTimestamp']) {
         $age = max(0, $popTime - wfTimestamp(TS_UNIX, $root['rootJobTimestamp']));
         $stats->timing("jobqueue.pickup_root_age.{$jType}", 1000 * $age);
     }
     // Track the execution time for jobs
     $stats->timing("jobqueue.run.{$jType}", $timeMs);
     // Track RSS increases for jobs (in case of memory leaks)
     if ($rssStart && $rssEnd) {
         $stats->increment("jobqueue.rss_delta.{$jType}", $rssEnd - $rssStart);
     }
     if ($status === false) {
         $msg = $job->toString() . " t={$timeMs} error={$error}";
         $this->logger->error($msg);
         $this->debugCallback($msg);
     } else {
         $msg = $job->toString() . " t={$timeMs} good";
         $this->logger->info($msg);
         $this->debugCallback($msg);
     }
     return array('status' => $status, 'error' => $error, 'timeMs' => $timeMs);
 }
开发者ID:lourinaldi,项目名称:mediawiki,代码行数:65,代码来源:JobRunner.php

示例9: testDoUpdatesCLI

 public function testDoUpdatesCLI()
 {
     $this->setMwGlobals('wgCommandLineMode', true);
     $updates = ['1' => "deferred update 1;\n", '2' => "deferred update 2;\n", '2-1' => "deferred update 1 within deferred update 2;\n", '2-2' => "deferred update 2 within deferred update 2;\n", '3' => "deferred update 3;\n", '3-1' => "deferred update 1 within deferred update 3;\n", '3-2' => "deferred update 2 within deferred update 3;\n", '3-1-1' => "deferred update 1 within deferred update 1 within deferred update 3;\n", '3-2-1' => "deferred update 1 within deferred update 2 with deferred update 3;\n"];
     wfGetLBFactory()->commitMasterChanges(__METHOD__);
     // clear anything
     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['2-2'];
         });
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['3'];
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['3-1'];
             DeferredUpdates::addCallableUpdate(function () use($updates) {
                 echo $updates['3-1-1'];
             });
         });
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['3-2'];
             DeferredUpdates::addCallableUpdate(function () use($updates) {
                 echo $updates['3-2-1'];
             });
         });
     });
     $this->expectOutputString(implode('', $updates));
     DeferredUpdates::doUpdates();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:36,代码来源:DeferredUpdatesTest.php

示例10: executePendingDeferredUpdates

 /**
  * @since 2.4
  */
 public static function executePendingDeferredUpdates()
 {
     DeferredCallableUpdate::releasePendingUpdates();
     \DeferredUpdates::doUpdates();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:8,代码来源:TestEnvironment.php

示例11: wfDoUpdates

/**
 * Do any deferred updates and clear the list
 *
 * @deprecated since 1.19
 * @see DeferredUpdates::doUpdate()
 * @param $commit string
 */
function wfDoUpdates($commit = '')
{
    wfDeprecated(__METHOD__, '1.19');
    DeferredUpdates::doUpdates($commit);
}
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:12,代码来源:GlobalFunctions.php

示例12: showReport

 function showReport()
 {
     if (!$this->mQuiet) {
         $delta = microtime(true) - $this->startTime;
         if ($delta) {
             $rate = sprintf("%.2f", $this->pageCount / $delta);
             $revrate = sprintf("%.2f", $this->revCount / $delta);
         } else {
             $rate = '-';
             $revrate = '-';
         }
         # Logs dumps don't have page tallies
         if ($this->pageCount) {
             $this->progress("{$this->pageCount} ({$rate} pages/sec {$revrate} revs/sec)");
         } else {
             $this->progress("{$this->revCount} ({$revrate} revs/sec)");
         }
     }
     wfWaitForSlaves();
     // XXX: Don't let deferred jobs array get absurdly large (bug 24375)
     DeferredUpdates::doUpdates('commit');
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:22,代码来源:importDump.php

示例13: wfLogProfilingData

        $cluster = 'pmtpa';
        require "{$IP}/../wmf-config/wgConf.php";
    }
    // Require the configuration (probably LocalSettings.php)
    require $maintenance->loadSettings();
}
if ($maintenance->getDbType() === Maintenance::DB_NONE) {
    if ($wgLocalisationCacheConf['storeClass'] === false && ($wgLocalisationCacheConf['store'] == 'db' || $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory)) {
        $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
    }
}
$maintenance->finalSetup();
// Some last includes
require_once "{$IP}/includes/Setup.php";
// Do the work
try {
    $maintenance->execute();
    // Potentially debug globals
    $maintenance->globals();
    // Perform deferred updates.
    DeferredUpdates::doUpdates('commit');
    // log profiling info
    wfLogProfilingData();
    // Commit and close up!
    $factory = wfGetLBFactory();
    $factory->commitMasterChanges();
    $factory->shutdown();
} catch (MWException $mwe) {
    echo $mwe->getText();
    exit(1);
}
开发者ID:spring,项目名称:spring-website,代码行数:31,代码来源:doMaintenance.php

示例14: push

 private static function push(array &$queue, DeferrableUpdate $update)
 {
     global $wgCommandLineMode;
     if ($update instanceof MergeableUpdate) {
         $class = get_class($update);
         // fully-qualified class
         if (isset($queue[$class])) {
             /** @var $existingUpdate MergeableUpdate */
             $existingUpdate = $queue[$class];
             $existingUpdate->merge($update);
         } else {
             $queue[$class] = $update;
         }
     } else {
         $queue[] = $update;
     }
     // CLI scripts may forget to periodically flush these updates,
     // so try to handle that rather than OOMing and losing them entirely.
     // Try to run the updates as soon as there is no current wiki transaction.
     static $waitingOnTrx = false;
     // de-duplicate callback
     if ($wgCommandLineMode && !$waitingOnTrx) {
         $lb = wfGetLB();
         $dbw = $lb->getAnyOpenConnection($lb->getWriterIndex());
         // Do the update as soon as there is no transaction
         if ($dbw && $dbw->trxLevel()) {
             $waitingOnTrx = true;
             $dbw->onTransactionIdle(function () use(&$waitingOnTrx) {
                 DeferredUpdates::doUpdates();
                 $waitingOnTrx = false;
             });
         } else {
             self::doUpdates();
         }
     }
 }
开发者ID:xiebinyi,项目名称:mediawiki,代码行数:36,代码来源:DeferredUpdates.php

示例15: testAsyncWrites

 public function testAsyncWrites()
 {
     $be = TestingAccessWrapper::newFromObject(new FileBackendMultiWrite(array('name' => 'localtesting', 'wikiId' => wfWikiId() . mt_rand(), 'backends' => array(array('name' => 'multitesting0', 'class' => 'MemoryFileBackend', 'isMultiMaster' => false), array('name' => 'multitesting1', 'class' => 'MemoryFileBackend', 'isMultiMaster' => true)), 'replication' => 'async')));
     DeferredUpdates::forceDeferral(true);
     $p = 'container/test-cont/file.txt';
     $be->quickCreate(array('dst' => "mwstore://localtesting/{$p}", 'content' => 'cattitude'));
     $this->assertEquals(false, $be->backends[0]->getFileContents(array('src' => "mwstore://multitesting0/{$p}")), "File not yet written to backend 0");
     $this->assertEquals('cattitude', $be->backends[1]->getFileContents(array('src' => "mwstore://multitesting1/{$p}")), "File already written to backend 1");
     DeferredUpdates::doUpdates();
     DeferredUpdates::forceDeferral(false);
     $this->assertEquals('cattitude', $be->backends[0]->getFileContents(array('src' => "mwstore://multitesting0/{$p}")), "File now written to backend 0");
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:12,代码来源:FileBackendTest.php


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