Package: phpunit-mock-object
Version: 1.2.3-1
Severity: important
Tags: patch

Hi,

PHP 5.6.0 closes PHP bug #67072 [1], which breaks compatibility of PHP
with phpunit-mock-object 1.2.3 in Debian. This results in errors like:

<code>
PHP Warning:  Erroneous data format for unserializing 
'Mock_TokenInterface_b42316e5' in 
/usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
PHP Notice:  unserialize(): Error at offset 39 of 40 bytes in 
/usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
PHP Fatal error:  Call to a member function expects() on boolean in 
/tmp/symfony/src/Symfony/Component/Security/Tests/Acl/Domain/UserSecurityIdentityTest.php
 on line 57
</code>

For another example take a look at Debian BTS #759235 [2].

Since PHP 5.6.0 is in sid and phpunit-mock-object is not working reliably
with it, I'm setting the severity of this bug to important.

The patch attached is taken from upstream's VCS [3] and no longer needed
with PHPUnit_MockObject v2.1.5 and up [4].

It can be applied to a local clone of pkg-php/phpunit-mock-object.git
(branch 'debian-sid') with '# git am', e.g.:
# cd /PATH/TO/PHPUNIT-MOCK-OBJECT-REPO
# git am /PATH/TO/PHP-5.6.0-support.patch

Thanks
Daniel


[1] http://bugs.php.net/67072
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759235#5
[3] 
https://github.com/sebastianbergmann/phpunit-mock-objects/commit/1c68f1338f1940deb8265428bb2a7cbc5bc074b5
[4] https://github.com/sebastianbergmann/phpunit-mock-objects/issues/171
From 0927007baa55b978f13d897f7479763df4a2313c Mon Sep 17 00:00:00 2001
From: Daniel Beyer <d...@deb.ymc.ch>
Date: Thu, 18 Sep 2014 13:49:53 +0200
Subject: [PATCH] Support PHP 5.6.0 by backporting a patch from upstream

---
 .../patches/0001-Add-support-for-PHP-5.6.0.patch   | 51 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 52 insertions(+)
 create mode 100644 debian/patches/0001-Add-support-for-PHP-5.6.0.patch
 create mode 100644 debian/patches/series

diff --git a/debian/patches/0001-Add-support-for-PHP-5.6.0.patch b/debian/patches/0001-Add-support-for-PHP-5.6.0.patch
new file mode 100644
index 0000000..de43465
--- /dev/null
+++ b/debian/patches/0001-Add-support-for-PHP-5.6.0.patch
@@ -0,0 +1,51 @@
+From: Daniel Beyer <ymc-d...@vcs.ymc.ch>
+Date: Thu, 18 Sep 2014 13:05:21 +0200
+Subject: Add support for PHP 5.6.0
+
+Forwarded: not-needed
+
+PHP 5.6.0 closes PHP bug #67072 [1], which breaks compatibility of PHP with
+phpunit-mock-object 1.2.3 in Debian. This results in errors like:
+<code>
+PHP Warning:  Erroneous data format for unserializing 'Mock_TokenInterface_b42316e5' in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
+PHP Notice:  unserialize(): Error at offset 39 of 40 bytes in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 247
+PHP Fatal error:  Call to a member function expects() on boolean in /tmp/symfony/src/Symfony/Component/Security/Tests/Acl/Domain/UserSecurityIdentityTest.php on line 57
+</code>
+
+For another example take a look at Debian BTS #759235 [2].
+
+The patch is taken from upstream's VCS [3] and no longer needed with
+PHPUnit_MockObject v2.1.5 and up [4].
+
+[1] http://bugs.php.net/67072
+[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759235#5
+[3] https://github.com/sebastianbergmann/phpunit-mock-objects/commit/1c68f1338f1940deb8265428bb2a7cbc5bc074b5
+[4] https://github.com/sebastianbergmann/phpunit-mock-objects/issues/171
+---
+ .../PHPUnit/Framework/MockObject/Generator.php              | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/PHPUnit_MockObject-1.2.3/PHPUnit/Framework/MockObject/Generator.php b/PHPUnit_MockObject-1.2.3/PHPUnit/Framework/MockObject/Generator.php
+index e25d050..846ec4c 100644
+--- a/PHPUnit_MockObject-1.2.3/PHPUnit/Framework/MockObject/Generator.php
++++ b/PHPUnit_MockObject-1.2.3/PHPUnit/Framework/MockObject/Generator.php
+@@ -240,11 +240,14 @@ class PHPUnit_Framework_MockObject_Generator
+                 $object = $class->newInstanceArgs($arguments);
+             }
+         } else {
+-            // Use a trick to create a new object of a class
+-            // without invoking its constructor.
+-            $object = unserialize(
+-              sprintf('O:%d:"%s":0:{}', strlen($className), $className)
+-            );
++            $class = new ReflectionClass($className);
++            if ($class->isInternal()) {
++                $object = unserialize(
++                    sprintf('O:%d:"%s":0:{}', strlen($className), $className)
++                );
++            } else {
++                $object = $class->newInstanceWithoutConstructor();
++            }
+         }
+ 
+         return $object;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..9d68b6a
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-Add-support-for-PHP-5.6.0.patch
-- 
1.9.1

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to