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


PHP wfGetLBFactory函數代碼示例

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


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

示例1: newConnection

 /**
  * Open a connection to the master server with the admin rights.
  * @return Database
  * @access private
  */
 function newConnection()
 {
     $lb = wfGetLBFactory()->newMainLB();
     $db = $lb->getConnection(DB_MASTER);
     $this->loadBalancers[] = $lb;
     return $db;
 }
開發者ID:GodelDesign,項目名稱:Godel,代碼行數:12,代碼來源:upgrade1_5.php

示例2: process

 public function process()
 {
     // Erweiterung der Elternfunktion process()
     $post = $this->request->data('post');
     $get = $this->request->data('get');
     unset($get['title']);
     // dirty MediaWiki fix: /wiki/foo -> /w/index.php?title=foo
     if (isset($get['allowed_filetarpathes'])) {
         $this->echoJson(self::$allowed_filetarpathes);
         exit;
     }
     if (!empty($this->request->file())) {
         $this->handleChunk();
         if (isset($this->returnData)) {
             $this->echoJson($this->returnData);
         }
         // Fehlermeldung "Uncommitted DB writes": MediaWiki mag es wahrscheinlich nicht,
         // wenn man exit() aufruft. vgl. http://stackoverflow.com/a/22695318
         $lb = wfGetLBFactory();
         $lb->shutdown();
         exit;
         # prevent MediaWiki to output something
     } elseif (!empty($get)) {
         $this->handleTestChunk();
         if (isset($this->returnData)) {
             $this->echoJson($this->returnData);
         }
         exit;
         # prevent MediaWiki to output something
     }
     $this->pruneChunks(true);
     # [true=always|false=random base]. Other option is to implement a cron script
 }
開發者ID:PhysikOnline-FFM,項目名稱:riedbergtv-video-converter-script,代碼行數:33,代碼來源:upload.php

示例3: getLB

 /**
  * @return \LoadBalancer
  */
 public function getLB()
 {
     if ($this->cluster !== false) {
         return wfGetLBFactory()->getExternalLB($this->cluster, $this->wiki);
     } else {
         return wfGetLB($this->wiki);
     }
 }
開發者ID:TarLocesilion,項目名稱:mediawiki-extensions-Flow,代碼行數:11,代碼來源:DbFactory.php

示例4: write

 /**
  * @param array $updates Array of arrays each containing two keys, 'primaryKey'
  *  and 'changes'. primaryKey must contain a map of column names to values
  *  sufficient to uniquely identify the row changes must contain a map of column
  *  names to update values to apply to the row.
  */
 public function write(array $updates)
 {
     $this->db->begin();
     foreach ($updates as $update) {
         $this->db->update($this->table, $update['changes'], $update['primaryKey'], __METHOD__);
     }
     $this->db->commit();
     wfGetLBFactory()->waitForReplication();
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:15,代碼來源:BatchRowWriter.php

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

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

示例7: execute

 public function execute()
 {
     wfProfileIn(__METHOD__);
     //run the download:
     Http::doSessionIdDownload($this->getOption('sid'), $this->getOption('usk'));
     // close up shop:
     // Execute any deferred updates
     wfDoUpdates();
     // Log what the user did, for book-keeping purposes.
     wfLogProfilingData();
     // Shut down the database before exit
     wfGetLBFactory()->shutdown();
     wfProfileOut(__METHOD__);
 }
開發者ID:rocLv,項目名稱:conference,代碼行數:14,代碼來源:httpSessionDownload.php

示例8: getOpenIDStore

	function getOpenIDStore( $storeType, $prefix, $options ) {
		global $wgOut, $wgMemc, $wgDBtype;

		switch ( $storeType ) {

		case 'file':
			# Auto-create path if it doesn't exist
			if ( !is_dir( $options['path'] ) ) {
				if ( !mkdir( $options['path'], 0770, true ) ) {
					$wgOut->showErrorPage( 'openidconfigerror', 'openidconfigerrortext' );
					return null;
				}
			}
			return new Auth_OpenID_FileStore( $options['path'] );

		case 'db':
			if ( $wgDBtype == 'sqlite' ) {
				$db = new MediaWikiOpenIDDatabaseConnection( wfGetDB( DB_MASTER ) );
				require_once( 'Auth/OpenID/SQLiteStore.php' );
				return new Auth_OpenID_SQLiteStore( $db );
			} else {
				$lb = wfGetLBFactory()->newMainLB();
				$db = new MediaWikiOpenIDDatabaseConnection( $lb->getConnection( DB_MASTER ) );
				switch( $wgDBtype ) {
				case 'mysql':
					require_once( 'Auth/OpenID/MySQLStore.php' );
					return new Auth_OpenID_MySQLStore( $db );
				case 'postgres':
					require_once( 'Auth/OpenID/PostgreSQLStore.php' );
					return new Auth_OpenID_PostgreSQLStore( $db );
				default:
					$wgOut->showErrorPage( 'openidconfigerror', 'openidconfigerrortext' );
					return null;
				}
			}

		case 'memcached':
			return new MediaWikiOpenIDMemcachedStore( $wgMemc );

		 default:
			$wgOut->showErrorPage( 'openidconfigerror', 'openidconfigerrortext' );
		}
	}
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:43,代碼來源:SpecialOpenID.body.php

示例9: getDB

 /**
  * @return DatabaseBase
  */
 protected function getDB()
 {
     if (!isset($this->db)) {
         # If server connection info was given, use that
         if ($this->serverInfo) {
             $this->lb = new LoadBalancer(array('servers' => array($this->serverInfo)));
             $this->db = $this->lb->getConnection(DB_MASTER);
             $this->db->clearFlag(DBO_TRX);
         } else {
             # We must keep a separate connection to MySQL in order to avoid deadlocks
             # However, SQLite has an opposite behaviour.
             # @todo Investigate behaviour for other databases
             if (wfGetDB(DB_MASTER)->getType() == 'sqlite') {
                 $this->db = wfGetDB(DB_MASTER);
             } else {
                 $this->lb = wfGetLBFactory()->newMainLB();
                 $this->db = $this->lb->getConnection(DB_MASTER);
                 $this->db->clearFlag(DBO_TRX);
             }
         }
     }
     return $this->db;
 }
開發者ID:eFFemeer,項目名稱:seizamcore,代碼行數:26,代碼來源:SqlBagOStuff.php

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

示例11: execute

 public function execute()
 {
     $wiki = $this->getOption('wikidb') ?: false;
     // Get the appropriate load balancer (for this wiki)
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'), $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     // Figure out which server to use
     if ($this->hasOption('slave')) {
         $server = $this->getOption('slave');
         if ($server === 'any') {
             $index = DB_SLAVE;
         } else {
             $index = null;
             for ($i = 0; $i < $lb->getServerCount(); ++$i) {
                 if ($lb->getServerName($i) === $server) {
                     $index = $i;
                     break;
                 }
             }
             if ($index === null) {
                 $this->error("No slave server configured with the name '{$server}'.", 1);
             }
         }
     } else {
         $index = DB_MASTER;
     }
     // Get a DB handle (with this wiki's DB selected) from the appropriate load balancer
     $db = $lb->getConnection($index, array(), $wiki);
     if ($this->hasOption('slave') && $db->getLBInfo('master') !== null) {
         $this->error("The server selected ({$db->getServer()}) is not a slave.", 1);
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $db->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $db->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $db->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $db->query($wholeLine);
             $this->sqlPrintResult($res, $db);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
開發者ID:Tarendai,項目名稱:spring-website,代碼行數:85,代碼來源:sql.php

示例12: restInPeace

 /**
  * Ends this task peacefully
  */
 public function restInPeace()
 {
     // Do any deferred jobs
     DeferredUpdates::doUpdates('commit');
     // Execute a job from the queue
     $this->doJobs();
     // 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:mangowi,項目名稱:mediawiki,代碼行數:17,代碼來源:Wiki.php

示例13: setWFVariables

 /**
  * setWFVariables
  *
  * add all default variables into city_variables table
  *
  * @author Krzysztof Krzyzaniak <eloy@wikia-inc.com>
  * @author Piotr Molski <moli@wikia-inc.com>
  * @access private
  *
  */
 private function setWFVariables()
 {
     // WF Variables containter
     $this->mWFSettingVars = array();
     $this->mWFSettingVars['wgSitename'] = $this->mNewWiki->sitename;
     $this->mWFSettingVars['wgLogo'] = self::DEFAULT_WIKI_LOGO;
     $this->mWFSettingVars['wgUploadPath'] = $this->mNewWiki->images_url;
     $this->mWFSettingVars['wgUploadDirectory'] = $this->mNewWiki->images_dir;
     $this->mWFSettingVars['wgDBname'] = $this->mNewWiki->dbname;
     $this->mWFSettingVars['wgLocalInterwiki'] = $this->mNewWiki->sitename;
     $this->mWFSettingVars['wgLanguageCode'] = $this->mNewWiki->language;
     $this->mWFSettingVars['wgServer'] = rtrim($this->mNewWiki->url, "/");
     $this->mWFSettingVars['wgEnableSectionEdit'] = true;
     $this->mWFSettingVars['wgEnableSwiftFileBackend'] = true;
     $this->mWFSettingVars['wgOasisLoadCommonCSS'] = true;
     if ($this->getInitialNjordExtValue()) {
         $this->mWFSettingVars['wgEnableNjordExt'] = true;
     }
     // rt#60223: colon allowed in sitename, breaks project namespace
     if (mb_strpos($this->mWFSettingVars['wgSitename'], ':') !== false) {
         $this->mWFSettingVars['wgMetaNamespace'] = str_replace(array(':', ' '), array('', '_'), $this->mWFSettingVars['wgSitename']);
     }
     if (self::ACTIVE_CLUSTER) {
         wfGetLBFactory()->sectionsByDB[$this->mNewWiki->dbname] = $this->mWFSettingVars['wgDBcluster'] = self::ACTIVE_CLUSTER;
     }
     $oRes = $this->mDBw->select("city_variables_pool", array("cv_id, cv_name"), array("cv_name in ('" . implode("', '", array_keys($this->mWFSettingVars)) . "')"), __METHOD__);
     $this->mWFVars = array();
     while ($oRow = $this->mDBw->fetchObject($oRes)) {
         $this->mWFVars[$oRow->cv_name] = $oRow->cv_id;
     }
     $this->mDBw->freeResult($oRes);
     foreach ($this->mWFSettingVars as $variable => $value) {
         /**
          * first, get id of variable
          */
         $cv_id = 0;
         if (isset($this->mWFVars[$variable])) {
             $cv_id = $this->mWFVars[$variable];
         }
         /**
          * then, insert value for wikia
          */
         if (!empty($cv_id)) {
             $this->mDBw->insert("city_variables", array("cv_value" => serialize($value), "cv_city_id" => $this->mNewWiki->city_id, "cv_variable_id" => $cv_id), __METHOD__);
         }
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:57,代碼來源:CreateWiki.php

示例14: rollbackMasterChangesAndLog

 /**
  * If there are any open database transactions, roll them back and log
  * the stack trace of the exception that should have been caught so the
  * transaction could be aborted properly.
  *
  * @since 1.23
  * @param Exception|Throwable $e
  */
 public static function rollbackMasterChangesAndLog($e)
 {
     $factory = wfGetLBFactory();
     if ($factory->hasMasterChanges()) {
         $logger = LoggerFactory::getInstance('Bug56269');
         $logger->warning('Exception thrown with an uncommited database transaction: ' . self::getLogMessage($e), self::getLogContext($e));
         $factory->rollbackMasterChanges(__METHOD__);
     }
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:17,代碼來源:MWExceptionHandler.php

示例15: rollbackMasterChangesAndLog

 /**
  * If there are any open database transactions, roll them back and log
  * the stack trace of the exception that should have been caught so the
  * transaction could be aborted properly.
  *
  * @since 1.23
  * @param Exception $e
  */
 public static function rollbackMasterChangesAndLog(Exception $e)
 {
     $factory = wfGetLBFactory();
     if ($factory->hasMasterChanges()) {
         wfDebugLog('Bug56269', 'Exception thrown with an uncommited database transaction: ' . MWExceptionHandler::getLogMessage($e) . "\n" . $e->getTraceAsString());
         $factory->rollbackMasterChanges();
     }
 }
開發者ID:D66Ha,項目名稱:mediawiki,代碼行數:16,代碼來源:MWExceptionHandler.php


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