ZF-10756: ContextSwitch::initContext('default') overwrites format-parameter

Issue Type: Bug Created: 2010-11-29T02:11:11.000+0000 Last Updated: 2012-11-20T21:38:14.000+0000 Status: Open Fix version(s): Reporter: Marcus Häußler (testvogel) Assignee: None Tags: - Zend_Controller

Related issues: Attachments:


Hi, in my opinion the default parameter you can set to ContextSwitch::initContext($format) should not overwrite any given format-parameter by URL.


<pre class="literal">
$contextSwitch = $this->_helper->contextSwitch;
$contextSwitch->addContext('excel', array('suffix'  => 'excel'));
$contextSwitch->addContext('csv', array('suffix'  => 'csv'));

$contextSwitch->addActionContext('myAction', 'csv') // excel is not allowed

If the url <> is called, I would expect that the my-action.csv.phtml is rendered. Instead the my-action.excel.phtml is rendered (if it exists), although the excel-context is not allowed to this action and the given format is csv.

The problem is in ContextSwitch line 270:

<pre class="literal">
// Use provided format if passed
if (!empty($format) && $this->hasContext($format)) {
    $context = $format;

If a default format is given ('excel' in my example), it will be used allways!

I think the block can be deleted, cause the default format is already set in line 252, when no format is specified by url.


No comments to display

Have you found an issue?

See the Overview section for more details.


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

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