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

PHP wfGetLBFactory函数代码示例

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

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



在下文中一共展示了wfGetLBFactory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]>
  * @author Piotr Molski <[email protected]>
  * @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


示例16: execute

 public function execute()
 {
     // Get a DB handle (with this wiki's DB select) from the appropriate load balancer
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'));
         $dbw = $lb->getConnection(DB_MASTER);
         // master for external LB
     } else {
         $dbw = wfGetDB(DB_MASTER);
         // master for primary LB for this wiki
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->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 = $dbw->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 . $dbw->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:62,代码来源:sql.php


示例17: wfHttpError

}
if (strcmp("{$wgScriptPath}/api{$wgScriptExtension}", $url)) {
    wfHttpError(403, 'Forbidden', 'API must be accessed through the primary script entry point.');
    return;
}
// Verify that the API has not been disabled
if (!$wgEnableAPI) {
    echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
    echo '<pre><b>$wgEnableAPI=true;</b></pre>';
    die(1);
}
// So extensions can check whether they're running in API mode
define('MW_API', true);
// Set a dummy $wgTitle, because $wgTitle == null breaks various things
// In a perfect world this wouldn't be necessary
$wgTitle = Title::newFromText('API');
/* Construct an ApiMain with the arguments passed via the URL. What we get back
 * is some form of an ApiMain, possibly even one that produces an error message,
 * but we don't care here, as that is handled by the ctor.
 */
$processor = new ApiMain($wgRequest, $wgEnableWriteAPI);
// Process data & print results
$processor->execute();
// Execute any deferred updates
wfDoUpdates();
// Log what the user did, for book-keeping purposes.
wfProfileOut('api.php');
wfLogProfilingData();
// Shut down the database
wfGetLBFactory()->shutdown();
开发者ID:ui-libraries,项目名称:TIRW,代码行数:30,代码来源:api.php


示例18: getDB

 /**
  * @param int $index (DB_SLAVE/DB_MASTER)
  * @return DBConnRef
  */
 protected function getDB($index)
 {
     $lb = $this->cluster !== false ? wfGetLBFactory()->getExternalLB($this->cluster, $this->wiki) : wfGetLB($this->wiki);
     return $lb->getConnectionRef($index, array(), $this->wiki);
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:9,代码来源:JobQueueDB.php


示例19: restInPeace

 /**
  * Ends this task peacefully
  */
 function restInPeace()
 {
     wfLogProfilingData();
     // Commit and close up!
     $factory = wfGetLBFactory();
     $factory->commitMasterChanges();
     $factory->shutdown();
     wfDebug("Request ended normally\n");
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:12,代码来源:Wiki.php


示例20: getMasterDB

 /**
  * Get a master connection to the logging DB
  *
  * @return DatabaseBase
  * @throws DBError
  */
 protected function getMasterDB()
 {
     if (!$this->dbw) {
         // Get a separate connection in autocommit mode
         $lb = wfGetLBFactory()->newMainLB();
         $this->dbw = $lb->getConnection(DB_MASTER, array(), $this->wiki);
         $this->dbw->clearFlag(DBO_TRX);
     }
     return $this->dbw;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:16,代码来源:DBFileJournal.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wfGetLangObj函数代码示例发布时间:2022-05-23
下一篇:
PHP wfGetLB函数代码示例发布时间: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