<?php
-
/**
+ * @defgroup Parser Parser
*
+ * @file
+ * @ingroup Parser
* File for Parser and related classes
- *
- * @addtogroup Parser
*/
* * only within ParserOptions
* </pre>
*
- * @addtogroup Parser
+ * @ingroup Parser
*/
class Parser
{
}
global $wgExpensiveParserFunctionLimit;
if ( $this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit ) {
- if ( is_callable( array( $this->mOutput, 'addWarning' ) ) ) {
- $warning = wfMsg( 'expensive-parserfunction-warning', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
- $this->mOutput->addWarning( $warning );
- $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( 'expensive-parserfunction-category' ) );
- if ( $cat ) {
- $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
- }
- }
+ $this->limitationWarn( 'expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
}
wfRunHooks( 'ParserAfterTidy', array( &$this, &$text ) );
function &getTitle() { return $this->mTitle; }
function getOptions() { return $this->mOptions; }
+ function getRevisionId() { return $this->mRevisionId; }
function getFunctionLang() {
global $wgLang, $wgContLang;
*/
function areSubpagesAllowed() {
# Some namespaces don't allow subpages
- global $wgNamespacesWithSubpages;
- return !empty($wgNamespacesWithSubpages[$this->mTitle->getNamespace()]);
+ return MWNamespace::hasSubpages( $this->mTitle->getNamespace() );
}
/**
return $assocArgs;
}
+ /**
+ * Warn the user when a parser limitation is reached
+ * Will warn at most once the user per limitation type
+ *
+ * @param string $limitationType, should be one of:
+ * 'expensive-parserfunction' (corresponding messages: 'expensive-parserfunction-warning', 'expensive-parserfunction-category')
+ * 'post-expand-template-argument' (corresponding messages: 'post-expand-template-argument-warning', 'post-expand-template-argument-category')
+ * 'post-expand-template-inclusion' (corresponding messages: 'post-expand-template-inclusion-warning', 'post-expand-template-inclusion-category')
+ * @params int $current, $max When an explicit limit has been
+ * exceeded, provide the values (optional)
+ */
+ function limitationWarn( $limitationType, $current=null, $max=null) {
+ $msgName = $limitationType . '-warning';
+ //does no harm if $current and $max are present but are unnecessary for the message
+ $warning = wfMsg( $msgName, $current, $max);
+ $this->mOutput->addWarning( $warning );
+ $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $limitationType . '-category' ) );
+ if ( $cat ) {
+ $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
+ }
+ }
+
/**
* Return the text of a template, after recursively
* replacing any variables or templates within the template.
# Error, oversize inclusion
$text = "[[$originalTitle]]" .
$this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
+ $this->limitationWarn( 'post-expand-template-inclusion' );
}
if ( $isLocalObj ) {
}
$rev = $id ? Revision::newFromId( $id ) : Revision::newFromTitle( $title );
$rev_id = $rev ? $rev->getId() : 0;
+ // If there is no current revision, there is no page
+ if( $id === false && !$rev ) {
+ $linkCache = LinkCache::singleton();
+ $linkCache->addBadLinkObj( $title );
+ }
$deps[] = array(
'title' => $title,
}
if ( !$this->incrementIncludeSize( 'arg', strlen( $text ) ) ) {
$error = '<!-- WARNING: argument omitted, expansion size too large -->';
+ $this->limitationWarn( 'post-expand-template-argument' );
}
if ( $text === false && $object === false ) {
if ( count( $matches ) == 0 ) {
continue;
}
+
+ if ( strpos( $matches[0], '%' ) !== false )
+ $matches[1] = urldecode( $matches[1] );
$tp = Title::newFromText( $matches[1] );
$nt =& $tp;
if( is_null( $nt ) ) {
$sk = $this->mOptions->getSkin();
# Give extensions a chance to select the file revision for us
- $skip = $time = false;
- wfRunHooks( 'BeforeParserMakeImageLinkObj', array( &$this, &$title, &$skip, &$time ) );
+ $skip = $time = $descQuery = false;
+ wfRunHooks( 'BeforeParserMakeImageLinkObj', array( &$this, &$title, &$skip, &$time, &$descQuery ) );
if ( $skip ) {
return $sk->makeLinkObj( $title );
wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
# Linker does the rest
- $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time );
+ $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery );
# Give the handler a chance to modify the parser object
if ( $handler ) {
/**
* @todo document, briefly.
- * @addtogroup Parser
+ * @ingroup Parser
*/
class StripState {
var $general, $nowiki;
/**
* @todo document, briefly.
- * @addtogroup Parser
+ * @ingroup Parser
*/
class OnlyIncludeReplacer {
var $output = '';