本文整理汇总了PHP中HTMLFileCache::isCached方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLFileCache::isCached方法的具体用法?PHP HTMLFileCache::isCached怎么用?PHP HTMLFileCache::isCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLFileCache
的用法示例。
在下文中一共展示了HTMLFileCache::isCached方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fileCachedPage
/**
* @return string
*/
private function fileCachedPage()
{
$context = RequestContext::getMain();
if ($context->getOutput()->isDisabled()) {
// Done already?
return '';
}
if ($context->getTitle()) {
// Use the main context's title if we managed to set it
$t = $context->getTitle()->getPrefixedDBkey();
} else {
// Fallback to the raw title URL param. We can't use the Title
// class is it may hit the interwiki table and give a DB error.
// We may get a cache miss due to not sanitizing the title though.
$t = str_replace(' ', '_', $context->getRequest()->getVal('title'));
if ($t == '') {
// fallback to main page
$t = Title::newFromText($this->msg('mainpage', 'Main Page'))->getPrefixedDBkey();
}
}
$cache = new HTMLFileCache($t, 'view');
if ($cache->isCached()) {
return $cache->fetchText();
} else {
return '';
}
}
示例2: run
/**
* Run the current MediaWiki instance; index.php just calls this
*/
public function run()
{
try {
$this->setDBProfilingAgent();
try {
$this->main();
} catch (ErrorPageError $e) {
// Bug 62091: while exceptions are convenient to bubble up GUI errors,
// they are not internal application faults. As with normal requests, this
// should commit, print the output, do deferred updates, jobs, and profiling.
$this->doPreOutputCommit();
$e->report();
// display the GUI error
}
} catch (Exception $e) {
$context = $this->context;
$action = $context->getRequest()->getVal('action', 'view');
if ($e instanceof DBConnectionError && $context->hasTitle() && $context->getTitle()->canExist() && in_array($action, ['view', 'history'], true) && HTMLFileCache::useFileCache($this->context, HTMLFileCache::MODE_OUTAGE)) {
// Try to use any (even stale) file during outages...
$cache = new HTMLFileCache($context->getTitle(), 'view');
if ($cache->isCached()) {
$cache->loadFromFileCache($context, HTMLFileCache::MODE_OUTAGE);
print MWExceptionRenderer::getHTML($e);
exit;
}
}
MWExceptionHandler::handleException($e);
}
$this->doPostOutputShutdown('normal');
}