当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLFileCache::loadFromFileCache方法代码示例

本文整理汇总了PHP中HTMLFileCache::loadFromFileCache方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLFileCache::loadFromFileCache方法的具体用法?PHP HTMLFileCache::loadFromFileCache怎么用?PHP HTMLFileCache::loadFromFileCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLFileCache的用法示例。


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

示例1: main

 private function main()
 {
     global $wgTitle;
     $output = $this->context->getOutput();
     $request = $this->context->getRequest();
     // Send Ajax requests to the Ajax dispatcher.
     if ($this->config->get('UseAjax') && $request->getVal('action') === 'ajax') {
         // Set a dummy title, because $wgTitle == null might break things
         $title = Title::makeTitle(NS_SPECIAL, 'Badtitle/performing an AJAX call in ' . __METHOD__);
         $this->context->setTitle($title);
         $wgTitle = $title;
         $dispatcher = new AjaxDispatcher($this->config);
         $dispatcher->performAction($this->context->getUser());
         return;
     }
     // Get title from request parameters,
     // is set on the fly by parseTitle the first time.
     $title = $this->getTitle();
     $action = $this->getAction();
     $wgTitle = $title;
     // Set DB query expectations for this HTTP request
     $trxLimits = $this->config->get('TrxProfilerLimits');
     $trxProfiler = Profiler::instance()->getTransactionProfiler();
     $trxProfiler->setLogger(LoggerFactory::getInstance('DBPerformance'));
     if ($request->hasSafeMethod()) {
         $trxProfiler->setExpectations($trxLimits['GET'], __METHOD__);
     } else {
         $trxProfiler->setExpectations($trxLimits['POST'], __METHOD__);
     }
     // If the user has forceHTTPS set to true, or if the user
     // is in a group requiring HTTPS, or if they have the HTTPS
     // preference set, redirect them to HTTPS.
     // Note: Do this after $wgTitle is setup, otherwise the hooks run from
     // isLoggedIn() will do all sorts of weird stuff.
     if ($request->getProtocol() == 'http' && preg_match('#^https://#', wfExpandUrl($request->getRequestURL(), PROTO_HTTPS)) && ($request->getSession()->shouldForceHTTPS() || $request->getCookie('forceHTTPS', '') || $request->getCookie('forceHTTPS') || $this->context->getUser()->isLoggedIn() && $this->context->getUser()->requiresHTTPS())) {
         $oldUrl = $request->getFullRequestURL();
         $redirUrl = preg_replace('#^http://#', 'https://', $oldUrl);
         // ATTENTION: This hook is likely to be removed soon due to overall design of the system.
         if (Hooks::run('BeforeHttpsRedirect', [$this->context, &$redirUrl])) {
             if ($request->wasPosted()) {
                 // This is weird and we'd hope it almost never happens. This
                 // means that a POST came in via HTTP and policy requires us
                 // redirecting to HTTPS. It's likely such a request is going
                 // to fail due to post data being lost, but let's try anyway
                 // and just log the instance.
                 // @todo FIXME: See if we could issue a 307 or 308 here, need
                 // to see how clients (automated & browser) behave when we do
                 wfDebugLog('RedirectedPosts', "Redirected from HTTP to HTTPS: {$oldUrl}");
             }
             // Setup dummy Title, otherwise OutputPage::redirect will fail
             $title = Title::newFromText('REDIR', NS_MAIN);
             $this->context->setTitle($title);
             // Since we only do this redir to change proto, always send a vary header
             $output->addVaryHeader('X-Forwarded-Proto');
             $output->redirect($redirUrl);
             $output->output();
             return;
         }
     }
     if ($title->canExist() && HTMLFileCache::useFileCache($this->context)) {
         // Try low-level file cache hit
         $cache = new HTMLFileCache($title, $action);
         if ($cache->isCacheGood()) {
             // Check incoming headers to see if client has this cached
             $timestamp = $cache->cacheTimestamp();
             if (!$output->checkLastModified($timestamp)) {
                 $cache->loadFromFileCache($this->context);
             }
             // Do any stats increment/watchlist stuff, assuming user is viewing the
             // latest revision (which should always be the case for file cache)
             $this->context->getWikiPage()->doViewUpdates($this->context->getUser());
             // Tell OutputPage that output is taken care of
             $output->disable();
             return;
         }
     }
     // Actually do the work of the request and build up any output
     $this->performRequest();
     // GUI-ify and stash the page output in MediaWiki::doPreOutputCommit() while
     // ChronologyProtector synchronizes DB positions or slaves accross all datacenters.
     $buffer = null;
     $outputWork = function () use($output, &$buffer) {
         if ($buffer === null) {
             $buffer = $output->output(true);
         }
         return $buffer;
     };
     // Now commit any transactions, so that unreported errors after
     // output() don't roll back the whole DB transaction and so that
     // we avoid having both success and error text in the response
     $this->doPreOutputCommit($outputWork);
     // Now send the actual output
     print $outputWork();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:94,代码来源:MediaWiki.php

示例2: tryFileCache

 /**
  * checkLastModified returns true if it has taken care of all
  * output to the client that is necessary for this request.
  * (that is, it has sent a cached version of the page)
  *
  * @return bool True if cached version send, false otherwise
  */
 protected function tryFileCache()
 {
     static $called = false;
     if ($called) {
         wfDebug("Article::tryFileCache(): called twice!?\n");
         return false;
     }
     $called = true;
     if ($this->isFileCacheable()) {
         $cache = new HTMLFileCache($this->getTitle(), 'view');
         if ($cache->isCacheGood($this->mPage->getTouched())) {
             wfDebug("Article::tryFileCache(): about to load file\n");
             $cache->loadFromFileCache($this->getContext());
             return true;
         } else {
             wfDebug("Article::tryFileCache(): starting buffer\n");
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     } else {
         wfDebug("Article::tryFileCache(): not cacheable\n");
     }
     return false;
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:30,代码来源:Article.php

示例3: AjaxDispatcher

    $dispatcher = new AjaxDispatcher();
    $dispatcher->performAction();
    $mediaWiki->restInPeace();
    exit;
}
if ($wgUseFileCache && isset($wgTitle)) {
    wfProfileIn('main-try-filecache');
    // Raw pages should handle cache control on their own,
    // even when using file cache. This reduces hits from clients.
    if ($action != 'raw' && HTMLFileCache::useFileCache()) {
        /* Try low-level file cache hit */
        $cache = new HTMLFileCache($wgTitle, $action);
        if ($cache->isFileCacheGood()) {
            /* Check incoming headers to see if client has this cached */
            if (!$wgOut->checkLastModified($cache->fileCacheTime())) {
                $cache->loadFromFileCache();
            }
            # Do any stats increment/watchlist stuff
            $wgArticle = MediaWiki::articleFromTitle($wgTitle);
            $wgArticle->viewUpdates();
            # Tell $wgOut that output is taken care of
            wfProfileOut('main-try-filecache');
            $mediaWiki->restInPeace();
            exit;
        }
    }
    wfProfileOut('main-try-filecache');
}
# Setting global variables in mediaWiki
$mediaWiki->setVal('action', $action);
$mediaWiki->setVal('DisabledActions', $wgDisabledActions);
开发者ID:GodelDesign,项目名称:Godel,代码行数:31,代码来源:index.php

示例4: tryFileCache

 /**
  * checkLastModified returns true if it has taken care of all
  * output to the client that is necessary for this request.
  * (that is, it has sent a cached version of the page)
  */
 function tryFileCache()
 {
     static $called = false;
     if ($called) {
         wfDebug("Article::tryFileCache(): called twice!?\n");
         return;
     }
     $called = true;
     if ($this->isFileCacheable()) {
         $touched = $this->mTouched;
         $cache = new HTMLFileCache($this->mTitle);
         if ($cache->isFileCacheGood($touched)) {
             wfDebug("Article::tryFileCache(): about to load file\n");
             $cache->loadFromFileCache();
             return true;
         } else {
             wfDebug("Article::tryFileCache(): starting buffer\n");
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     } else {
         wfDebug("Article::tryFileCache(): not cacheable\n");
     }
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:28,代码来源:Article.php

示例5: view

 function view()
 {
     global $wgOut, $wgScript;
     if (isset($_SERVER['SCRIPT_URL'])) {
         # Normally we use PHP_SELF to get the URL to the script
         # as it was called, minus the query string.
         #
         # Some sites use Apache rewrite rules to handle subdomains,
         # and have PHP set up in a weird way that causes PHP_SELF
         # to contain the rewritten URL instead of the one that the
         # outside world sees.
         #
         # If in this mode, use SCRIPT_URL instead, which mod_rewrite
         # provides containing the "before" URL.
         $url = $_SERVER['SCRIPT_URL'];
     } else {
         $url = $_SERVER['PHP_SELF'];
     }
     if (strcmp($wgScript, $url)) {
         # Internet Explorer will ignore the Content-Type header if it
         # thinks it sees a file extension it recognizes. Make sure that
         # all raw requests are done through the script node, which will
         # have eg '.php' and should remain safe.
         #
         # We used to redirect to a canonical-form URL as a general
         # backwards-compatibility / good-citizen nice thing. However
         # a lot of servers are set up in buggy ways, resulting in
         # redirect loops which hang the browser until the CSS load
         # times out.
         #
         # Just return a 403 Forbidden and get it over with.
         wfHttpError(403, 'Forbidden', 'Raw pages must be accessed through the primary script entry point.');
         return;
     }
     header("Content-type: " . $this->mContentType . '; charset=' . $this->mCharset);
     # allow the client to cache this for 24 hours
     $mode = $this->mPrivateCache ? 'private' : 'public';
     header('Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage);
     if (HTMLFileCache::useFileCache()) {
         $cache = new HTMLFileCache($this->mTitle, 'raw');
         if ($cache->isFileCacheGood()) {
             $cache->loadFromFileCache();
             $wgOut->disable();
             return;
         } else {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     $text = $this->getRawText();
     if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
         wfDebug(__METHOD__ . ': RawPageViewBeforeOutput hook broke raw page output.');
     }
     echo $text;
     $wgOut->disable();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:55,代码来源:RawPage.php

示例6: view

 function view()
 {
     global $wgOut, $wgScript, $wgRequest;
     if ($wgRequest->isPathInfoBad()) {
         # Internet Explorer will ignore the Content-Type header if it
         # thinks it sees a file extension it recognizes. Make sure that
         # all raw requests are done through the script node, which will
         # have eg '.php' and should remain safe.
         #
         # We used to redirect to a canonical-form URL as a general
         # backwards-compatibility / good-citizen nice thing. However
         # a lot of servers are set up in buggy ways, resulting in
         # redirect loops which hang the browser until the CSS load
         # times out.
         #
         # Just return a 403 Forbidden and get it over with.
         wfHttpError(403, 'Forbidden', 'Invalid file extension found in PATH_INFO or QUERY_STRING. ' . 'Raw pages must be accessed through the primary script entry point.');
         return;
     }
     header("Content-type: " . $this->mContentType . '; charset=' . $this->mCharset);
     # allow the client to cache this for 24 hours
     $mode = $this->mPrivateCache ? 'private' : 'public';
     header('Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage);
     global $wgUseFileCache;
     if ($wgUseFileCache and HTMLFileCache::useFileCache()) {
         $cache = new HTMLFileCache($this->mTitle, 'raw');
         if ($cache->isFileCacheGood()) {
             $cache->loadFromFileCache();
             $wgOut->disable();
             return;
         } else {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     $text = $this->getRawText();
     if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
         wfDebug(__METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n");
     }
     echo $text;
     $wgOut->disable();
 }
开发者ID:rocLv,项目名称:conference,代码行数:41,代码来源:RawPage.php

示例7: view

 function view()
 {
     global $wgOut, $wgRequest;
     if (!$wgRequest->checkUrlExtension()) {
         $wgOut->disable();
         return;
     }
     header('Content-type: ' . $this->mContentType . '; charset=' . $this->mCharset);
     # allow the client to cache this for 24 hours
     $mode = $this->mPrivateCache ? 'private' : 'public';
     header('Cache-Control: ' . $mode . ', s-maxage=' . $this->mSmaxage . ', max-age=' . $this->mMaxage);
     global $wgUseFileCache;
     if ($wgUseFileCache && HTMLFileCache::useFileCache()) {
         $cache = new HTMLFileCache($this->mTitle, 'raw');
         if ($cache->isFileCacheGood()) {
             $cache->loadFromFileCache();
             $wgOut->disable();
             return;
         } else {
             ob_start(array(&$cache, 'saveToFileCache'));
         }
     }
     $text = $this->getRawText();
     if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
         wfDebug(__METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n");
     }
     echo $text;
     $wgOut->disable();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:29,代码来源:RawPage.php

示例8: main

 private function main()
 {
     global $wgUseFileCache, $wgTitle, $wgUseAjax;
     wfProfileIn(__METHOD__);
     # Set title from request parameters
     $wgTitle = $this->getTitle();
     $action = $this->getAction();
     $user = $this->context->getUser();
     # Send Ajax requests to the Ajax dispatcher.
     if ($wgUseAjax && $action == 'ajax') {
         $dispatcher = new AjaxDispatcher();
         $dispatcher->performAction();
         wfProfileOut(__METHOD__);
         return;
     }
     if ($wgUseFileCache && $wgTitle->getNamespace() != NS_SPECIAL) {
         wfProfileIn('main-try-filecache');
         // Raw pages should handle cache control on their own,
         // even when using file cache. This reduces hits from clients.
         if (HTMLFileCache::useFileCache()) {
             /* Try low-level file cache hit */
             $cache = new HTMLFileCache($wgTitle, $action);
             if ($cache->isFileCacheGood()) {
                 /* Check incoming headers to see if client has this cached */
                 $timestamp = $cache->fileCacheTime();
                 if (!$this->context->getOutput()->checkLastModified($timestamp)) {
                     $cache->loadFromFileCache();
                 }
                 # Do any stats increment/watchlist stuff
                 $article = WikiPage::factory($wgTitle);
                 $article->doViewUpdates($user);
                 # Tell OutputPage that output is taken care of
                 $this->context->getOutput()->disable();
                 wfProfileOut('main-try-filecache');
                 wfProfileOut(__METHOD__);
                 return;
             }
         }
         wfProfileOut('main-try-filecache');
     }
     $this->performRequest();
     $this->finalCleanup();
     wfProfileOut(__METHOD__);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:44,代码来源:Wiki.php

示例9: main

 private function main()
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $request = $this->context->getRequest();
     // Send Ajax requests to the Ajax dispatcher.
     if ($this->config->get('UseAjax') && $request->getVal('action', 'view') == 'ajax') {
         // Set a dummy title, because $wgTitle == null might break things
         $title = Title::makeTitle(NS_MAIN, 'AJAX');
         $this->context->setTitle($title);
         $wgTitle = $title;
         $dispatcher = new AjaxDispatcher($this->config);
         $dispatcher->performAction($this->context->getUser());
         wfProfileOut(__METHOD__);
         return;
     }
     // Get title from request parameters,
     // is set on the fly by parseTitle the first time.
     $title = $this->getTitle();
     $action = $this->getAction();
     $wgTitle = $title;
     // If the user has forceHTTPS set to true, or if the user
     // is in a group requiring HTTPS, or if they have the HTTPS
     // preference set, redirect them to HTTPS.
     // Note: Do this after $wgTitle is setup, otherwise the hooks run from
     // isLoggedIn() will do all sorts of weird stuff.
     if ($request->getProtocol() == 'http' && ($request->getCookie('forceHTTPS', '') || $request->getCookie('forceHTTPS') || $this->context->getUser()->isLoggedIn() && $this->context->getUser()->requiresHTTPS())) {
         $oldUrl = $request->getFullRequestURL();
         $redirUrl = preg_replace('#^http://#', 'https://', $oldUrl);
         // ATTENTION: This hook is likely to be removed soon due to overall design of the system.
         if (wfRunHooks('BeforeHttpsRedirect', array($this->context, &$redirUrl))) {
             if ($request->wasPosted()) {
                 // This is weird and we'd hope it almost never happens. This
                 // means that a POST came in via HTTP and policy requires us
                 // redirecting to HTTPS. It's likely such a request is going
                 // to fail due to post data being lost, but let's try anyway
                 // and just log the instance.
                 //
                 // @todo FIXME: See if we could issue a 307 or 308 here, need
                 // to see how clients (automated & browser) behave when we do
                 wfDebugLog('RedirectedPosts', "Redirected from HTTP to HTTPS: {$oldUrl}");
             }
             // Setup dummy Title, otherwise OutputPage::redirect will fail
             $title = Title::newFromText(NS_MAIN, 'REDIR');
             $this->context->setTitle($title);
             $output = $this->context->getOutput();
             // Since we only do this redir to change proto, always send a vary header
             $output->addVaryHeader('X-Forwarded-Proto');
             $output->redirect($redirUrl);
             $output->output();
             wfProfileOut(__METHOD__);
             return;
         }
     }
     if ($this->config->get('UseFileCache') && $title->getNamespace() >= 0) {
         wfProfileIn('main-try-filecache');
         if (HTMLFileCache::useFileCache($this->context)) {
             // Try low-level file cache hit
             $cache = new HTMLFileCache($title, $action);
             if ($cache->isCacheGood()) {
                 // Check incoming headers to see if client has this cached
                 $timestamp = $cache->cacheTimestamp();
                 if (!$this->context->getOutput()->checkLastModified($timestamp)) {
                     $cache->loadFromFileCache($this->context);
                 }
                 // Do any stats increment/watchlist stuff
                 // Assume we're viewing the latest revision (this should always be the case with file cache)
                 $this->context->getWikiPage()->doViewUpdates($this->context->getUser());
                 // Tell OutputPage that output is taken care of
                 $this->context->getOutput()->disable();
                 wfProfileOut('main-try-filecache');
                 wfProfileOut(__METHOD__);
                 return;
             }
         }
         wfProfileOut('main-try-filecache');
     }
     // Actually do the work of the request and build up any output
     $this->performRequest();
     // Either all DB and deferred updates should happen or none.
     // The later should not be cancelled due to client disconnect.
     ignore_user_abort(true);
     // Now commit any transactions, so that unreported errors after
     // output() don't roll back the whole DB transaction
     wfGetLBFactory()->commitMasterChanges();
     // Output everything!
     $this->context->getOutput()->output();
     wfProfileOut(__METHOD__);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:89,代码来源:MediaWiki.php


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