Bug in Navigation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in Navigation

rwrz
Hello!

I found this bug on Navigation, function "findHelper"

Actually:
        $helper    = $plugins->get($proxy);
        $container = $this->getContainer();
        $hash      = spl_object_hash($container);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }

Fixed:
        $helper    = $plugins->get($proxy);
        //$container = $this->getContainer();
        $hash      = spl_object_hash($helper);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }


Problem:
Actually, the hash calculated is from CONTAINER, so when Navigation try to check if a Helper have an injected container, it is actually checking if a CONTAINER is injected in any helper.
So when we try to use 2 Navigation helpers, like, MENU and BREADCRUMPS, it broke! The second will be "injected", but actually is isnt.

Sorry about the english!

Cya
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Navigation

Frank Brückner
Hi Rodrigo,
you are right! This is issue needs some more unit tests.
Thanks, I will look into this.


Kind regards,
Frank

Am 21.02.2013, 18:57 Uhr, schrieb Rodrigo Picinin - RWRZ  
<[hidden email]>:

> Hello!
>
> I found this bug on Navigation, function "findHelper"
>
> Actually:
>        $helper    = $plugins->get($proxy);
>
>        $container = $this->getContainer();
>        $hash      = spl_object_hash($container);
>
>        if (!isset($this->injected[$hash])) {
>            $helper->setContainer();
>
>            $this->inject($helper);
>            $this->injected[$hash] = true;
>        }
>
> Fixed:
>        $helper    = $plugins->get($proxy);
>
>        //$container = $this->getContainer();
>        $hash      = spl_object_hash($helper);
>
>        if (!isset($this->injected[$hash])) {
>            $helper->setContainer();
>
>            $this->inject($helper);
>            $this->injected[$hash] = true;
>        }
>
>
> Problem:
> Actually, the hash calculated is from CONTAINER, so when Navigation try  
> to check if a Helper have an injected container, it is >actually  
> checking if a CONTAINER is injected in any helper.
>
> So when we try to use 2 Navigation helpers, like, MENU and BREADCRUMPS,  
> it broke! The second will be "injected", but actually is >isnt.
>
> Sorry about the english!
>
>
> Cya
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Navigation

Marco Pivetta
In reply to this post by rwrz
Heya!

If it is a bug, then please report it on https://github.com/zendframework/zf2/issues :)



On 21 February 2013 18:57, Rodrigo Picinin - RWRZ <[hidden email]> wrote:
Hello!

I found this bug on Navigation, function "findHelper"

Actually:
        $helper    = $plugins->get($proxy);
        $container = $this->getContainer();
        $hash      = spl_object_hash($container);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }

Fixed:
        $helper    = $plugins->get($proxy);
        //$container = $this->getContainer();
        $hash      = spl_object_hash($helper);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }


Problem:
Actually, the hash calculated is from CONTAINER, so when Navigation try to check if a Helper have an injected container, it is actually checking if a CONTAINER is injected in any helper.
So when we try to use 2 Navigation helpers, like, MENU and BREADCRUMPS, it broke! The second will be "injected", but actually is isnt.

Sorry about the english!

Cya

Reply | Threaded
Open this post in threaded view
|

Re: Bug in Navigation

Frank Brückner
In reply to this post by rwrz
Pull request: https://github.com/zendframework/zf2/pull/3859

Am 21.02.2013, 18:57 Uhr, schrieb Rodrigo Picinin - RWRZ  
<[hidden email]>:

> Hello!
>
> I found this bug on Navigation, function "findHelper"
>
> Actually:
>        $helper    = $plugins->get($proxy);
>
>        $container = $this->getContainer();
>        $hash      = spl_object_hash($container);
>
>        if (!isset($this->injected[$hash])) {
>            $helper->setContainer();
>
>            $this->inject($helper);
>            $this->injected[$hash] = true;
>        }
>
> Fixed:
>        $helper    = $plugins->get($proxy);
>
>        //$container = $this->getContainer();
>        $hash      = spl_object_hash($helper);
>
>        if (!isset($this->injected[$hash])) {
>            $helper->setContainer();
>
>            $this->inject($helper);
>            $this->injected[$hash] = true;
>        }
>
>
> Problem:
> Actually, the hash calculated is from CONTAINER, so when Navigation try  
> to check if a Helper have an injected container, it is >actually  
> checking if a CONTAINER is injected in any helper.
>
> So when we try to use 2 Navigation helpers, like, MENU and BREADCRUMPS,  
> it broke! The second will be "injected", but actually is isnt.
>
> Sorry about the english!
>
>
> Cya
Reply | Threaded
Open this post in threaded view
|

Re: Bug in Navigation

cmple
This post has NOT been accepted by the mailing list yet.
In reply to this post by rwrz
rwrz wrote
Hello!

I found this bug on Navigation, function "findHelper"

Actually:
        $helper    = $plugins->get($proxy);
        $container = $this->getContainer();
        $hash      = spl_object_hash($container);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }

Fixed:
        $helper    = $plugins->get($proxy);
        //$container = $this->getContainer();
        $hash      = spl_object_hash($helper);

        if (!isset($this->injected[$hash])) {
            $helper->setContainer();
            $this->inject($helper);
            $this->injected[$hash] = true;
        }


Problem:
Actually, the hash calculated is from CONTAINER, so when Navigation try to
check if a Helper have an injected container, it is actually checking if a
CONTAINER is injected in any helper.
So when we try to use 2 Navigation helpers, like, MENU and BREADCRUMPS, it
broke! The second will be "injected", but actually is isnt.

Sorry about the english!

Cya
I have the same issue when rendering menu & breadcrumbs at the same time in zf-2.1.3

Thanks!
Roman.