From ac774b60eab10b7a285265a73c489ebbd193f4e9 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 6 Aug 2009 16:11:12 +0000 Subject: [PATCH] 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 --- includes/StubObject.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/StubObject.php b/includes/StubObject.php index e18537e054..6b60708d17 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -88,6 +88,10 @@ class StubObject { */ function _unstub( $name = '_unstub', $level = 2 ) { static $recursionLevel = 0; + + if ( !($GLOBALS[$this->mGlobal] instanceof StubObject) ) + return $GLOBALS[$this->mGlobal]; // already unstubbed. + if ( get_class( $GLOBALS[$this->mGlobal] ) != $this->mClass ) { $fname = __METHOD__.'-'.$this->mGlobal; wfProfileIn( $fname ); @@ -96,7 +100,7 @@ class StubObject { throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" ); } wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" ); - $GLOBALS[$this->mGlobal] = $this->_newObject(); + $obj = $GLOBALS[$this->mGlobal] = $this->_newObject(); --$recursionLevel; wfProfileOut( $fname ); } -- 2.20.1