jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/396131 )
Change subject: Change php extract() to explicit code
......................................................................
Change php extract() to explicit code
Avoid php magic and make var settings more visible
Change-Id: I223874fd871104b0ac6a80d7f39c6dd997d0551d
---
M includes/parser/Parser.php
M includes/parser/Preprocessor_DOM.php
M includes/parser/Preprocessor_Hash.php
M includes/parser/Sanitizer.php
4 files changed, 117 insertions(+), 20 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 3548da9..75c1faf 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -3108,10 +3108,29 @@
throw $ex;
}
- # The interface for parser functions allows for
extracting
- # flags into the local scope. Extract any
forwarded flags
- # here.
- extract( $result );
+ // Extract any forwarded flags
+ if ( isset( $result['found'] ) ) {
+ $found = $result['found'];
+ }
+ if ( array_key_exists( 'text', $result ) ) {
+ // a string or null
+ $text = $result['text'];
+ }
+ if ( isset( $result['nowiki'] ) ) {
+ $nowiki = $result['nowiki'];
+ }
+ if ( isset( $result['isHTML'] ) ) {
+ $isHTML = $result['isHTML'];
+ }
+ if ( isset( $result['forceRawInterwiki'] ) ) {
+ $forceRawInterwiki =
$result['forceRawInterwiki'];
+ }
+ if ( isset( $result['isChildObj'] ) ) {
+ $isChildObj = $result['isChildObj'];
+ }
+ if ( isset( $result['isLocalObj'] ) ) {
+ $isLocalObj = $result['isLocalObj'];
+ }
}
}
@@ -3862,11 +3881,12 @@
}
if ( is_array( $output ) ) {
- # Extract flags to local scope (to override
$markerType)
+ // Extract flags
$flags = $output;
$output = $flags[0];
- unset( $flags[0] );
- extract( $flags );
+ if ( isset( $flags['markerType'] ) ) {
+ $markerType = $flags['markerType'];
+ }
}
} else {
if ( is_null( $attrText ) ) {
diff --git a/includes/parser/Preprocessor_DOM.php
b/includes/parser/Preprocessor_DOM.php
index 2588962..5368125 100644
--- a/includes/parser/Preprocessor_DOM.php
+++ b/includes/parser/Preprocessor_DOM.php
@@ -559,8 +559,16 @@
'count' => $count ];
$stack->push( $piece );
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] )
) {
+ $findEquals =
$stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) )
{
+ $findPipe =
$stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] )
) {
+ $inHeading =
$stackFlags['inHeading'];
+ }
$i += $count;
}
} elseif ( $found == 'line-end' ) {
@@ -610,8 +618,16 @@
// Unwind the stack
$stack->pop();
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
// Append the result to the enclosing
accumulator
$accum .= $element;
@@ -640,8 +656,16 @@
$stack->push( $piece );
$accum =& $stack->getAccum();
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] )
) {
+ $findEquals =
$stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) )
{
+ $findPipe =
$stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] )
) {
+ $inHeading =
$stackFlags['inHeading'];
+ }
} else {
# Add literal brace(s)
$accum .= htmlspecialchars( str_repeat(
$curChar, $count ) );
@@ -748,8 +772,16 @@
$accum .= $s;
}
}
- $flags = $stack->getFlags();
- extract( $flags );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
# Add XML element to the enclosing accumulator
$accum .= $element;
diff --git a/includes/parser/Preprocessor_Hash.php
b/includes/parser/Preprocessor_Hash.php
index 332f8e9..b45b026 100644
--- a/includes/parser/Preprocessor_Hash.php
+++ b/includes/parser/Preprocessor_Hash.php
@@ -497,7 +497,16 @@
'count' => $count ];
$stack->push( $piece );
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] )
) {
+ $findEquals =
$stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) )
{
+ $findPipe =
$stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] )
) {
+ $inHeading =
$stackFlags['inHeading'];
+ }
$i += $count;
}
} elseif ( $found == 'line-end' ) {
@@ -554,7 +563,16 @@
// Unwind the stack
$stack->pop();
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
// Append the result to the enclosing
accumulator
array_splice( $accum, count( $accum ), 0,
$element );
@@ -584,7 +602,16 @@
$stack->push( $piece );
$accum =& $stack->getAccum();
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] )
) {
+ $findEquals =
$stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) )
{
+ $findPipe =
$stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] )
) {
+ $inHeading =
$stackFlags['inHeading'];
+ }
} else {
# Add literal brace(s)
self::addLiteral( $accum, str_repeat(
$curChar, $count ) );
@@ -695,7 +722,16 @@
}
}
- extract( $stack->getFlags() );
+ $stackFlags = $stack->getFlags();
+ if ( isset( $stackFlags['findEquals'] ) ) {
+ $findEquals = $stackFlags['findEquals'];
+ }
+ if ( isset( $stackFlags['findPipe'] ) ) {
+ $findPipe = $stackFlags['findPipe'];
+ }
+ if ( isset( $stackFlags['inHeading'] ) ) {
+ $inHeading = $stackFlags['inHeading'];
+ }
# Add XML element to the enclosing accumulator
array_splice( $accum, count( $accum ), 0,
$element );
diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php
index 20fee2d..b570a43 100644
--- a/includes/parser/Sanitizer.php
+++ b/includes/parser/Sanitizer.php
@@ -477,7 +477,16 @@
public static function removeHTMLtags( $text, $processCallback = null,
$args = [], $extratags = [], $removetags = [], $warnCallback =
null
) {
- extract( self::getRecognizedTagData( $extratags, $removetags )
);
+ $tagData = self::getRecognizedTagData( $extratags, $removetags
);
+ $htmlpairs = $tagData['htmlpairs'];
+ $htmlsingle = $tagData['htmlsingle'];
+ $htmlsingleonly = $tagData['htmlsingleonly'];
+ $htmlnest = $tagData['htmlnest'];
+ $tabletags = $tagData['tabletags'];
+ $htmllist = $tagData['htmllist'];
+ $listtags = $tagData['listtags'];
+ $htmlsingleallowed = $tagData['htmlsingleallowed'];
+ $htmlelements = $tagData['htmlelements'];
# Remove HTML comments
$text = self::removeHTMLcomments( $text );
--
To view, visit https://gerrit.wikimedia.org/r/396131
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I223874fd871104b0ac6a80d7f39c6dd997d0551d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: C. Scott Ananian <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits