From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/parser/Preprocessor_Hash.php | 76 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'includes/parser/Preprocessor_Hash.php') diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 4f04c865..fad1adbb 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -89,7 +89,7 @@ class Preprocessor_Hash implements Preprocessor { * Preprocess some wikitext and return the document tree. * This is the ghost of Parser::replace_variables(). * - * @param $text String: the text to parse + * @param string $text the text to parse * @param $flags Integer: bitwise combination of: * Parser::PTD_FOR_INCLUSION Handle "" and "" as if the text is being * included. Default is to assume a direct page view. @@ -105,6 +105,7 @@ class Preprocessor_Hash implements Preprocessor { * cache may be implemented at a later date which takes further advantage of these strict * dependency requirements. * + * @throws MWException * @return PPNode_Hash_Tree */ function preprocessToObj( $text, $flags = 0 ) { @@ -115,9 +116,9 @@ class Preprocessor_Hash implements Preprocessor { $cacheable = $wgPreprocessorCacheThreshold !== false && strlen( $text ) > $wgPreprocessorCacheThreshold; if ( $cacheable ) { - wfProfileIn( __METHOD__.'-cacheable' ); + wfProfileIn( __METHOD__ . '-cacheable' ); - $cacheKey = wfMemcKey( 'preprocess-hash', md5($text), $flags ); + $cacheKey = wfMemcKey( 'preprocess-hash', md5( $text ), $flags ); $cacheValue = $wgMemc->get( $cacheKey ); if ( $cacheValue ) { $version = substr( $cacheValue, 0, 8 ); @@ -126,12 +127,12 @@ class Preprocessor_Hash implements Preprocessor { // From the cache wfDebugLog( "Preprocessor", "Loaded preprocessor hash from memcached (key $cacheKey)" ); - wfProfileOut( __METHOD__.'-cacheable' ); + wfProfileOut( __METHOD__ . '-cacheable' ); wfProfileOut( __METHOD__ ); return $hash; } } - wfProfileIn( __METHOD__.'-cache-miss' ); + wfProfileIn( __METHOD__ . '-cache-miss' ); } $rules = array( @@ -331,7 +332,7 @@ class Preprocessor_Hash implements Preprocessor { if ( $stack->top ) { $part = $stack->top->getCurrentPart(); - if ( ! (isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) { + if ( !(isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) { $part->visualEnd = $wsStart; } // Else comments abutting, no change in visual end @@ -390,7 +391,7 @@ class Preprocessor_Hash implements Preprocessor { } // and just become tags if ( in_array( $lowerName, $ignoredElements ) ) { - $accum->addNodeWithText( 'ignore', substr( $text, $tagStartPos, $i - $tagStartPos ) ); + $accum->addNodeWithText( 'ignore', substr( $text, $tagStartPos, $i - $tagStartPos ) ); continue; } @@ -461,7 +462,7 @@ class Preprocessor_Hash implements Preprocessor { if ( $equalsLength > 0 ) { if ( $searchStart - $equalsLength == $piece->startPos ) { // This is just a single string of equals signs on its own line - // Replicate the doHeadings behaviour /={count}(.+)={count}/ + // Replicate the doHeadings behavior /={count}(.+)={count}/ // First find out how many equals signs there really are (don't stop at 6) $count = $equalsLength; if ( $count < 3 ) { @@ -548,7 +549,7 @@ class Preprocessor_Hash implements Preprocessor { } } - if ($matchingCount <= 0) { + if ( $matchingCount <= 0 ) { # No matching element found in callback array # Output a literal closing brace and continue $accum->addLiteral( str_repeat( $curChar, $count ) ); @@ -590,10 +591,10 @@ class Preprocessor_Hash implements Preprocessor { $lastNode = $node; } if ( !$node ) { - throw new MWException( __METHOD__. ': eqpos not found' ); + throw new MWException( __METHOD__ . ': eqpos not found' ); } if ( $node->name !== 'equals' ) { - throw new MWException( __METHOD__ .': eqpos is not equals' ); + throw new MWException( __METHOD__ . ': eqpos is not equals' ); } $equalsNode = $node; @@ -638,23 +639,17 @@ class Preprocessor_Hash implements Preprocessor { $accum =& $stack->getAccum(); # Re-add the old stack element if it still has unmatched opening characters remaining - if ($matchingCount < $piece->count) { + if ( $matchingCount < $piece->count ) { $piece->parts = array( new PPDPart_Hash ); $piece->count -= $matchingCount; # do we still qualify for any callback with remaining count? - $names = $rules[$piece->open]['names']; - $skippedBraces = 0; - $enclosingAccum =& $accum; - while ( $piece->count ) { - if ( array_key_exists( $piece->count, $names ) ) { - $stack->push( $piece ); - $accum =& $stack->getAccum(); - break; - } - --$piece->count; - $skippedBraces ++; + $min = $rules[$piece->open]['min']; + if ( $piece->count >= $min ) { + $stack->push( $piece ); + $accum =& $stack->getAccum(); + } else { + $accum->addLiteral( str_repeat( $piece->open, $piece->count ) ); } - $enclosingAccum->addLiteral( str_repeat( $piece->open, $skippedBraces ) ); } extract( $stack->getFlags() ); @@ -695,11 +690,11 @@ class Preprocessor_Hash implements Preprocessor { $rootNode->lastChild = $stack->rootAccum->lastNode; // Cache - if ($cacheable) { + if ( $cacheable ) { $cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . serialize( $rootNode ); $wgMemc->set( $cacheKey, $cacheValue, 86400 ); - wfProfileOut( __METHOD__.'-cache-miss' ); - wfProfileOut( __METHOD__.'-cacheable' ); + wfProfileOut( __METHOD__ . '-cache-miss' ); + wfProfileOut( __METHOD__ . '-cacheable' ); wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" ); } @@ -866,7 +861,6 @@ class PPFrame_Hash implements PPFrame { */ var $depth; - /** * Construct a new preprocessor frame. * @param $preprocessor Preprocessor: the parent preprocessor @@ -884,9 +878,11 @@ class PPFrame_Hash implements PPFrame { * Create a new child frame * $args is optionally a multi-root PPNode or array containing the template arguments * - * @param $args PPNode_Hash_Array|array + * @param array|bool|\PPNode_Hash_Array $args PPNode_Hash_Array|array * @param $title Title|bool * + * @param int $indexOffset + * @throws MWException * @return PPTemplateFrame_Hash */ function newChild( $args = false, $title = false, $indexOffset = 0 ) { @@ -1035,7 +1031,7 @@ class PPFrame_Hash implements PPFrame { } # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result # Not in RECOVER_COMMENTS mode (extractSections) though - elseif ( $this->parser->ot['wiki'] && ! ( $flags & PPFrame::RECOVER_COMMENTS ) ) { + elseif ( $this->parser->ot['wiki'] && !( $flags & PPFrame::RECOVER_COMMENTS ) ) { $out .= $this->parser->insertStripItem( $contextNode->firstChild->value ); } # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove @@ -1082,7 +1078,7 @@ class PPFrame_Hash implements PPFrame { $newIterator = $contextNode->getChildren(); } } else { - throw new MWException( __METHOD__.': Invalid parameter type' ); + throw new MWException( __METHOD__ . ': Invalid parameter type' ); } if ( $newIterator !== false ) { @@ -1371,9 +1367,9 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { function getArguments() { $arguments = array(); foreach ( array_merge( - array_keys($this->numberedArgs), - array_keys($this->namedArgs)) as $key ) { - $arguments[$key] = $this->getArgument($key); + array_keys( $this->numberedArgs ), + array_keys( $this->namedArgs ) ) as $key ) { + $arguments[$key] = $this->getArgument( $key ); } return $arguments; } @@ -1383,8 +1379,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { */ function getNumberedArguments() { $arguments = array(); - foreach ( array_keys($this->numberedArgs) as $key ) { - $arguments[$key] = $this->getArgument($key); + foreach ( array_keys( $this->numberedArgs ) as $key ) { + $arguments[$key] = $this->getArgument( $key ); } return $arguments; } @@ -1394,8 +1390,8 @@ class PPTemplateFrame_Hash extends PPFrame_Hash { */ function getNamedArguments() { $arguments = array(); - foreach ( array_keys($this->namedArgs) as $key ) { - $arguments[$key] = $this->getArgument($key); + foreach ( array_keys( $this->namedArgs ) as $key ) { + $arguments[$key] = $this->getArgument( $key ); } return $arguments; } @@ -1609,6 +1605,7 @@ class PPNode_Hash_Tree implements PPNode { * - index String index * - value PPNode value * + * @throws MWException * @return array */ function splitArg() { @@ -1642,6 +1639,7 @@ class PPNode_Hash_Tree implements PPNode { * Split an "" node into an associative array containing name, attr, inner and close * All values in the resulting array are PPNodes. Inner and close are optional. * + * @throws MWException * @return array */ function splitExt() { @@ -1669,6 +1667,7 @@ class PPNode_Hash_Tree implements PPNode { /** * Split an "" node * + * @throws MWException * @return array */ function splitHeading() { @@ -1695,6 +1694,7 @@ class PPNode_Hash_Tree implements PPNode { /** * Split a "