From: addshore Date: Wed, 5 Mar 2014 19:50:20 +0000 (+0100) Subject: Catch Serialization Exception in MediaWikiTestCase X-Git-Tag: 1.31.0-rc.0~16733^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=a3d8146e57135c65356f6be2e813b4f179ec7d1d;p=lhc%2Fweb%2Fwiklou.git Catch Serialization Exception in MediaWikiTestCase In the case that something is not serializable then we should fall back and just set the value. This is the case for Closures.. See http://wikidata-jenkins.wmflabs.org/ci/job/wikidata-client-tests/748/console Change-Id: Ib5f76932d60840a2f97671c134e18adc619974cd --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 9ca1cabc22..4d64d0577d 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -315,7 +315,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { // NOTE: we serialize then unserialize the value in case it is an object // this stops any objects being passed by reference. We could use clone // and if is_object but this does account for objects within objects! - $this->mwGlobals[$key] = unserialize( serialize( $GLOBALS[$key] ) ); + try{ + $this->mwGlobals[$key] = unserialize( serialize( $GLOBALS[$key] ) ); + } + // NOTE; some things such as Closures are not serializable + // in this case just set the value! + catch( Exception $e ) { + $this->mwGlobals[$key] = $GLOBALS[$key]; + } } // Override the global