r54524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54523‎ | r54524 | r54525 >
Date:16:11, 6 August 2009
Author:werdna
Status:ok
Tags:
Comment:
If an object has already been unstubbed (i.e. we have a copy of the StubObject, which has since been unstubbed but the copy not updated), then return the already-unstubbed object instead of unstubbing it again
Modified paths:
  • /trunk/phase3/includes/StubObject.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/StubObject.php
@@ -88,6 +88,10 @@
8989 */
9090 function _unstub( $name = '_unstub', $level = 2 ) {
9191 static $recursionLevel = 0;
 92+
 93+ if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) )
 94+ return $GLOBALS[$this->mGlobal]; // already unstubbed.
 95+
9296 if ( get_class( $GLOBALS[$this->mGlobal] ) != $this->mClass ) {
9397 $fname = __METHOD__.'-'.$this->mGlobal;
9498 wfProfileIn( $fname );
@@ -96,7 +100,7 @@
97101 throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" );
98102 }
99103 wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" );
100 - $GLOBALS[$this->mGlobal] = $this->_newObject();
 104+ $obj = $GLOBALS[$this->mGlobal] = $this->_newObject();
101105 --$recursionLevel;
102106 wfProfileOut( $fname );
103107 }

Status & tagging log