r81831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81830‎ | r81831 | r81832 >
Date:17:36, 9 February 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Follow up to r81829. Poison var_dump, so that debug statements like r81671 can be easily detected.
The three 'right' usages are
* includes/Import.php
* includes/api/ApiFormatDump.php
* tests/parser/parserTestsParserHook.php
Modified paths:
  • /trunk/phase3/tests/parser/parserTestsParserHook.php (modified) (history)
  • /trunk/tools/code-utils/check-vars.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTestsParserHook.php
@@ -28,12 +28,12 @@
2929 class ParserTestParserHook {
3030
3131 static function setup( &$parser ) {
32 - $parser->setHook( 'tag', array( __CLASS__, 'hook' ) );
 32+ $parser->setHook( 'tag', array( __CLASS__, 'dumpHook' ) );
3333
3434 return true;
3535 }
3636
37 - static function hook( $in, $argv ) {
 37+ static function dumpHook( $in, $argv ) {
3838 ob_start();
3939 var_dump(
4040 $in,
Index: trunk/tools/code-utils/check-vars.php
@@ -94,6 +94,9 @@
9595 'session_unregister' => 'Deprecated since PHP 5.3.0.',
9696 'session_is_registered' => 'Deprecated since PHP 5.3.0.',
9797 'set_magic_quotes_runtime' => 'Deprecated since PHP 5.3.0.',
 98+
 99+ 'var_dump' => 'Debugging function.', //r81671#c13996
 100+ //'print_r' => 'Debugging function if second parameter is not true.',
98101 );
99102
100103 protected $generateDeprecatedList = false;
@@ -721,6 +724,10 @@
722725 }
723726
724727 if ( isset( self::$poisonedFunctions[ strtolower($token[1]) ] ) ) {
 728+ if ( $token[1] == 'var_dump' && ( substr( $this->mFunction, 0, 4 ) == 'dump' ) || basename( $this->mFilename ) == 'ApiFormatDump.php' ) {
 729+ // Allow var_dump if the function purpose is really to dump contents
 730+ return;
 731+ }
725732 $this->warning( "Poisoned function {$token[1]} called from {$this->mFunction} in line {$token[2]}: " . self::$poisonedFunctions[strtolower($token[1])] );
726733 return;
727734 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r82604Poison wfVarDump(), as suggested in r81831 CR.platonides15:09, 22 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81671Back out the changes which depend on the categorylinks schema change, so that...tstarling00:57, 8 February 2011
r81829Don't use ob_start/ob_get_contents/ob_end_clean just to var_dump() a string. ...platonides17:21, 9 February 2011

Comments

#Comment by Hashar (talk | contribs)   12:09, 22 February 2011

Marked 'ok' What about wfVarDump() ?

#Comment by Platonides (talk | contribs)   15:09, 22 February 2011

Poisoned in r82604.

Status & tagging log