[php-phpunit-PHPUnit-MockObject] upstream fix for php 5.4.29 and 5.5.13 (#1103223)

Remi Collet remi at fedoraproject.org
Fri May 30 14:02:12 UTC 2014


commit 45590dc3d44d238602c2ec5931594f6fab157394
Author: Remi Collet <remi at fedoraproject.org>
Date:   Fri May 30 15:57:03 2014 +0200

    upstream fix for php 5.4.29 and 5.5.13 (#1103223)
    
    (cherry picked from commit e12faeeef912eb36f93b6857ab9135bd5fbab5dd)

 php-phpunit-PHPUnit-MockObject.spec |   11 +++++-
 phpunit-mock-objects-upstream.patch |   67 +++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/php-phpunit-PHPUnit-MockObject.spec b/php-phpunit-PHPUnit-MockObject.spec
index fa1df2d..512f098 100644
--- a/php-phpunit-PHPUnit-MockObject.spec
+++ b/php-phpunit-PHPUnit-MockObject.spec
@@ -18,7 +18,7 @@
 
 Name:           php-phpunit-PHPUnit-MockObject
 Version:        2.1.0
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Mock Object library for PHPUnit
 
 Group:          Development/Libraries
@@ -32,6 +32,9 @@ Source1:        Autoload.php.in
 # Temporary workaround, under investigation
 Patch0:         %{gh_project}-rpm.patch
 
+# Upstream fix for PHP 5.4.29 and 5.5.13
+Patch1:         %{gh_project}-upstream.patch
+
 BuildArch:      noarch
 BuildRequires:  %{_bindir}/phpab
 %if %{with_tests}
@@ -60,6 +63,9 @@ Mock Object library for PHPUnit
 %setup -q -n %{gh_project}-%{gh_commit}
 
 %patch0 -p1
+%patch1 -p1
+
+find . -name \*.orig -exec rm {} \; -print
 
 
 %build
@@ -99,6 +105,9 @@ fi
 
 
 %changelog
+* Fri May 30 2014 Remi Collet <remi at fedoraproject.org> - 2.1.0-3
+- upstream fix for php 5.4.29 and 5.5.13 (#1103223)
+
 * Tue May  6 2014 Remi Collet <remi at fedoraproject.org> - 2.1.0-2
 - workaround to autoload issue during check
 
diff --git a/phpunit-mock-objects-upstream.patch b/phpunit-mock-objects-upstream.patch
new file mode 100644
index 0000000..1775124
--- /dev/null
+++ b/phpunit-mock-objects-upstream.patch
@@ -0,0 +1,67 @@
+From 1c68f1338f1940deb8265428bb2a7cbc5bc074b5 Mon Sep 17 00:00:00 2001
+From: Maksim Kochkin <maxxarts at gmail.com>
+Date: Fri, 11 Apr 2014 21:12:26 +0400
+Subject: [PATCH] Use newInstanceWithoutConstructor when possible
+
+Comment says
+
+// We have to use this dirty trick instead of ReflectionClass::newInstanceWithoutConstructor()
+// because of https://github.com/sebastianbergmann/phpunit-mock-objects/issues/154
+
+As I see the only reason to use unserialize here is internal classes (or not?). So how about using unserialize for internal classes and newInstanceWithoutConstructor for other?
+---
+ src/Framework/MockObject/Generator.php | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php
+index 59f10ad..1d8467b 100644
+--- a/src/Framework/MockObject/Generator.php
++++ b/src/Framework/MockObject/Generator.php
+@@ -267,11 +267,14 @@ protected function getObject($code, $className, $type = '', $callOriginalConstru
+                 $object = $class->newInstanceArgs($arguments);
+             }
+         } else {
+-            // We have to use this dirty trick instead of ReflectionClass::newInstanceWithoutConstructor()
+-            // because of https://github.com/sebastianbergmann/phpunit-mock-objects/issues/154
+-            $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();
++            }
+         }
+ 
+         if ($callOriginalMethods) {
+-- 
+1.9.3
+
+From ba8784d88ff4cc52cf9424d7f7c631ccd867019c Mon Sep 17 00:00:00 2001
+From: Maksim Kochkin <maxxarts at gmail.com>
+Date: Mon, 14 Apr 2014 00:09:22 +0400
+Subject: [PATCH] newInstanceWithoutConstructor only for 5.4+
+
+---
+ src/Framework/MockObject/Generator.php | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Framework/MockObject/Generator.php b/src/Framework/MockObject/Generator.php
+index 1d8467b..a4c7037 100644
+--- a/src/Framework/MockObject/Generator.php
++++ b/src/Framework/MockObject/Generator.php
+@@ -268,7 +268,7 @@ protected function getObject($code, $className, $type = '', $callOriginalConstru
+             }
+         } else {
+             $class = new ReflectionClass($className);
+-            if ($class->isInternal()) {
++            if ($class->isInternal() || version_compare(PHP_VERSION, '5.4.0', '<')) {
+                 $object = unserialize(
+                     sprintf('O:%d:"%s":0:{}', strlen($className), $className)
+                 );
+-- 
+1.9.3
+


More information about the scm-commits mailing list