From 0d847cb55d8e9c3c0f40827828472fd9b25e1018 Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Mon, 7 Jul 2014 15:36:44 -0400 Subject: [PATCH] Unstub the passed object when calling unstub() Previously, only the global was unstubbed when StubObject::unstub() was called. Now, the object given as a parameter will also be unstubbed. (What about other references to the object, though?) Change-Id: I431ddd61e24686fc2f014c30064808ce57fe1706 --- includes/StubObject.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/StubObject.php b/includes/StubObject.php index 6508bceca7..fb9b3e455c 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -83,9 +83,9 @@ class StubObject { * @param object $obj Object to check. * @return void */ - static function unstub( $obj ) { + static function unstub( &$obj ) { if ( $obj instanceof StubObject ) { - $obj->_unstub( 'unstub', 3 ); + $obj = $obj->_unstub( 'unstub', 3 ); } } @@ -134,6 +134,7 @@ class StubObject { * @param string $name Name of the method called in this object. * @param int $level Level to go in the stack trace to get the function * who called this function. + * @return The unstubbed version of itself * @throws MWException */ function _unstub( $name = '_unstub', $level = 2 ) { @@ -157,6 +158,7 @@ class StubObject { $GLOBALS[$this->global] = $this->_newObject(); --$recursionLevel; wfProfileOut( $fname ); + return $GLOBALS[$this->global]; } } } -- 2.20.1