Issues

ZF-2204: wrong stacking of plugins.

Issue Type: Improvement Created: 2007-11-14T17:26:33.000+0000 Last Updated: 2009-01-10T10:50:11.000+0000 Status: Postponed Fix version(s): - Next Major Release ()

Reporter: Alan Gabriel Bem (alan.bem) Assignee: Ralph Schindler (ralph) Tags: - Zend_Controller

Related issues: Attachments: - Broker.php.diff

Description

It's description of Matthew Weier O'Phinney: "Let's say you have 3 plugins, one registered with no stackIndex, one with a stackIndex of 99, and another with one of 50. If you register another, it will get a stackIndex of 3, when it should get a stackIndex of 1. "

<pre class="highlight">
    public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin, $stackIndex = null)
    {
        //code
        } else {
            $stackIndex = count($this->_plugins); // why?
            while (isset($this->_plugins[$stackIndex])) {
                ++$stackIndex;
            }
            $this->_plugins[$stackIndex] = $plugin;
        }
        //code
    }

Comments

Posted by Matthew Weier O'Phinney (matthew) on 2007-11-16T14:52:14.000+0000

Scheduling for 1.0.3

Posted by Matthew Weier O'Phinney (matthew) on 2007-11-26T15:49:13.000+0000

Postponing to 1.1.0. Right now, I can't figure out a way to do stack ordering that's (a) easily user manipulable (b) maintains reasonable internal index order when indices are automatically generated, and (c) retains backwards compatibility. When I can sit down with the code and ensure (c) in particular can be met, while meeting (a) and (b), we can proceed -- and that will need to wait for 1.1.0.

Posted by Jordan Ryan Moore (jordanryanmoore) on 2007-12-17T12:44:55.000+0000

Attaching patch that fixes this bug.

Posted by Wil Sinclair (wil) on 2008-04-18T13:12:01.000+0000

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Posted by Ralph Schindler (ralph) on 2008-04-22T10:38:29.000+0000

Updating project management info.

Posted by Matthew Weier O'Phinney (matthew) on 2008-11-05T08:23:02.000+0000

Assigning to Ralph.

Posted by Ralph Schindler (ralph) on 2009-01-10T10:50:10.000+0000

This actually works very similar to how php would increment stack index. Notice:

<pre class="highlight">
~/tmp$ cat php-array-indexes.php 
<?php

$stack = array();
$stack[-99] = 'foo';
$stack[-50] = 'bar';
$stack[] = 'baz';

var_dump($stack);

$stack[50] = 'bar2';
$stack[] = 'baz2';

var_dump($stack);
~/tmp$ php php-array-indexes.php 
array(3) {
  [-99]=>
  string(3) "foo"
  [-50]=>
  string(3) "bar"
  [0]=>
  string(3) "baz"
}
array(5) {
  [-99]=>
  string(3) "foo"
  [-50]=>
  string(3) "bar"
  [0]=>
  string(3) "baz"
  [50]=>
  string(4) "bar2"
  [51]=>
  string(4) "baz2"
}

In our case, the next number represents both the next available positive index AS WELL as the number (if none was provided) of the plugin that was pushed onto the stack. I think this behavior is correct. On the other hand, i think the actual index and top/bottom of the stack might need to be re-evaluated.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts