r44421 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44420‎ | r44421 | r44422 >
Date:19:41, 10 December 2008
Author:brion
Status:ok (Comments)
Tags:
Comment:
Revert r44119 "Remove extract() comment"
extract() is pretty much the devil and shouldn't ever be used for safe, legible code because it makes it much more difficult to analyse the code -- you have to run around trying to track down the source of local variables and there's generally a lot of pain.
Removing the FIXME comment isn't a substitute for fixing it. ;)
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ChangesList.php
@@ -339,6 +339,7 @@
340340 wfProfileIn( __METHOD__ );
341341
342342 # Extract DB fields into local scope
 343+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
343344 extract( $rc->mAttribs );
344345
345346 # Should patrol-related stuff be shown?
@@ -432,6 +433,7 @@
433434 $rc = RCCacheEntry::newFromParent( $baseRC );
434435
435436 # Extract fields from DB into the function scope (rc_xxxx variables)
 437+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
436438 extract( $rc->mAttribs );
437439 $curIdEq = 'curid=' . $rc_cur_id;
438440
@@ -720,6 +722,7 @@
721723 $r .= '<table cellpadding="0" cellspacing="0" border="0" style="background: none">';
722724 foreach( $block as $rcObj ) {
723725 # Get rc_xxxx variables
 726+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
724727 extract( $rcObj->mAttribs );
725728
726729 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
@@ -839,6 +842,7 @@
840843 protected function recentChangesBlockLine( $rcObj ) {
841844 global $wgContLang, $wgRCShowChangedSize;
842845 # Get rc_xxxx variables
 846+ // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
843847 extract( $rcObj->mAttribs );
844848 $curIdEq = "curid={$rc_cur_id}";
845849

Follow-up revisions

RevisionCommit summaryAuthorDate
r79083Refactoring in RecentChanges/Watchlist:...happy-melon19:07, 27 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44119Remove extract() commentaaron17:02, 1 December 2008

Comments

#Comment by Aaron Schulz (talk | contribs)   20:23, 10 December 2008

Won't they go to the local symbol table? Wow is that comment correct?

Status & tagging log