Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix merging of identifiers for Zend\EventManager #1955

merged 3 commits into from

3 participants


The + operator does not work in this context of strings, because the new array has a key of 0. The + operator therefore does not merge the array($stringValue) with the original identifiers.

Tests are created, code is modified to pass the tests again.


This pull request fails (merged c33ee80 into 8d498ef).

@juriansluiman juriansluiman reopened this

This pull request fails (merged c33ee80 into 8d498ef).

@juriansluiman juriansluiman reopened this

I stop opening/closing this PR. Locally I tested the tests from Zend\EventManager (and they pass), but tests from Zend\Form, Zend\Captcha, Zend\Barcode all fail due to some missing services. I think the recent changes to move services to their own repo caused these errors.

If I need to rebase my PR later when master is fixed, I'll do.


This pull request fails (merged c33ee80 into 8d498ef).

@weierophinney weierophinney merged commit c33ee80 into zendframework:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 23, 2012
  1. @juriansluiman

    Create tests to address bug in adding identifiers

    juriansluiman authored
    When new identifiers are added, some get lost and are not appended
    to the list of identifiers.
  2. @juriansluiman
  3. @juriansluiman
This page is out of date. Refresh to see the latest.
2  library/Zend/EventManager/EventManager.php
@@ -148,7 +148,7 @@ public function addIdentifiers($identifiers)
if (is_array($identifiers) || $identifiers instanceof \Traversable) {
$this->identifiers = array_unique($this->identifiers + (array) $identifiers);
} elseif ($identifiers !== null) {
- $this->identifiers = array_unique($this->identifiers + array($identifiers));
+ $this->identifiers = array_unique(array_merge($this->identifiers, array($identifiers)));
return $this;
12 tests/Zend/EventManager/EventManagerTest.php
@@ -550,6 +550,18 @@ public function testDuplicateIdentifiersAreNotRegistered()
$this->assertSame($identifiers[0], __CLASS__);
+ public function testIdentifierGetterSettersWorkWithStrings()
+ {
+ $identifier1 = 'foo';
+ $identifiers = array($identifier1);
+ $this->assertInstanceOf('Zend\EventManager\EventManager', $this->events->setIdentifiers($identifier1));
+ $this->assertSame($this->events->getIdentifiers(), $identifiers);
+ $identifier2 = 'baz';
+ $identifiers = array($identifier1, $identifier2);
+ $this->assertInstanceOf('Zend\EventManager\EventManager', $this->events->addIdentifiers($identifier2));
+ $this->assertSame($this->events->getIdentifiers(), $identifiers);
+ }
public function testIdentifierGetterSettersWorkWithArrays()
$identifiers = array('foo', 'bar');
Something went wrong with that request. Please try again.