X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=includes%2Fparser%2FParser.php;h=4a78ff8321dfc2fc60d2cd4faf5c8045de89b38f;hb=6baf2fb802f20af063cb4fe13cd99c9248aae1cb;hp=5256733ee987df16ef710b01c13ec46b45731de0;hpb=613ae1c3f205cbcf71e82982c94a18044bb7881f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5256733ee9..4a78ff8321 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1075,7 +1075,6 @@ class Parser { * @return string */ public function doTableStuff( $text ) { - $lines = StringUtils::explode( "\n", $text ); $out = ''; $td_history = []; # Is currently a td tag open? @@ -1279,7 +1278,6 @@ class Parser { * @return string */ public function internalParse( $text, $isMain = true, $frame = false ) { - $origText = $text; // Avoid PHP 7.1 warning from passing $this by reference @@ -1855,7 +1853,6 @@ class Parser { * @return string */ public function replaceExternalLinks( $text ) { - $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); if ( $bits === false ) { throw new MWException( "PCRE needs to be compiled with " @@ -3031,7 +3028,6 @@ class Parser { * @return string The text of the template */ public function braceSubstitution( $piece, $frame ) { - // Flags // $text has been filled @@ -3378,11 +3374,6 @@ class Parser { list( $callback, $flags ) = $this->mFunctionHooks[$function]; - # Workaround for PHP bug 35229 and similar - if ( !is_callable( $callback ) ) { - throw new MWException( "Tag hook for $function is not callable\n" ); - } - // Avoid PHP 7.1 warning from passing $this by reference $parser = $this; @@ -3791,7 +3782,6 @@ class Parser { * @return array */ public function argSubstitution( $piece, $frame ) { - $error = false; $parts = $piece['parts']; $nameWithSpaces = $frame->expand( $piece['title'] ); @@ -3883,17 +3873,10 @@ class Parser { } if ( isset( $this->mTagHooks[$name] ) ) { - # Workaround for PHP bug 35229 and similar - if ( !is_callable( $this->mTagHooks[$name] ) ) { - throw new MWException( "Tag hook for $name is not callable\n" ); - } $output = call_user_func_array( $this->mTagHooks[$name], [ $content, $attributes, $this, $frame ] ); } elseif ( isset( $this->mFunctionTagHooks[$name] ) ) { list( $callback, ) = $this->mFunctionTagHooks[$name]; - if ( !is_callable( $callback ) ) { - throw new MWException( "Tag hook for $name is not callable\n" ); - } // Avoid PHP 7.1 warning from passing $this by reference $parser = $this; @@ -3979,7 +3962,6 @@ class Parser { * @return string */ public function doDoubleUnderscore( $text ) { - # The position of __TOC__ needs to be recorded $mw = MagicWord::get( 'toc' ); if ( $mw->match( $text ) ) { @@ -4520,12 +4502,16 @@ class Parser { # which may corrupt this parser instance via its wfMessage()->text() call- # Signatures - $sigText = $this->getUserSig( $user ); - $text = strtr( $text, [ - '~~~~~' => $d, - '~~~~' => "$sigText $d", - '~~~' => $sigText - ] ); + if ( strpos( $text, '~~~' ) !== false ) { + $sigText = $this->getUserSig( $user ); + $text = strtr( $text, [ + '~~~~~' => $d, + '~~~~' => "$sigText $d", + '~~~' => $sigText + ] ); + # The main two signature forms used above are time-sensitive + $this->mOutput->setFlag( 'user-signature' ); + } # Context links ("pipe tricks"): [[|name]] and [[name (context)|]] $tc = '[' . Title::legalChars() . ']'; @@ -4762,7 +4748,7 @@ class Parser { * @throws MWException * @return callable|null The old value of the mTagHooks array associated with the hook */ - public function setHook( $tag, $callback ) { + public function setHook( $tag, callable $callback ) { $tag = strtolower( $tag ); if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" ); @@ -4793,7 +4779,7 @@ class Parser { * @throws MWException * @return callable|null The old value of the mTagHooks array associated with the hook */ - public function setTransparentTagHook( $tag, $callback ) { + public function setTransparentTagHook( $tag, callable $callback ) { $tag = strtolower( $tag ); if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { throw new MWException( "Invalid character {$m[0]} in setTransparentHook('$tag', ...) call" ); @@ -4856,7 +4842,7 @@ class Parser { * @throws MWException * @return string|callable The old callback function for this name, if any */ - public function setFunctionHook( $id, $callback, $flags = 0 ) { + public function setFunctionHook( $id, callable $callback, $flags = 0 ) { global $wgContLang; $oldVal = isset( $this->mFunctionHooks[$id] ) ? $this->mFunctionHooks[$id][0] : null; @@ -4908,7 +4894,7 @@ class Parser { * @throws MWException * @return null */ - public function setFunctionTagHook( $tag, $callback, $flags ) { + public function setFunctionTagHook( $tag, callable $callback, $flags ) { $tag = strtolower( $tag ); if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) { throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" ); @@ -4960,7 +4946,6 @@ class Parser { * @return string HTML */ public function renderImageGallery( $text, $params ) { - $mode = false; if ( isset( $params['mode'] ) ) { $mode = $params['mode']; @@ -6082,7 +6067,7 @@ class Parser { $e = new Exception; $this->mInParse = $e->getTraceAsString(); - $recursiveCheck = new ScopedCallback( function() { + $recursiveCheck = new ScopedCallback( function () { $this->mInParse = false; } );