From a3d8146e57135c65356f6be2e813b4f179ec7d1d Mon Sep 17 00:00:00 2001 From: addshore Date: Wed, 5 Mar 2014 20:50:20 +0100 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.20.1