當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wfGetLB函數代碼示例

本文整理匯總了PHP中wfGetLB函數的典型用法代碼示例。如果您正苦於以下問題:PHP wfGetLB函數的具體用法?PHP wfGetLB怎麽用?PHP wfGetLB使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wfGetLB函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的wfGetLB函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。