• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfGetLB函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

 /**
  * loads property pair occurrence probability table from given csv file
  */
 function execute()
 {
     if (substr($this->getOption('file'), 0, 2) === "--") {
         $this->error("The --file option requires a file as an argument.\n", true);
     }
     $path = $this->getOption('file');
     $fullPath = realpath($path);
     $fullPath = str_replace('\\', '/', $fullPath);
     if (!file_exists($fullPath)) {
         $this->error("Cant find {$path} \n", true);
     }
     $tableName = 'wbs_propertypairs';
     wfWaitForSlaves();
     $lb = wfGetLB();
     $this->clearTable($lb, $tableName);
     $this->output("loading new entries from file\n");
     $importContext = $this->createImportContext($lb, $tableName, $fullPath, $this->isQuiet());
     $importStrategy = new BasicImporter();
     try {
         $success = $importStrategy->importFromCsvFileToDb($importContext);
     } catch (UnexpectedValueException $e) {
         $this->error("Import failed: " . $e->getMessage());
         exit;
     }
     if (!$success) {
         $this->error("Failed to run import to db");
     }
     $this->output("... Done loading\n");
 }
开发者ID:siebrand,项目名称:PropertySuggester,代码行数:32,代码来源:UpdateTable.php


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


示例3: testClusters

 /**
  * Execute checks for all requested clusters
  */
 private function testClusters()
 {
     foreach ($this->clusters as $clusterName) {
         $this->current = "{$clusterName}: ";
         $fullHealth = false;
         $operational = false;
         try {
             $databaseName = $this->getClusterDatabase($clusterName);
             $loadBalancer = wfGetLB($databaseName);
             $serverCount = $loadBalancer->getServerCount();
             $roles = ['master' => [], 'slave' => []];
             for ($i = 0; $i < $serverCount; $i++) {
                 $serverName = $loadBalancer->getServerName($i);
                 $this->current = "{$clusterName}: {$serverName}: ";
                 $role = $i === 0 ? 'master' : 'slave';
                 $roles[$role][$serverName] = $this->testHost($databaseName, $loadBalancer, $i);
             }
             if ($serverCount == 1) {
                 $fullHealth = $operational = reset($roles['master']);
             } else {
                 // full health = no host raised any issue
                 $fullHealth = !$this->occursInArray(false, $roles['master']) && !$this->occursInArray(false, $roles['slave']);
                 // operational = at least one master and one slave are working correctly
                 $operational = $this->occursInArray(true, $roles['master']) && $this->occursInArray(true, $roles['slave']);
             }
         } catch (DBError $e) {
             $this->addError($e->getMessage());
         }
         $this->status[$clusterName] = $fullHealth ? 'ok' : ($operational ? 'warning' : 'critical');
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:34,代码来源:HealthController.class.php


示例4: execute

 public function execute()
 {
     if ($this->hasOption('r')) {
         $lb = wfGetLB();
         echo 'time     ';
         $serverCount = $lb->getServerCount();
         for ($i = 1; $i < $serverCount; $i++) {
             $hostname = $lb->getServerName($i);
             printf("%-12s ", $hostname);
         }
         echo "\n";
         while (1) {
             $lb->clearLagTimeCache();
             $lags = $lb->getLagTimes();
             unset($lags[0]);
             echo gmdate('H:i:s') . ' ';
             foreach ($lags as $lag) {
                 printf("%-12s ", $lag === false ? 'false' : $lag);
             }
             echo "\n";
             sleep(5);
         }
     } else {
         $lb = wfGetLB();
         $lags = $lb->getLagTimes();
         foreach ($lags as $i => $lag) {
             $name = $lb->getServerName($i);
             $this->output(sprintf("%-20s %s\n", $name, $lag === false ? 'false' : $lag));
         }
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:31,代码来源:lag.php


示例5: __construct

 /**
  * Constructor
  *
  * @param bool $withTransaction Whether this update should be wrapped in a
  *   transaction (default: true). A transaction is only started if no
  *   transaction is already in progress, see beginTransaction() for details.
  */
 public function __construct($withTransaction = true)
 {
     parent::__construct();
     $this->mDb = wfGetLB()->getLazyConnectionRef(DB_MASTER);
     $this->mWithTransaction = $withTransaction;
     $this->mHasTransaction = false;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:14,代码来源:SqlDataUpdate.php


示例6: execute

	public function execute() {
		$userName = 'The Thing That Should Not Be'; // <- targer username

		$user = new CentralAuthUser( $userName );
		if ( !$user->exists() ) {
			echo "Cannot unsuppress non-existent user {$userName}!\n";
			exit( 0 );
		}
		$userName = $user->getName(); // sanity
		$wikis = $user->listAttached(); // wikis with attached accounts
		foreach ( $wikis as $wiki ) {
			$lb = wfGetLB( $wiki );
			$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
			# Get local ID like $user->localUserData( $wiki ) does
			$localUserId = $dbw->selectField( 'user', 'user_id',
				array( 'user_name' => $userName ), __METHOD__ );

			$delUserBit = Revision::DELETED_USER;
			$hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
				array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
			echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
			# Unsuppress username on edits
			if ( $hiddenCount > 0 ) {
				echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
				IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
				echo "done!\n\n";
			}
			$lb->reuseConnection( $dbw ); // not really needed
			# Don't lag too bad
			wfWaitForSlaves( 5 );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:unsuppressCrossWiki.php


示例7: execute

 /**
  * Special page "deleted user contributions".
  * Shows a list of the deleted contributions of a user.
  *
  * @param string $par (optional) user name of the user for which to show the contributions
  */
 function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $user = $this->getUser();
     if (!$this->userCanExecute($user)) {
         $this->displayRestrictionError();
         return;
     }
     $request = $this->getRequest();
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('deletedcontributions-title'));
     $options = [];
     if ($par !== null) {
         $target = $par;
     } else {
         $target = $request->getVal('target');
     }
     if (!strlen($target)) {
         $out->addHTML($this->getForm(''));
         return;
     }
     $options['limit'] = $request->getInt('limit', $this->getConfig()->get('QueryPageDefaultLimit'));
     $options['target'] = $target;
     $userObj = User::newFromName($target, false);
     if (!$userObj) {
         $out->addHTML($this->getForm(''));
         return;
     }
     $this->getSkin()->setRelevantUser($userObj);
     $target = $userObj->getName();
     $out->addSubtitle($this->getSubTitle($userObj));
     $ns = $request->getVal('namespace', null);
     if ($ns !== null && $ns !== '') {
         $options['namespace'] = intval($ns);
     } else {
         $options['namespace'] = '';
     }
     $out->addHTML($this->getForm($options));
     $pager = new DeletedContribsPager($this->getContext(), $target, $options['namespace']);
     if (!$pager->getNumRows()) {
         $out->addWikiMsg('nocontribs');
         return;
     }
     # Show a message about replica DB lag, if applicable
     $lag = wfGetLB()->safeGetLag($pager->getDatabase());
     if ($lag > 0) {
         $out->showLagWarning($lag);
     }
     $out->addHTML('<p>' . $pager->getNavigationBar() . '</p>' . $pager->getBody() . '<p>' . $pager->getNavigationBar() . '</p>');
     # If there were contributions, and it was a valid user or IP, show
     # the appropriate "footer" message - WHOIS tools, etc.
     if ($target != 'newbies') {
         $message = IP::isIPAddress($target) ? 'sp-contributions-footer-anon' : 'sp-contributions-footer';
         if (!$this->msg($message)->isDisabled()) {
             $out->wrapWikiMsg("<div class='mw-contributions-footer'>\n\$1\n</div>", [$message, $target]);
         }
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:65,代码来源:SpecialDeletedContributions.php


示例8: testChangeExists

 /**
  * @dataProvider provideChangeExists
  */
 public function testChangeExists($expected, array $changeData)
 {
     $connectionManager = new ConsistentReadConnectionManager(wfGetLB());
     $detector = new RecentChangesDuplicateDetector($connectionManager);
     $this->initRecentChanges();
     $change = $this->newChange($changeData);
     $this->assertEquals($expected, $detector->changeExists($change), 'changeExists()');
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:11,代码来源:RecentChangesDuplicateDetectorTest.php


示例9: tearDown

 function tearDown()
 {
     if (!is_null($this->db)) {
         wfGetLB()->closeConnecton($this->db);
     }
     unset($this->db);
     unset($this->search);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:8,代码来源:SearchMySQLTest.php


示例10: addTestChanges

 private function addTestChanges()
 {
     $changeStore = new SqlChangeStore(wfGetLB());
     $change = new EntityChange($this->getChangeRowData('20150101000005'));
     $changeStore->saveChange($change);
     $change = new EntityChange($this->getChangeRowData('20150101000300'));
     $changeStore->saveChange($change);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:8,代码来源:ChangePrunerTest.php


示例11: setUp

 protected function setUp()
 {
     $this->tablesUsed[] = EntityUsageTable::DEFAULT_TABLE_NAME;
     $this->tablesUsed[] = 'page';
     parent::setUp();
     $this->sqlUsageTracker = new SqlUsageTracker(new BasicEntityIdParser(), new ConsistentReadConnectionManager(wfGetLB()));
     $this->trackerTester = new UsageTrackerContractTester($this->sqlUsageTracker, array($this, 'getUsages'));
     $this->lookupTester = new UsageLookupContractTester($this->sqlUsageTracker, array($this, 'putUsages'));
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:9,代码来源:SqlUsageTrackerTest.php


示例12: execute

	function execute() {
		global $wgConf;
		foreach ( $wgConf->getLocalDatabases() as $wiki ) {
			$lb = wfGetLB( $wiki );
			$db = $lb->getConnection( DB_MASTER, array(), $wiki );
			$count = intval( $db->selectField( 'job', 'COUNT(*)', '', __METHOD__ ) );
			$this->output( "$wiki $count\n" );
			$lb->reuseConnection( $db );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:10,代码来源:getJobQueueLengths.php


示例13: checkMaxLag

 /**
  * Check if the maximum lag of database slaves is higher that $maxLag, and
  * if it's the case, output an error message
  *
  * @param $maxLag int: maximum lag allowed for the request, as supplied by
  *                the client
  * @return bool true if the request can continue
  */
 function checkMaxLag($maxLag)
 {
     list($host, $lag) = wfGetLB()->getMaxLag();
     if ($lag > $maxLag) {
         wfMaxlagError($host, $lag, $maxLag);
         return false;
     } else {
         return true;
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:18,代码来源:Wiki.php


示例14: fillSubscriptionTable

 /**
  * Static wrapper for EntityUsageTableBuilder::fillUsageTable
  *
  * @param DatabaseUpdater $dbUpdater
  * @param string $table
  */
 public static function fillSubscriptionTable(DatabaseUpdater $dbUpdater, $table)
 {
     $primer = new ChangesSubscriptionTableBuilder(wfGetLB(), $table, 1000);
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(function ($msg) use($dbUpdater) {
         $dbUpdater->output("\t{$msg}\n");
     });
     $primer->setProgressReporter($reporter);
     $primer->fillSubscriptionTable();
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:16,代码来源:ChangesSubscriptionSchemaUpdater.php


示例15: createStoreAndLookup

 /**
  * @see EntityLookupTest::newEntityLoader()
  *
  * @return array array( EntityStore, EntityLookup )
  */
 protected function createStoreAndLookup()
 {
     // make sure the term index is empty to avoid conflicts.
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $wikibaseRepo->getStore()->getTermIndex()->clear();
     //NOTE: we want to test integration of WikiPageEntityRevisionLookup and WikiPageEntityStore here!
     $contentCodec = $wikibaseRepo->getEntityContentDataCodec();
     $lookup = new WikiPageEntityRevisionLookup($contentCodec, new WikiPageEntityMetaDataLookup($this->getEntityIdParser(), false), false);
     $store = new WikiPageEntityStore(new EntityContentFactory($wikibaseRepo->getContentModelMappings()), new SqlIdGenerator(wfGetLB()));
     return array($store, $lookup);
 }
开发者ID:TU-Berlin,项目名称:WikidataMath,代码行数:16,代码来源:WikiPageEntityStoreTest.php


示例16: fillUsageTable

 /**
  * Static wrapper for EntityUsageTableBuilder::fillUsageTable
  *
  * @param DatabaseUpdater $dbUpdater
  */
 public static function fillUsageTable(DatabaseUpdater $dbUpdater)
 {
     $idParser = WikibaseClient::getDefaultInstance()->getEntityIdParser();
     $primer = new EntityUsageTableBuilder($idParser, wfGetLB());
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(function ($msg) use($dbUpdater) {
         $dbUpdater->output("\t{$msg}\n");
     });
     $primer->setProgressReporter($reporter);
     $primer->fillUsageTable();
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:16,代码来源:SqlUsageTrackerSchemaUpdater.php


示例17: getDB

 /**
  * Wrapper function for wfGetDB
  *
  * @param $db int Index of the connection to get
  * @param $groups mixed Query groups.
  * @param $wiki string|bool The wiki ID, or false for the current wiki
  * @return DatabaseBase
  */
 public static function getDB($db, $groups = array(), $wiki = false)
 {
     global $wgEchoCluster;
     // Use the external db defined for Echo
     if ($wgEchoCluster) {
         $lb = wfGetLBFactory()->getExternalLB($wgEchoCluster, $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     return $lb->getConnection($db, $groups, $wiki);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:19,代码来源:EchoDbFactory.php


示例18: syncDBs

 public function syncDBs()
 {
     $lb = wfGetLB();
     // bug 27975 - Don't try to wait for slaves if there are none
     // Prevents permission error when getting master position
     if ($lb->getServerCount() > 1) {
         $dbw = $lb->getConnection(DB_MASTER);
         $pos = $dbw->getMasterPos();
         $lb->waitForAll($pos);
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:11,代码来源:updateCollation.php


示例19: run

 function run()
 {
     if (!empty($this->params['mainDbMasterPos'])) {
         wfGetLB()->waitFor($this->params['mainDbMasterPos']);
     }
     if (!empty($this->params['echoDbMasterPos'])) {
         global $wgEchoCluster;
         wfGetLBFactory()->getExternalLB($wgEchoCluster)->waitFor($this->params['echoDbMasterPos']);
     }
     EchoNotificationController::notify($this->event, false);
     return true;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:12,代码来源:NotificationJob.php


示例20: rebuildLocalizationCache

 /**
  * Update the special pages localization cache
  */
 public function rebuildLocalizationCache()
 {
     global $IP, $wgSpecialPageCacheUpdates, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
     $dbw = wfGetDB(DB_MASTER);
     foreach ($wgSpecialPageCacheUpdates as $special => $call) {
         if (!is_callable($call)) {
             throw new \InvalidArgumentException("Uncallable function '{$call}' for special page {$special}");
         }
         $start = wfTime();
         call_user_func($call, $dbw);
         $end = wfTime();
         $this->info(sprintf("%-30s completed in %.2fs", $special, $end - $start));
         // Wait for the slave to catch up
         wfWaitForSlaves();
     }
     // This is needed to initialise $wgQueryPages
     require_once "{$IP}/includes/QueryPage.php";
     $disabledPages = $wgDisableQueryPageUpdate ? array_flip($wgDisableQueryPageUpdate) : [];
     foreach ($wgQueryPages as $page) {
         list($class, $special) = $page;
         $limit = isset($page[2]) ? $page[2] : $wgQueryCacheLimit;
         $queryPage = $this->getQueryPage($special, $class);
         if (array_key_exists($special, $disabledPages)) {
             // skip disabled pages
             $this->info(sprintf("%-30s disabled", $special));
             continue;
         }
         if (!$queryPage->isExpensive()) {
             // don't bother with cheap pages
             $this->info(sprintf("%-30s skipped", $special));
             continue;
         }
         $start = wfTime();
         $num = $queryPage->recache($limit);
         $end = wfTime();
         if ($num === false) {
             throw new \DBError($dbw, "database error");
         }
         $this->info(sprintf("%-30s updated %d rows in %.2fs", $special, $num, $end - $start));
         if (wfGetLB()->pingAll()) {
             // commit the changes if all connections are still open
             $dbw->commit();
         } else {
             // Reopen any connections that have closed
             $count = 6;
             do {
                 sleep(10);
             } while ($count-- > 0 && !wfGetLB()->pingAll());
         }
         // Wait for the slave to catch up
         wfWaitForSlaves();
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:56,代码来源:UpdateSpecialPagesTask.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfGetLBFactory函数代码示例发布时间:2022-05-23
下一篇:
PHP wfGetIP函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap