*/
public $mUsedOptions;
- public $mVersion = Parser::VERSION, # Compatibility check
- $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
- $mCacheExpiry = null, # Seconds after which the object should expire, use 0 for uncacheable. Used in ParserCache.
- $mCacheRevisionId = null; # Revision ID that was parsed
+ # Compatibility check
+ public $mVersion = Parser::VERSION;
+
+ # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
+ public $mCacheTime = '';
+
+ # Seconds after which the object should expire, use 0 for uncacheable. Used in ParserCache.
+ public $mCacheExpiry = null;
+
+ # Revision ID that was parsed
+ public $mCacheRevisionId = null;
/**
* @return string TS_MW timestamp
$parser->setFunctionHook( $func, array( __CLASS__, $func ), Parser::SFH_NO_HASH );
}
- $parser->setFunctionHook( 'namespace', array( __CLASS__, 'mwnamespace' ), Parser::SFH_NO_HASH );
+ $parser->setFunctionHook(
+ 'namespace',
+ array( __CLASS__, 'mwnamespace' ),
+ Parser::SFH_NO_HASH
+ );
$parser->setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), Parser::SFH_NO_HASH );
$parser->setFunctionHook( 'special', array( __CLASS__, 'special' ) );
$parser->setFunctionHook( 'speciale', array( __CLASS__, 'speciale' ) );
$parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
if ( $wgAllowDisplayTitle ) {
- $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), Parser::SFH_NO_HASH );
+ $parser->setFunctionHook(
+ 'displaytitle',
+ array( __CLASS__, 'displaytitle' ),
+ Parser::SFH_NO_HASH
+ );
}
if ( $wgAllowSlowParserFunctions ) {
$parser->setFunctionHook(
* @param int $direction
* @return string
*/
- public static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
+ public static function pad(
+ $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
+ ) {
$padding = $parser->killMarkers( $padding );
$lengthOfPadding = mb_strlen( $padding );
if ( $lengthOfPadding == 0 ) {
}
$limitReport .= 'Cached time: ' . $this->mOutput->getCacheTime() . "\n";
$limitReport .= 'Cache expiry: ' . $this->mOutput->getCacheExpiry() . "\n";
- $limitReport .= 'Dynamic content: ' . ( $this->mOutput->hasDynamicContent() ? 'true' : 'false' ) . "\n";
+ $limitReport .= 'Dynamic content: ' .
+ ( $this->mOutput->hasDynamicContent() ? 'true' : 'false' ) .
+ "\n";
+
foreach ( $this->mOutput->getLimitReportData() as $key => $value ) {
if ( Hooks::run( 'ParserLimitReportFormat',
array( $key, &$value, &$limitReport, false, false )
* @private
*/
public function makeFreeExternalLink( $url, $numPostProto ) {
-
$trail = '';
# The characters '<' and '>' (which were escaped by
# URLs, per RFC 2396.
# Make terminate a URL as well (bug T84937)
$m2 = array();
- if ( preg_match( '/&(lt|gt|nbsp|#x0*(3[CcEe]|[Aa]0)|#0*(60|62|160));/', $url, $m2, PREG_OFFSET_CAPTURE ) ) {
+ if ( preg_match(
+ '/&(lt|gt|nbsp|#x0*(3[CcEe]|[Aa]0)|#0*(60|62|160));/',
+ $url,
+ $m2,
+ PREG_OFFSET_CAPTURE
+ ) ) {
$trail = substr( $url, $m2[0][1] ) . $trail;
$url = substr( $url, 0, $m2[0][1] );
}
wfIncrStats( "pcache.miss.revid" );
$revId = $article->getLatest();
$cachedRevId = $value->getCacheRevisionId();
- wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" );
+ wfDebug(
+ "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
+ );
$value = false;
- } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false ) {
+ } elseif (
+ Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false
+ ) {
wfIncrStats( 'pcache.miss.rejected' );
- wfDebug( "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" );
+ wfDebug(
+ "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
+ );
$value = false;
} else {
wfIncrStats( "pcache.hit" );
// ...and its pointer
$this->mMemc->set( $this->getOptionsKey( $page ), $optionsKey, $expire );
- Hooks::run( 'ParserCacheSaveComplete', array( $this, $parserOutput, $page->getTitle(), $popts, $revId ) );
+ Hooks::run(
+ 'ParserCacheSaveComplete',
+ array( $this, $parserOutput, $page->getTitle(), $popts, $revId )
+ );
} else {
wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" );
}
}
/**
- * Sets a hook to force that a page exists, and sets a current revision callback to return a
- * revision with custom content when the current revision of the page is requested.
+ * Sets a hook to force that a page exists, and sets a current revision callback to return
+ * a revision with custom content when the current revision of the page is requested.
*
* @since 1.25
* @param Title $title
* @return ScopedCallback to unset the hook
*/
public function setupFakeRevision( $title, $content, $user ) {
- $oldCallback = $this->setCurrentRevisionCallback( function ( $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback ) {
- if ( $titleToCheck->equals( $title ) ) {
- return new Revision( array(
- 'page' => $title->getArticleID(),
- 'user_text' => $user->getName(),
- 'user' => $user->getId(),
- 'parent_id' => $title->getLatestRevId(),
- 'title' => $title,
- 'content' => $content
- ) );
- } else {
- return call_user_func( $oldCallback, $titleToCheck, $parser );
+ $oldCallback = $this->setCurrentRevisionCallback(
+ function (
+ $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback
+ ) {
+ if ( $titleToCheck->equals( $title ) ) {
+ return new Revision( array(
+ 'page' => $title->getArticleID(),
+ 'user_text' => $user->getName(),
+ 'user' => $user->getId(),
+ 'parent_id' => $title->getLatestRevId(),
+ 'title' => $title,
+ 'content' => $content
+ ) );
+ } else {
+ return call_user_func( $oldCallback, $titleToCheck, $parser );
+ }
}
- } );
+ );
+
global $wgHooks;
$wgHooks['TitleExists'][] =
function ( $titleToCheck, &$exists ) use ( $title ) {