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


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


$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:

// 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