summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2016-03-21 19:11:56 +0100
committerRemi Collet <fedora@famillecollet.com>2016-03-21 19:11:56 +0100
commitbe79fece04b6a83207b4c6feaab7a93413cd8afb (patch)
tree7d9228bd9cc57e4e96aa4baed38c7ef807f820f1
parentdf297d127c3331acee0fbafb8be6b0059ce9c366 (diff)
php-zendframework-zend-view: test build
-rw-r--r--php-zendframework-zend-view-pr55.patch159
-rw-r--r--php-zendframework-zend-view.spec12
2 files changed, 169 insertions, 2 deletions
diff --git a/php-zendframework-zend-view-pr55.patch b/php-zendframework-zend-view-pr55.patch
new file mode 100644
index 0000000..c022529
--- /dev/null
+++ b/php-zendframework-zend-view-pr55.patch
@@ -0,0 +1,159 @@
+From fed4b7ad72b0dbdf475310fa73ecf84d477f5c0e Mon Sep 17 00:00:00 2001
+From: Matthew Weier O'Phinney <matthew@zend.com>
+Date: Mon, 21 Mar 2016 11:52:49 -0500
+Subject: [PATCH 1/2] Fix zendframework/zend-navigation#23
+
+Running tests of zend-navigation against all v2 components (no v3 components)
+revealed a circular dependency condition in the navigation helpers related to
+`getEventManager()`.
+
+In v2, `getEventManager()` has lazy-loaded an EM instance, and an initializer
+was checking the returned instance to see if its `SharedEventManager` instance
+was present and/or the same as the one in the container; if not, it was
+re-injecting the EM instance from the container. Unfortunately, this fails now,
+as the call to `setEventManager()` now attaches the default listeners, and
+requires that a shared manager is present.
+
+This patch changes the behavior to the following:
+
+- `getEventManager()` now *never* lazy-loads an instance. This ensures that the
+ initializer doesn't lead to lazy-population of the shared manager.
+- `setEventManager()` was updated to check that we have a shared manager before
+ attempting to call `setDefaultListeners()`.
+- Internally, if an EM instance is needed, it now lazy-creates one, *with a
+ shared manager*, and calls `setEventManager()` with the new EM instance.
+- The EM initializer in the helper plugin amanger was updated to first check
+ that we have an `EventManager` instance before attempting to inject one.
+---
+ src/Helper/Navigation/AbstractHelper.php | 34 ++++++++++++++++++---------
+ src/HelperPluginManager.php | 5 ++++
+ test/Helper/Navigation/AbstractHelperTest.php | 5 ++++
+ test/Helper/Navigation/AbstractTest.php | 5 ----
+ 4 files changed, 33 insertions(+), 16 deletions(-)
+
+diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php
+index 5503b10..823c43e 100644
+--- a/src/Helper/Navigation/AbstractHelper.php
++++ b/src/Helper/Navigation/AbstractHelper.php
+@@ -342,7 +342,8 @@ public function accept(AbstractPage $page, $recursive = true)
+ */
+ protected function isAllowed($params)
+ {
+- $results = $this->getEventManager()->trigger(__FUNCTION__, $this, $params);
++ $events = $this->getEventManager() ?: $this->createEventManager();
++ $results = $events->trigger(__FUNCTION__, $this, $params);
+ return $results->last();
+ }
+
+@@ -513,22 +514,23 @@ public function setEventManager(EventManagerInterface $events)
+
+ $this->events = $events;
+
+- $this->setDefaultListeners();
++ if ($events->getSharedManager()) {
++ $this->setDefaultListeners();
++ }
+
+ return $this;
+ }
+
+ /**
+- * Get the event manager.
++ * Get the event manager, if present.
++ *
++ * Internally, the helper will lazy-load an EM instance the first time it
++ * requires one, but ideally it should be injected during instantiation.
+ *
+- * @return EventManagerInterface
++ * @return null|EventManagerInterface
+ */
+ public function getEventManager()
+ {
+- if (null === $this->events) {
+- $this->setEventManager($this->createEventManager());
+- }
+-
+ return $this->events;
+ }
+
+@@ -956,7 +958,13 @@ protected function setDefaultListeners()
+ return;
+ }
+
+- $this->getEventManager()->getSharedManager()->attach(
++ $events = $this->getEventManager() ?: $this->createEventManager();
++
++ if (! $events->getSharedManager()) {
++ return;
++ }
++
++ $events->getSharedManager()->attach(
+ 'Zend\View\Helper\Navigation\AbstractHelper',
+ 'isAllowed',
+ ['Zend\View\Helper\Navigation\Listener\AclListener', 'accept']
+@@ -975,9 +983,13 @@ private function createEventManager()
+ {
+ $r = new ReflectionClass(EventManager::class);
+ if ($r->hasMethod('setSharedManager')) {
+- return new EventManager();
++ $events = new EventManager();
++ $events->setSharedManager(new SharedEventManager());
++ } else {
++ $events = new EventManager(new SharedEventManager());
+ }
+
+- return new EventManager(new SharedEventManager());
++ $this->setEventManager($events);
++ return $events;
+ }
+ }
+diff --git a/src/HelperPluginManager.php b/src/HelperPluginManager.php
+index 8d97b6c..daf9190 100644
+--- a/src/HelperPluginManager.php
++++ b/src/HelperPluginManager.php
+@@ -375,6 +375,11 @@ public function injectEventManager($first, $second)
+ return;
+ }
+
++ if (! $container->has('EventManager')) {
++ // If the container doesn't have an EM service, do nothing.
++ return;
++ }
++
+ $events = $helper->getEventManager();
+ if (! $events || ! $events->getSharedManager() instanceof SharedEventManagerInterface) {
+ $helper->setEventManager($container->get('EventManager'));
+diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php
+index e53f877..37262a7 100644
+--- a/test/Helper/Navigation/AbstractHelperTest.php
++++ b/test/Helper/Navigation/AbstractHelperTest.php
+@@ -76,4 +76,9 @@ public function testHasRoleChecksMemberVariable()
+ $this->_helper->setRole($role);
+ $this->assertEquals(true, $this->_helper->hasRole());
+ }
++
++ public function testEventManagerIsNullByDefault()
++ {
++ $this->assertNull($this->_helper->getEventManager());
++ }
+ }
+diff --git a/test/Helper/Navigation/AbstractTest.php b/test/Helper/Navigation/AbstractTest.php
+index 693e965..874e581 100644
+--- a/test/Helper/Navigation/AbstractTest.php
++++ b/test/Helper/Navigation/AbstractTest.php
+@@ -23,14 +23,9 @@
+
+ /**
+ * Base class for navigation view helper tests
+- *
+- * @group Zend_View
+- * @group Zend_View_Helper
+ */
+ abstract class AbstractTest extends \PHPUnit_Framework_TestCase
+ {
+- const REGISTRY_KEY = 'Zend_Navigation';
+-
+ /**
+ * @var
+ */
+
diff --git a/php-zendframework-zend-view.spec b/php-zendframework-zend-view.spec
index df734b8..536f1ba 100644
--- a/php-zendframework-zend-view.spec
+++ b/php-zendframework-zend-view.spec
@@ -21,7 +21,7 @@
Name: php-%{gh_owner}-%{gh_project}
Version: 2.6.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Zend Framework %{library} component
Group: Development/Libraries
@@ -30,6 +30,8 @@ URL: http://framework.zend.com/
Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz
Source1: makesrc.sh
+Patch0: %{name}-pr55.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
# Tests
@@ -155,6 +157,8 @@ substitution, and more.
%prep
%setup -q -n %{gh_project}-%{gh_commit}
+%patch0 -p1
+
%build
# Empty build section, nothing required
@@ -206,7 +210,11 @@ rm -rf %{buildroot}
%changelog
-* Tue Mar 3 2016 Remi Collet <remi@fedoraproject.org> - 2.6.4-1
+* Mon Mar 21 2016 Remi Collet <remi@fedoraproject.org> - 2.6.4-2
+- add patch for zend-navigation issue, see:
+ https://github.com/zendframework/zend-navigation/issues/23
+
+* Thu Mar 3 2016 Remi Collet <remi@fedoraproject.org> - 2.6.4-1
- version 2.6.4
* Tue Feb 23 2016 Remi Collet <remi@fedoraproject.org> - 2.6.3-1