From 01aa34783c9b19d39e568641f3f2dd0fc983b11a Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 24 Aug 2011 16:32:22 +0200 Subject: [PATCH] Do not try to serialize() anonymous functions. --- ChangeLog.markdown | 5 +++++ PHPUnit/Util/GlobalState.php | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index c49ad3925a8..fa723c634a6 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -3,6 +3,11 @@ PHPUnit 3.5 This is the list of changes for the PHPUnit 3.5 release series. +PHPUnit 3.5.16 +-------------- + +* `PHPUnit_Util_GlobalState` no longer tries to `serialize()` anonymous functions. + PHPUnit 3.5.15 -------------- diff --git a/PHPUnit/Util/GlobalState.php b/PHPUnit/Util/GlobalState.php index f4412b0e83d..3293584ada4 100644 --- a/PHPUnit/Util/GlobalState.php +++ b/PHPUnit/Util/GlobalState.php @@ -106,7 +106,8 @@ public static function backupGlobals(array $blacklist) foreach (array_keys($GLOBALS) as $key) { if ($key != 'GLOBALS' && !in_array($key, $superGlobalArrays) && - !in_array($key, $blacklist)) { + !in_array($key, $blacklist) && + !is_callable($GLOBALS[$key])) { self::$globals['GLOBALS'][$key] = serialize($GLOBALS[$key]); } } @@ -226,6 +227,10 @@ public static function getGlobalsAsString() if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray])) { foreach (array_keys($GLOBALS[$superGlobalArray]) as $key) { + if (is_callable($GLOBALS[$superGlobalArray][$key])) { + continue; + } + $result .= sprintf( '$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n", $superGlobalArray, @@ -241,7 +246,7 @@ public static function getGlobalsAsString() $blacklist[] = '_PEAR_Config_instance'; foreach (array_keys($GLOBALS) as $key) { - if (!in_array($key, $blacklist)) { + if (!in_array($key, $blacklist) && !is_callable($GLOBALS[$key])) { $result .= sprintf( '$GLOBALS[\'%s\'] = %s;' . "\n", $key, @@ -294,7 +299,11 @@ public static function backupStaticAttributes(array $blacklist) if (!isset($blacklist[$declaredClasses[$i]]) || !in_array($name, $blacklist[$declaredClasses[$i]])) { $attribute->setAccessible(TRUE); - $backup[$name] = serialize($attribute->getValue()); + $value = $attribute->getValue(); + + if (!is_callable($value)) { + $backup[$name] = serialize($value); + } } } }