Thiemo Kreuz (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399428 )

Change subject: Remove dead, unused debug code, forgotten variables and such
......................................................................

Remove dead, unused debug code, forgotten variables and such

This patch also fixes some actual bugs because of typos in variable
names.

Change-Id: I1c4e306dd23eddf9521902b255725f325f7d69f5
---
M DPL.php
M DPLMain.php
M DPLSetup.php
M DynamicPageListInclude.php
4 files changed, 13 insertions(+), 73 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DynamicPageList 
refs/changes/28/399428/1

diff --git a/DPL.php b/DPL.php
index 8f7cba9..0dbebc4 100644
--- a/DPL.php
+++ b/DPL.php
@@ -142,7 +142,6 @@
                                                if ( $greml > 0 ) {
                                                        $this->mOutput .= 
$this->formatList( $nstart -$offset, $portion, $iTitleMaxLen, 
$defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol, $updateRules, 
$deleteRules );
                                                        $nstart += $portion;
-                                                       $portion = 0;
                                                        break;
                                                } else {
                                                        $this->mOutput .= 
$this->formatList( $nstart -$offset, $portion + $greml, $iTitleMaxLen, 
$defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol, $updateRules, 
$deleteRules );
@@ -246,7 +245,6 @@
        }
 
        function formatCount( $numart ) {
-               global $wgLang;
                if ( $this->mHeadingType == 'category' ) {
                        $message = 'categoryarticlecount';
                } else {
@@ -343,7 +341,7 @@
        }
 
        function formatList( $iStart, $iCount, $iTitleMaxLen, 
$defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol, $updateRules, 
$deleteRules ) {
-               global $wgUser, $wgLang, $wgContLang;
+               global $wgLang, $wgContLang;
 
                $mode = $this->mListMode;
                // categorypage-style list output mode
@@ -770,7 +768,6 @@
                $optional = array();
 
                $lastCmd = '';
-               $message = '';
                $summary = '';
                $editForm = false;
                $action = '';
@@ -780,7 +777,6 @@
                $table = '';
                $fieldFormat = '';
 
-               // $message .= 'updaterules=<pre><nowiki>';
                $nr = -1;
                foreach ( $rules as $rule ) {
                        if ( preg_match( '/^\s*#/', $rule ) > 0 ) {
@@ -901,8 +897,6 @@
                        }
                }
 
-               // $message.= '</nowiki></pre>';
-
                // perform changes to the wiki source text 
=======================================
 
                if ( $replaceThis != '' ) {
@@ -1006,7 +1000,7 @@
                                        foreach ( $parameter as $nr => $parm ) {
                                                // set parameters to values 
specified in the dpl source or get them from the HTTP request
                                                if ( $exec == 'set' ) {
-                                                       $myvalue = $value[$nr];
+                                                       $myValue = $value[$nr];
                                                } else {
                                                        if ( $call >= 
$matchCount ) {
                                                                break;
diff --git a/DPLMain.php b/DPLMain.php
index c570fe1..a491da7 100644
--- a/DPLMain.php
+++ b/DPLMain.php
@@ -16,7 +16,7 @@
 
                error_reporting( E_ALL );
 
-               global $wgUser, $wgLang, $wgContLang, $wgRequest;
+               global $wgLang, $wgContLang, $wgRequest;
                global $wgNonincludableNamespaces;
 
                // logger (display of debug messages)
@@ -34,7 +34,6 @@
 
                // Local parser created. See 
http://www.mediawiki.org/wiki/Extensions_FAQ#How_do_I_render_wikitext_in_my_extension.3F
                $localParser = new Parser();
-               $pOptions = $parser->mOptions;
 
                // check if DPL shall only be executed from protected pages
                if ( array_key_exists( 'RunFromProtectedPagesOnly', 
ExtDynamicPageList::$options ) &&
@@ -161,8 +160,6 @@
                $bEscapeLinks = 
ExtDynamicPageList::$options['escapelinks']['default'];
                $bSkipThisPage = 
ExtDynamicPageList::$options['skipthispage']['default'];
 
-               $sHiddenCategories = 
ExtDynamicPageList::$options['hiddencategories']['default'];
-
                $sMinorEdits = null;
                $acceptOpenReferences = self::argBoolean( 
ExtDynamicPageList::$options['openreferences']['default'] );
 
@@ -180,7 +177,6 @@
                $sQuality   = 
ExtDynamicPageList::$options['qualitypages']['default'];
                $sStable        = 
ExtDynamicPageList::$options['stablepages']['default'];
 
-               $bSuppressErrors  = self::argBoolean( 
ExtDynamicPageList::$options['suppresserrors']['default'] );
                $sResultsHeader   = 
ExtDynamicPageList::$options['resultsheader']['default'];
                $sResultsFooter   = 
ExtDynamicPageList::$options['resultsfooter']['default'];
                $sNoResultsHeader = 
ExtDynamicPageList::$options['noresultsheader']['default'];
@@ -276,8 +272,6 @@
 
                $_sIncludeMaxLen = 
ExtDynamicPageList::$options['includemaxlength']['default'];
                $iIncludeMaxLen = ( $_sIncludeMaxLen == '' ) ? null : intval( 
$_sIncludeMaxLen );
-
-               $bScroll = self::argBoolean( 
ExtDynamicPageList::$options['scroll']['default'] );
 
                $aLinksTo          = array();
                $aNotLinksTo    = array();
@@ -454,9 +448,7 @@
                                        }
                                        break;
                                case 'hiddencategories':
-                                       if ( in_array( $sArg, 
ExtDynamicPageList::$options['hiddencategories'] ) ) {
-                                               $sHiddenCategories = $sArg;
-                                       } else {
+                                       if ( !in_array( $sArg, 
ExtDynamicPageList::$options['hiddencategories'] ) ) {
                                                $output .= 
$logger->msgWrongParam( 'hiddencategories', $sArg );
                                        }
                                        break;
@@ -2883,9 +2875,6 @@
                        $dbr->freeResult( $res );
                        return $output;
                }
-
-               // generate title for Special:Contributions (used if 
adduser=true)
-               $sSpecContribs = '[[:Special:Contributions|Contributions]]';
 
                $aHeadings = array(); // maps heading to count (# of pages 
under each heading)
                $aArticles = array();
diff --git a/DPLSetup.php b/DPLSetup.php
index 9d2ef16..82c2279 100644
--- a/DPLSetup.php
+++ b/DPLSetup.php
@@ -1322,9 +1322,8 @@
                // entry point for user tag <dpl> or <DynamicPageList>
                // create list and do a recursive parse of the output
 
-               // $dump1 = self::dumpParsedRefs($parser,"before DPL tag");
                $text = DPLMain::dynamicPageList( $input, $params, $parser, 
$reset, 'tag' );
-               // $dump2 = self::dumpParsedRefs($parser,"after DPL tag");
+
                if ( $reset[1] ) { // we can remove the templates by 
save/restore
                        $saveTemplates = $parser->mOutput->mTemplates;
                }
@@ -1334,7 +1333,9 @@
                if ( $reset[3] ) { // we can remove the images by save/restore
                        $saveImages = $parser->mOutput->mImages;
                }
+
                $parsedDPL = $parser->recursiveTagParse( $text );
+
                if ( $reset[1] ) { // TEMPLATES
                        $parser->mOutput->mTemplates = $saveTemplates;
                }
@@ -1344,8 +1345,7 @@
                if ( $reset[3] ) { // IMAGES
                        $parser->mOutput->mImages = $saveImages;
                }
-               // $dump3 = self::dumpParsedRefs($parser,"after tag parse");
-               // return $dump1.$parsedDPL.$dump2.$dump3;
+
                return $parsedDPL;
        }
 
@@ -1372,13 +1372,6 @@
                        $p1 = $arg_list[$i];
                        $input .= str_replace( "\n", '', $p1 ) . "\n";
                }
-               // for debugging you may want to uncomment the following 
statement
-               // return 
str_replace('§','<','§pre>§nowiki>'.$input.'§/nowiki>§/pre>');
-
-               // $dump1 = self::dumpParsedRefs($parser,"before DPL func");
-               // $text = DPLMain::dynamicPageList($input, $params, $parser, 
$reset, 'func');
-               // $dump2 = self::dumpParsedRefs($parser,"after DPL func");
-               // return $dump1.$text.$dump2;
 
                $dplresult = DPLMain::dynamicPageList( $input, $params, 
$parser, $reset, 'func' );
                return array( // parser needs to be coaxed to do further 
recursive processing
@@ -1390,7 +1383,7 @@
 
        public static function dplNumParserFunction( &$parser, $text = '' ) {
                $num = str_replace( '&#160;', ' ', $text );
-               $num = str_replace( '&nbsp;', ' ', $text );
+               $num = str_replace( '&nbsp;', ' ', $num );
                $num = preg_replace( '/([0-9])([.])([0-9][0-9]?[^0-9,])/', 
'\1,\3', $num );
                $num = preg_replace( '/([0-9.]+),([0-9][0-9][0-9])\s*Mrd/', 
'\1\2 000000 ', $num );
                $num = preg_replace( '/([0-9.]+),([0-9][0-9])\s*Mrd/', '\1\2 
0000000 ', $num );
@@ -1459,7 +1452,7 @@
                $sources = array();
                $targets = array();
                $from = '';
-               $to = '';
+
                if ( $flip == '' | $flip == 'normal' ) {
                        $flip = false;
                } else {
@@ -1540,24 +1533,6 @@
                }
        }
 
-       private static function dumpParsedRefs( $parser, $label ) {
-               // if (!preg_match("/Query Q/",$parser->mTitle->getText())) 
return '';
-               echo '<pre>parser mLinks: ';
-               ob_start();
-               var_dump( $parser->mOutput->mLinks );
-               $a = ob_get_contents();
-               ob_end_clean();
-               echo htmlspecialchars( $a, ENT_QUOTES );
-               echo '</pre>';
-               echo '<pre>parser mTemplates: ';
-               ob_start();
-               var_dump( $parser->mOutput->mTemplates );
-               $a = ob_get_contents();
-               ob_end_clean();
-               echo htmlspecialchars( $a, ENT_QUOTES );
-               echo '</pre>';
-       }
-
        // remove section markers in case the LabeledSectionTransclusion 
extension is not installed.
        public static function removeSectionMarkers( $in, $assocArgs = array(), 
$parser = null ) {
                return '';
@@ -1578,7 +1553,6 @@
                                        self::$fixedCategories[$key] = $val;
                                }
                        }
-                       // $text .= self::dumpParsedRefs($parser,"before final 
reset");
                        if ( self::$createdLinks['resetLinks'] ) {
                                $parser->mOutput->mLinks = array();
                        }
@@ -1591,7 +1565,6 @@
                        if ( self::$createdLinks['resetImages'] ) {
                                $parser->mOutput->mImages = array();
                        }
-                       // $text .= self::dumpParsedRefs($parser,"after final 
reset");
                        self::$fixedCategories = array();
                }
                return true;
@@ -1600,16 +1573,13 @@
        public static function endEliminate( &$parser, &$text ) {
                // called during the final output phase; removes links created 
by DPL
                if ( isset( self::$createdLinks ) ) {
-                       // self::dumpParsedRefs($parser,"before final 
eliminate");
                        if ( array_key_exists( 0, self::$createdLinks ) ) {
                                foreach ( $parser->mOutput->getLinks() as $nsp 
=> $link ) {
                                        if ( !array_key_exists( $nsp, 
self::$createdLinks[0] ) ) {
                                                continue;
                                        }
-                                       // echo ("<pre> elim: created Links 
[$nsp] = ". count(ExtDynamicPageList::$createdLinks[0][$nsp])."</pre>\n");
-                                       // echo ("<pre> elim: parser Links 
[$nsp] = ". count($parser->mOutput->mLinks[$nsp])                    
."</pre>\n");
+
                                        $parser->mOutput->mLinks[$nsp] = 
array_diff_assoc( $parser->mOutput->mLinks[$nsp], self::$createdLinks[0][$nsp] 
);
-                                       // echo ("<pre> elim: parser Links 
[$nsp] nachher = ". count($parser->mOutput->mLinks[$nsp])     ."</pre>\n");
                                        if ( count( 
$parser->mOutput->mLinks[$nsp] ) == 0 ) {
                                                unset( 
$parser->mOutput->mLinks[$nsp] );
                                        }
@@ -1620,10 +1590,8 @@
                                        if ( !array_key_exists( $nsp, 
self::$createdLinks[1] ) ) {
                                                continue;
                                        }
-                                       // echo ("<pre> elim: created Tpls 
[$nsp] = ". count(ExtDynamicPageList::$createdLinks[1][$nsp])."</pre>\n");
-                                       // echo ("<pre> elim: parser Tpls 
[$nsp] = ". count($parser->mOutput->mTemplates[$nsp])                 
."</pre>\n");
+
                                        $parser->mOutput->mTemplates[$nsp] = 
array_diff_assoc( $parser->mOutput->mTemplates[$nsp], 
self::$createdLinks[1][$nsp] );
-                                       // echo ("<pre> elim: parser Tpls 
[$nsp] nachher = ". count($parser->mOutput->mTemplates[$nsp])  ."</pre>\n");
                                        if ( count( 
$parser->mOutput->mTemplates[$nsp] ) == 0 ) {
                                                unset( 
$parser->mOutput->mTemplates[$nsp] );
                                        }
@@ -1635,7 +1603,6 @@
                        if ( isset( self::$createdLinks ) && array_key_exists( 
3, self::$createdLinks ) ) {
                                $parser->mOutput->mImages = array_diff_assoc( 
$parser->mOutput->mImages, self::$createdLinks[3] );
                        }
-                       // $text .= self::dumpParsedRefs($parser,"after final 
eliminate".$parser->mTitle->getText());
                }
 
                // self::$createdLinks=array(
diff --git a/DynamicPageListInclude.php b/DynamicPageListInclude.php
index 167df74..9e2accf 100644
--- a/DynamicPageListInclude.php
+++ b/DynamicPageListInclude.php
@@ -178,7 +178,6 @@
        /// Generate a regex to match the section(s) we're interested in.
        private static function createSectionPattern( $sec, $to, &$any ) {
                $any = false;
-               $to_sec = ( $to == '' ) ? $sec : $to;
                if ( $sec[0] == '*' ) {
                        $any = true;
                        if ( $sec == '**' )     {
@@ -188,15 +187,6 @@
                        }
                } else {
                        $sec = preg_quote( $sec, '/' );
-               }
-               if ( $to_sec[0] == '*' ) {
-                       if ( $to_sec == '**' ) {
-                               $to_sec = '[^\/>"' . "']+";
-                       } else {
-                               $to_sec = str_replace( '/', '\/', substr( 
$to_sec, 1 ) );
-                       }
-               } else {
-                       $to_sec = preg_quote( $to_sec, '/' );
                }
 
                $ws = "(?:\s+[^>]+)?"; // was like $ws="\s*"
@@ -638,7 +628,7 @@
                                $n++;
                                continue;
                        }
-                       $c = $tCall[0];
+
                        // normally we construct a call for template2 with the 
parameters of template1
                        if ( count( $extractParm ) == 0 ) {
                                // find the end of the call: bracket level must 
be zero

-- 
To view, visit https://gerrit.wikimedia.org/r/399428
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c4e306dd23eddf9521902b255725f325f7d69f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DynamicPageList
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to