Múltiples acciones desencadenadas desde navigation.xml

We have a strange issue with the navigation xml, here's a snippet:

...
<registration>
      <label>Registration</label>
      <module>mine</module>
      <controller>registration</controller>
      <pages>
          <register>
             <label>Register</label>
             <module>mine</module>
             <controller>registration</controller>
             <action>doregistration</action>
           </register>
      </pages>
</registration>
...

Every time we call the /mine/registration/index action, the /mine/registration/doregistration action gets triggered afterwards (when debugging it can take a second or two)

The /mine/registration/index does get displayed correctly.

This problem occurs throughout the whole application. When we change the action of the second (or sub-) page, this particular action is executed.

Is this a known issue in Zend? Has anyone had this problem before?

preguntado el 03 de mayo de 12 a las 09:05

This is a really difficult question to answer, it could be a number of things. If its happening after the page loads successfully then I'd suggest looking at your javascript. Your not calling on other actions from within your view scripts by any chance? -

We aren't calling the action, nowhere. In fact we did a project search on the name of the action, and we found almost nothing, except the occurrence in the navigation xml. That's how we found that the xml is somehow involved. When we run the application without javascript (disabled in firefox) we get the same behavior. -

2 Respuestas

Maybe that this example, from the same application, with the same problem, makes things more clear:

En los navigation.xml:

...
<over>
    <label>Over ons</label>
    <module>default</module>
    <controller>over</controller>
    <action>index</action>
    <pages>
        <wat>
            <label>Wat?</label>
            <module>default</module>
            <controller>over</controller>
            <action>wat</action>
        </wat>
        <wie>
            <label>Wie?</label>
            <module>default</module>
            <controller>over</controller>
            <action>wie</action>
        </wie>
        <contact>
            <label>Contact</label>
            <module>default</module>
            <controller>over</controller>
            <action>contact</action>
        </contact>
        <faq>
            <label>Help</label>
            <module>default</module>
            <controller>over</controller>
            <action>faq</action>
        </faq>
    </pages>
</over>
...

El correspondiente OverController Se ve como esto:

class Default_OverController extends Custom_Controller_Action_EhcAction
{

public function indexAction()
{
    return $this->render('index');
}

public function contactAction()
{
    return $this->render('contact');
}

public function wieAction()
{
    return $this->render('wie');
}

public function watAction()
{
    return $this->render('wat');
}

public function faqAction()
{
    return $this->render('faq');
}
}

As you can see our Controllers extend the Custom_Controller_Action_EhcAction. This is a custom class that extends the Zend_Controller_Action and adds some extra functionality (logging, identity of the logged in user, ...). This custom class can't be the cause of our problem, it still occurs if we don't use is.

In this example, if we go to the default/over/wat action, the application will also call the following node default/over/wie. If we switch places in the XML, it turns out that the second call always is the following or first underlying node.

We don't think theirs a JavaScript call, because if we check our traffic with Charles, there's only one call being dispatched.

The view scripts of this example only contain simple HTML, no PHP or JS whatsoever...

Hopefully this will make our problem more clear...

contestado el 03 de mayo de 12 a las 20:05

Aha! We found the cause of the problem: the links navigation helper http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation.links

We still have no real solution for this, but those head links aren't that important. We don't use it anymore.

contestado el 04 de mayo de 12 a las 09:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.