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

PHP wfGetMainCache函数代码示例

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

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



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

示例1: createCache

 function createCache()
 {
     if (!isset($this->cache)) {
         global $wgPageAttachment_useInternalCache;
         global $wgPageAttachment_internalCacheType;
         if (isset($wgPageAttachment_useInternalCache) && $wgPageAttachment_useInternalCache == true) {
             if (isset($wgPageAttachment_internalCacheType)) {
                 if ($wgPageAttachment_internalCacheType == 'SQLite3') {
                     $this->cache = new Provider\SQLiteCache();
                 } else {
                     if ($wgPageAttachment_internalCacheType == 'Database') {
                         $this->cache = new Provider\DatabaseCache();
                     } else {
                         print '<br/>*** ERROR ***************************************************************<br/>';
                         print 'PageAttachment internal cache is enabled.<br/>';
                         print 'However, invalid PageAttachment internal cache type specified: ' . $wgPageAttachment_internalCacheType . '<br/>';
                         print '*************************************************************************<br/>';
                     }
                 }
             } else {
                 print '<br/>*** ERROR ***************************************************************<br/>';
                 print 'PageAttachment internal cache is enabled.<br/>';
                 print 'However, PageAttachment internal cache type is not specified.<br/>';
                 print '*************************************************************************<br/>';
             }
         } else {
             $mwCacheObj = \wfGetMainCache();
             $this->cache = new Provider\MWCacheObjWrapper($mwCacheObj);
         }
     }
     return $this->cache;
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:32,代码来源:CacheFactory.php


示例2: __construct

 /**
  * @params include:
  *   - objectCache : Name of an object cache registered in $wgObjectCaches.
  *                   This defaults to the one specified by $wgMainCacheType.
  *   - cacheTTL    : Seconds to cache the aggregate data before regenerating.
  * @param array $params
  */
 protected function __construct(array $params)
 {
     parent::__construct($params);
     $this->cache = isset($params['objectCache']) ? wfGetCache($params['objectCache']) : wfGetMainCache();
     $this->cacheTTL = isset($params['cacheTTL']) ? $params['cacheTTL'] : 180;
     // 3 min
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:14,代码来源:JobQueueAggregatorMemc.php


示例3: __construct

 public function __construct($parent)
 {
     global $wgMemc;
     $this->parent = $parent;
     $this->srvCache = ObjectCache::newAccelerator(array(), 'hash');
     $this->mainCache = $wgMemc ?: wfGetMainCache();
 }
开发者ID:KaralisWebLabs,项目名称:mediawiki,代码行数:7,代码来源:LoadMonitor.php


示例4: __construct

 /**
  * Construct a new instance from configuration.
  * 
  * $config paramaters include:
  *     'dbServers'   : Associative array of DB names to server configuration.
  *                     Configuration is an associative array that includes:
  *                     'host'        - DB server name
  *                     'dbname'      - DB name
  *                     'type'        - DB type (mysql,postgres,...)
  *                     'user'        - DB user
  *                     'password'    - DB user password
  *                     'tablePrefix' - DB table prefix
  *                     'flags'       - DB flags (see DatabaseBase)
  *     'dbsByBucket' : Array of 1-16 consecutive integer keys, starting from 0,
  *                     each having an odd-numbered list of DB names (peers) as values.
  *                     Any DB named 'localDBMaster' will automatically use the DB master
  *                     settings for this wiki (without the need for a dbServers entry).
  *     'lockExpiry'  : Lock timeout (seconds) for dropped connections. [optional]
  *                     This tells the DB server how long to wait before assuming
  *                     connection failure and releasing all the locks for a session.
  *
  * @param Array $config 
  */
 public function __construct(array $config)
 {
     $this->dbServers = isset($config['dbServers']) ? $config['dbServers'] : array();
     // likely just using 'localDBMaster'
     // Sanitize dbsByBucket config to prevent PHP errors
     $this->dbsByBucket = array_filter($config['dbsByBucket'], 'is_array');
     $this->dbsByBucket = array_values($this->dbsByBucket);
     // consecutive
     if (isset($config['lockExpiry'])) {
         $this->lockExpiry = $config['lockExpiry'];
     } else {
         $met = ini_get('max_execution_time');
         $this->lockExpiry = $met ? $met : 60;
         // use some sane amount if 0
     }
     $this->safeDelay = $this->lockExpiry <= 0 ? 60 : $this->lockExpiry;
     // cover worst case
     foreach ($this->dbsByBucket as $bucket) {
         if (count($bucket) > 1) {
             // Tracks peers that couldn't be queried recently to avoid lengthy
             // connection timeouts. This is useless if each bucket has one peer.
             $this->statusCache = wfGetMainCache();
             break;
         }
     }
     $this->session = '';
     for ($i = 0; $i < 5; $i++) {
         $this->session .= mt_rand(0, 2147483647);
     }
     $this->session = wfBaseConvert(sha1($this->session), 16, 36, 31);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:54,代码来源:DBLockManager.php


示例5: setUp

 function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
     $wgScript = '/index.php';
     $wgScriptPath = '/';
     $wgArticlePath = '/wiki/$1';
     $wgStyleSheetPath = '/skins';
     $wgStylePath = '/skins';
     $wgThumbnailScriptPath = false;
     $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => wfTempDir() . '/test-repo', 'url' => 'http://example.com/images', 'deletedDir' => wfTempDir() . '/test-repo/delete', 'hashLevels' => 2, 'transformVia404' => false);
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     $wgDeferredUpdateList = array();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     // $wgContLang = new StubContLang;
     $wgUser = new User();
     $context = new RequestContext();
     $wgLang = $context->getLang();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = new WebRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:29,代码来源:UploadFromUrlTestSuite.php


示例6: newInstance

 /**
  * @since 1.21
  * @deprecated 1.25 Construct a SiteStore instance directly instead.
  *
  * @param ORMTable|null $sitesTable
  * @param BagOStuff|null $cache
  *
  * @return SiteStore
  */
 public static function newInstance(ORMTable $sitesTable = null, BagOStuff $cache = null)
 {
     if ($cache === null) {
         $cache = wfGetMainCache();
     }
     $siteStore = new DBSiteStore();
     return new static($siteStore, $cache);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:17,代码来源:SiteSQLStore.php


示例7: init

 /**
  * Initialization
  */
 private static function init()
 {
     clearstatcache();
     self::$cache =& wfGetMainCache();
     if (self::$cache instanceof FakeMemCachedClient) {
         self::$realCache = false;
     }
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:11,代码来源:ExtensionLoader.php


示例8: execute

 public function execute()
 {
     $force = $this->getOption('force', false);
     $this->source = $this->getOption('source', 'https://en.wikipedia.org/w/api.php');
     $this->cache = wfGetMainCache();
     $data = $this->fetchLinks();
     if ($data === false) {
         $this->error("Error during fetching data.");
     } else {
         $this->doPopulate($data, $force);
     }
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:12,代码来源:populateInterwiki.php


示例9: setUp

 function setUp()
 {
     global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
     global $wgHooks, $IP;
     $wgContLang = Language::factory('en');
     //Setup CLI arguments
     if ($this->getCliArg('regex=')) {
         $this->regex = $this->getCliArg('regex=');
     } else {
         # Matches anything
         $this->regex = '';
     }
     $this->keepUploads = $this->getCliArg('keep-uploads');
     $tmpGlobals = array();
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStyleSheetPath'] = '/skins';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = array('class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => 'local-backend');
     $tmpGlobals['wgForeignFileRepos'] = array();
     $tmpGlobals['wgEnableParserCache'] = false;
     $tmpGlobals['wgHooks'] = $wgHooks;
     $tmpGlobals['wgDeferredUpdateList'] = array();
     $tmpGlobals['wgMemc'] = wfGetMainCache();
     $tmpGlobals['messageMemc'] = wfGetMessageCacheStorage();
     $tmpGlobals['parserMemc'] = wfGetParserCacheStorage();
     // $tmpGlobals['wgContLang'] = new StubContLang;
     $tmpGlobals['wgUser'] = new User();
     $context = new RequestContext();
     $tmpGlobals['wgLang'] = $context->getLanguage();
     $tmpGlobals['wgOut'] = $context->getOutput();
     $tmpGlobals['wgParser'] = new StubObject('wgParser', $GLOBALS['wgParserConf']['class'], array($GLOBALS['wgParserConf']));
     $tmpGlobals['wgRequest'] = $context->getRequest();
     if ($GLOBALS['wgStyleDirectory'] === false) {
         $tmpGlobals['wgStyleDirectory'] = "{$IP}/skins";
     }
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedInitialGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $this->savedWeirdGlobals['mw_namespace_protection'] = $wgNamespaceProtection[NS_MEDIAWIKI];
     $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image'];
     $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk'];
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:51,代码来源:NewParserTest.php


示例10: getLagTimes

 function getLagTimes($serverIndexes, $wiki)
 {
     wfProfileIn(__METHOD__);
     $expiry = 5;
     $requestRate = 10;
     global $wgMemc;
     if (empty($wgMemc)) {
         $wgMemc = wfGetMainCache();
     }
     $masterName = $this->parent->getServerName(0);
     $memcKey = wfMemcKey('lag_times', $masterName);
     $times = $wgMemc->get($memcKey);
     if ($times) {
         # Randomly recache with probability rising over $expiry
         $elapsed = time() - $times['timestamp'];
         $chance = max(0, ($expiry - $elapsed) * $requestRate);
         if (mt_rand(0, $chance) != 0) {
             unset($times['timestamp']);
             wfProfileOut(__METHOD__);
             return $times;
         }
         wfIncrStats('lag_cache_miss_expired');
     } else {
         wfIncrStats('lag_cache_miss_absent');
     }
     # Cache key missing or expired
     $times = array();
     foreach ($serverIndexes as $i) {
         if ($i == 0) {
             # Master
             $times[$i] = 0;
         } elseif (false !== ($conn = $this->parent->getAnyOpenConnection($i))) {
             $times[$i] = $conn->getLag();
         } elseif (false !== ($conn = $this->parent->openConnection($i, $wiki))) {
             $times[$i] = $conn->getLag();
         }
     }
     # Add a timestamp key so we know when it was cached
     $times['timestamp'] = time();
     $wgMemc->set($memcKey, $times, $expiry);
     # But don't give the timestamp to the caller
     unset($times['timestamp']);
     $lagTimes = $times;
     wfProfileOut(__METHOD__);
     return $lagTimes;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:46,代码来源:LoadMonitor.php


示例11: suite

 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite();
     self::$iter = new TestFileIterator(PARSER_TESTS);
     foreach (self::$iter as $i => $test) {
         $suite->addTest(new ParserUnitTest($i, $test['test']));
         self::$count++;
     }
     unset($tests);
     self::$parser = new PTShell();
     self::$iter->setParser(self::$parser);
     self::$parser->recorder->start();
     self::$parser->setupDatabase();
     self::$iter->rewind();
     /* } */
     /* function setUp() { */
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $wgNamespacesWithSubpages, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
     $wgScript = '/index.php';
     $wgScriptPath = '/';
     $wgArticlePath = '/wiki/$1';
     $wgStyleSheetPath = '/skins';
     $wgStylePath = '/skins';
     $wgThumbnailScriptPath = false;
     $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => '', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false);
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     $wgDeferredUpdateList = array();
     $wgMemc =& wfGetMainCache();
     $messageMemc =& wfGetMessageCacheStorage();
     $parserMemc =& wfGetParserCacheStorage();
     $wgContLang = new StubContLang();
     $wgUser = new StubUser();
     $wgLang = new StubUserLang();
     $wgOut = new StubObject('wgOut', 'OutputPage');
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = new WebRequest();
     $wgMessageCache = new StubObject('wgMessageCache', 'MessageCache', array($messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID()));
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     return $suite;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:44,代码来源:MediaWikiParserTest.php


示例12: setUp

 protected function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
     $tmpDir = $this->getNewTempDirectory();
     $tmpGlobals = [];
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = ['class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => new FSFileBackend(['name' => 'local-backend', 'wikiId' => wfWikiID(), 'containerPaths' => ['local-public' => "{$tmpDir}/test-repo/public", 'local-thumb' => "{$tmpDir}/test-repo/thumb", 'local-temp' => "{$tmpDir}/test-repo/temp", 'local-deleted' => "{$tmpDir}/test-repo/delete"]])];
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgParserCacheType = CACHE_NONE;
     DeferredUpdates::clearPendingUpdates();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     RequestContext::resetMain();
     $context = RequestContext::getMain();
     $wgUser = new User();
     $wgLang = $context->getLanguage();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], [$wgParserConf]);
     $wgRequest = $context->getRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:38,代码来源:UploadFromUrlTestSuite.php


示例13: __construct

 public function __construct()
 {
     global $IP;
     // No Setup.php yet. Initialise everything by ourselves
     require_once $IP . '/includes/GlobalFunctions.php';
     require_once $IP . '/includes/ObjectCache.php';
     $wgMemc = wfGetMainCache();
     // Caching not yet working
     $cached = false;
     //$wgMemc->get( 'configurewmf:data' );
     if ($cached) {
         $this->overrides = $cached;
         return;
     }
     $dbr = self::getSlaveDB();
     $r = $dbr->select('config_overrides', array('cfg_target', 'cfg_value'), null, __METHOD__);
     $overrides = array();
     while ($row = $dbr->fetchObject($r)) {
         $overrides[] = array('target' => $row->cfg_target, 'value' => unserialize($row->cfg_value));
     }
     $wgMemc->set('configurewmf:data', $overrides);
     $this->overrides = $overrides;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:23,代码来源:ConfigureWMF.class.php


示例14: __construct

 /**
  * @see FileBackendStore::__construct()
  * Additional $config params include:
  *    swiftAuthUrl       : Swift authentication server URL
  *    swiftUser          : Swift user used by MediaWiki (account:username)
  *    swiftKey           : Swift authentication key for the above user
  *    swiftAuthTTL       : Swift authentication TTL (seconds)
  *    swiftAnonUser      : Swift user used for end-user requests (account:username)
  *    shardViaHashLevels : Map of container names to sharding config with:
  *                         'base'   : base of hash characters, 16 or 36
  *                         'levels' : the number of hash levels (and digits)
  *                         'repeat' : hash subdirectories are prefixed with all the
  *                                    parent hash directory names (e.g. "a/ab/abc")
  *	  swiftTimeout       : number of seconds timeout consistent with php-cloudfiles. Default: 10
  */
 public function __construct(array $config)
 {
     parent::__construct($config);
     // Required settings
     $this->auth = new CF_Authentication($config['swiftUser'], $config['swiftKey'], null, $config['swiftAuthUrl']);
     /* <Wikia> */
     if (!empty($config['debug'])) {
         $this->auth->setDebug($config['debug']);
     }
     $this->swiftTimeout = isset($config['swiftTimeout']) ? intval($config['swiftTimeout']) : 10;
     /* </Wikia> */
     // Optional settings
     $this->authTTL = isset($config['swiftAuthTTL']) ? $config['swiftAuthTTL'] : 120;
     // some sane number
     $this->swiftAnonUser = isset($config['swiftAnonUser']) ? $config['swiftAnonUser'] : '';
     $this->shardViaHashLevels = isset($config['shardViaHashLevels']) ? $config['shardViaHashLevels'] : '';
     /* <Wikia> */
     // caching credentials
     if (!empty($config['cacheAuthInfo']) && $config['cacheAuthInfo'] === true) {
         $this->srvCache = wfGetMainCache();
     }
     $this->srvCache = $this->srvCache ? $this->srvCache : new EmptyBagOStuff();
     /* </Wikia> */
 }
开发者ID:yusufchang,项目名称:app,代码行数:39,代码来源:SwiftFileBackend.php


示例15: reset

 /**
  * Purges the internal and external cache of the site list, forcing the list
  * of sites to be re-read from the database.
  *
  * @since 1.21
  */
 public function reset()
 {
     wfProfileIn(__METHOD__);
     // purge cache
     $cache = wfGetMainCache();
     $cache->delete($this->getCacheKey());
     $this->sites = null;
     wfProfileOut(__METHOD__);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:15,代码来源:SiteSQLStore.php


示例16: lock

 /**
  * Start a transaction and lock the image for update
  * Increments a reference counter if the lock is already held
  * @throws MWException
  * @return bool True if the image exists, false otherwise
  */
 function lock()
 {
     $dbw = $this->repo->getMasterDB();
     if (!$this->locked) {
         if (!$dbw->trxLevel()) {
             $dbw->begin(__METHOD__);
             $this->lockedOwnTrx = true;
         }
         $this->locked++;
         // Bug 54736: use simple lock to handle when the file does not exist.
         // SELECT FOR UPDATE only locks records not the gaps where there are none.
         $cache = wfGetMainCache();
         $key = $this->getCacheKey();
         if (!$cache->lock($key, 5)) {
             throw new MWException("Could not acquire lock for '{$this->getName()}.'");
         }
         $dbw->onTransactionIdle(function () use($cache, $key) {
             $cache->unlock($key);
             // release on commit
         });
     }
     return $dbw->selectField('image', '1', array('img_name' => $this->getName()), __METHOD__, array('FOR UPDATE'));
 }
开发者ID:spring,项目名称:spring-website,代码行数:29,代码来源:LocalFile.php


示例17: wfDebug

// Useful debug output
if ($wgCommandLineMode) {
    wfDebug("\n\nStart command line script {$self}\n");
} else {
    $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
    if ($wgDebugPrintHttpHeaders) {
        $debug .= "HTTP HEADERS:\n";
        foreach ($wgRequest->getAllHeaders() as $name => $value) {
            $debug .= "{$name}: {$value}\n";
        }
    }
    wfDebug($debug);
}
Profiler::instance()->scopedProfileOut($ps_misc);
$ps_memcached = Profiler::instance()->scopedProfileIn($fname . '-memcached');
$wgMemc = wfGetMainCache();
$messageMemc = wfGetMessageCacheStorage();
$parserMemc = wfGetParserCacheStorage();
wfDebugLog('caches', 'cluster: ' . get_class($wgMemc) . ', WAN: ' . ($wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache) . ', stash: ' . $wgMainStash . ', message: ' . get_class($messageMemc) . ', parser: ' . get_class($parserMemc) . ', session: ' . get_class(ObjectCache::getInstance($wgSessionCacheType)));
Profiler::instance()->scopedProfileOut($ps_memcached);
// Most of the config is out, some might want to run hooks here.
Hooks::run('SetupAfterCache');
$ps_globals = Profiler::instance()->scopedProfileIn($fname . '-globals');
/**
 * @var Language $wgContLang
 */
$wgContLang = Language::factory($wgLanguageCode);
$wgContLang->initContLang();
// Now that variant lists may be available...
$wgRequest->interpolateTitle();
if (!is_object($wgAuth)) {
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:Setup.php


示例18: highlight

 /**
  * Highlight a code-block using a particular lexer.
  *
  * @param string $code Code to highlight.
  * @param string|null $lang Language name, or null to use plain markup.
  * @param array $args Associative array of additional arguments.
  *  If it contains a 'line' key, the output will include line numbers.
  *  If it includes a 'highlight' key, the value will be parsed as a
  *  comma-separated list of lines and line-ranges to highlight.
  *  If it contains a 'start' key, the value will be used as the line at which to
  *  start highlighting.
  *  If it contains a 'inline' key, the output will not be wrapped in `<div><pre/></div>`.
  * @return Status Status object, with HTML representing the highlighted
  *  code as its value.
  */
 protected static function highlight($code, $lang = null, $args = array())
 {
     global $wgPygmentizePath;
     $status = new Status();
     $lexer = self::getLexer($lang);
     if ($lexer === null && $lang !== null) {
         $status->warning('syntaxhighlight-error-unknown-language', $lang);
     }
     $length = strlen($code);
     if (strlen($code) > self::HIGHLIGHT_MAX_BYTES) {
         $status->warning('syntaxhighlight-error-exceeds-size-limit', $length, self::HIGHLIGHT_MAX_BYTES);
         $lexer = null;
     }
     if (wfShellExecDisabled() !== false) {
         $status->warning('syntaxhighlight-error-pygments-invocation-failure');
         wfWarn('MediaWiki determined that it cannot invoke Pygments. ' . 'As a result, SyntaxHighlight_GeSHi will not perform any syntax highlighting. ' . 'See the debug log for details: ' . 'https://www.mediawiki.org/wiki/Manual:$wgDebugLogFile');
         $lexer = null;
     }
     $inline = isset($args['inline']);
     if ($lexer === null) {
         if ($inline) {
             $status->value = htmlspecialchars(trim($code), ENT_NOQUOTES);
         } else {
             $pre = Html::element('pre', array(), $code);
             $status->value = Html::rawElement('div', array('class' => self::HIGHLIGHT_CSS_CLASS), $pre);
         }
         return $status;
     }
     $options = array('cssclass' => self::HIGHLIGHT_CSS_CLASS, 'encoding' => 'utf-8');
     // Line numbers
     if (isset($args['line'])) {
         $options['linenos'] = 'inline';
     }
     if ($lexer === 'php' && strpos($code, '<?php') === false) {
         $options['startinline'] = 1;
     }
     // Highlight specific lines
     if (isset($args['highlight'])) {
         $lines = self::parseHighlightLines($args['highlight']);
         if (count($lines)) {
             $options['hl_lines'] = implode(' ', $lines);
         }
     }
     // Starting line number
     if (isset($args['start'])) {
         $options['linenostart'] = $args['start'];
     }
     if ($inline) {
         $options['nowrap'] = 1;
     }
     $cache = wfGetMainCache();
     $cacheKey = self::makeCacheKey($code, $lexer, $options);
     $output = $cache->get($cacheKey);
     if ($output === false) {
         $optionPairs = array();
         foreach ($options as $k => $v) {
             $optionPairs[] = "{$k}={$v}";
         }
         $builder = new ProcessBuilder();
         $builder->setPrefix($wgPygmentizePath);
         $process = $builder->add('-l')->add($lexer)->add('-f')->add('html')->add('-O')->add(implode(',', $optionPairs))->getProcess();
         $process->setInput($code);
         $process->run();
         if (!$process->isSuccessful()) {
             $status->warning('syntaxhighlight-error-pygments-invocation-failure');
             wfWarn('Failed to invoke Pygments: ' . $process->getErrorOutput());
             $status->value = self::highlight($code, null, $args)->getValue();
             return $status;
         }
         $output = $process->getOutput();
         $cache->set($cacheKey, $output);
     }
     if ($inline) {
         $output = trim($output);
     }
     $status->value = $output;
     return $status;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:93,代码来源:SyntaxHighlight_GeSHi.class.php


示例19: __construct

	/**
	 * @params include:
	 *  - sectionsByWiki      : A map of wiki IDs to section names.
	 *                          Wikis will default to using the section "default".
	 *  - partitionsBySection : Map of section names to maps of (partition name => weight).
	 *                          A section called 'default' must be defined if not all wikis
	 *                          have explicitly defined sections.
	 *  - configByPartition   : Map of queue partition names to configuration arrays.
	 *                          These configuration arrays are passed to JobQueue::factory().
	 *                          The options set here are overriden by those passed to this
	 *                          the federated queue itself (e.g. 'order' and 'claimTTL').
	 *  - partitionsNoPush    : List of partition names that can handle pop() but not push().
	 *                          This can be used to migrate away from a certain partition.
	 * @param array $params
	 */
	protected function __construct( array $params ) {
		parent::__construct( $params );
		$section = isset( $params['sectionsByWiki'][$this->wiki] )
			? $params['sectionsByWiki'][$this->wiki]
			: 'default';
		if ( !isset( $params['partitionsBySection'][$section] ) ) {
			throw new MWException( "No configuration for section '$section'." );
		}
		// Get the full partition map
		$this->partitionMap = $params['partitionsBySection'][$section];
		arsort( $this->partitionMap, SORT_NUMERIC );
		// Get the partitions jobs can actually be pushed to
		$partitionPushMap = $this->partitionMap;
		if ( isset( $params['partitionsNoPush'] ) ) {
			foreach ( $params['partitionsNoPush'] as $partition ) {
				unset( $partitionPushMap[$partition] );
			}
		}
		// Get the config to pass to merge into each partition queue config
		$baseConfig = $params;
		foreach ( array( 'class', 'sectionsByWiki',
			'partitionsBySection', 'configByPartition', 'partitionsNoPush' ) as $o )
		{
			unset( $baseConfig[$o] );
		}
		// Get the partition queue objects
		foreach ( $this->partitionMap as $partition => $w ) {
			if ( !isset( $params['configByPartition'][$partition] ) ) {
				throw new MWException( "No configuration for partition '$partition'." );
			}
			$this->partitionQueues[$partition] = JobQueue::factory(
				$baseConfig + $params['configByPartition'][$partition] );
		}
		// Get the ring of partitions to push jobs into
		$this->partitionPushRing = new HashRing( $partitionPushMap );
		// Aggregate cache some per-queue values if there are multiple partition queues
		$this->cache = count( $this->partitionMap ) > 1 ? wfGetMainCache() : new EmptyBagOStuff();
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:53,代码来源:JobQueueFederated.php


示例20: execute

 /**
  * execute
  *
  * entry point for TaskExecutor
  *
  * @access public
  * @author eloy@wikia
  *
  * @param mixed $params default null - task data from wikia_tasks table
  *
  * @return boolean - status of operation
  */
 public function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgExtensionMessagesFiles;
     $this->mTaskID = $params->task_id;
     $this->mParams = unserialize($params->task_arguments);
     $city_id = $this->mParams["city_id"];
     $command = $this->mParams["command"];
     $type = $this->mParams["type"];
     $server = $this->mParams["server"];
     $this->addLog("wgServer for this site is: {$server}");
     if ($city_id && $command) {
         $this->mWikiId = $city_id;
         /**
          * execute maintenance script
          */
         $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/{$command} --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
         $this->addLog("Running {$cmd}");
         $retval = wfShellExec($cmd, $status);
         $this->addLog($retval);
         if ($type == "ACWLocal" || $type == "CWLocal") {
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/initStats.php --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
             $this->addLog("Running {$cmd}");
             $retval = wfShellExec($cmd, $status);
             $this->addLog($retval);
             $this->addLog("Remove edit lock");
             $oVariable = WikiFactory::getVarByName('wgReadOnly', $city_id);
             if (isset($oVariable->cv_variable_id)) {
                 WikiFactory::removeVarById($oVariable->cv_variable_id, $city_id);
                 WikiFactory::clearCache($city_id);
             }
         }
         $dbname = WikiFactory::IDtoDB($city_id);
         $cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} ");
         $this->addLog("Running {$cmd}");
         $retval = wfShellExec($cmd, $status);
         $this->addLog($retval);
         /**
          * once again clear cache at the very end
          */
         $wgMemc = wfGetMainCache();
         $wgMemc->delete(WikiFactory::getVarsKey($city_id));
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:64,代码来源:LocalMaintenanceTask.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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