Zend Framework

$_noController value overwritten due to a flaw in the logic...

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0.0, 1.0.1, 1.0.2
  • Fix Version/s: 1.0.3
  • Component/s: Zend_Controller
  • Labels:
    None

Description

If you have previously used setNoController function (of ViewRenderer Helper), to disable looking for the view in a sub-directory with the controller's name, in your actions controller, it will be over-written later due to a flaw.

public function init()
        {
                $this->_helper->viewRenderer->setRender('test');
                $this->_helper->viewRenderer->setNoController(true);
        }

This won't work, nor will it work using preDispatch(). The problem is on Zend/Controller/Action.php in this piece of code:

public function getViewScript($action = null, $noController = null)
    {
        if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
            $viewRenderer = $this->_helper->getHelper('viewRenderer');
            $viewRenderer->setNoController($noController);
            return $viewRenderer->getViewScript($action);
        }

$noController, a null value, is passed through setNoController function and the setNoController function assumes if the value isn't true, it's false. So null is considered false, and a value is set also it isn't supposed to.

I think either a test needs to be made in Actions.php or inside the setNoController function, for the null value.

Example in ViewRender helper:

if ($flag === null) {
            return;
        }

Or in Actions.php:

if ($noController !== null) {
            $viewRenderer->setNoController($noController);
	}

This caused me a major headache when I was trying to implement the code (which is pasted at beginning of the issue), and I had to use setNeverController() instead.

Activity

Hide
Thomas Weidner added a comment -

Assigned to Matthew

Show
Thomas Weidner added a comment - Assigned to Matthew
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for 1.0.3

Show
Matthew Weier O'Phinney added a comment - Scheduling for 1.0.3
Hide
Matthew Weier O'Phinney added a comment -

Fixed in both trunk and release branch as of r6877

Show
Matthew Weier O'Phinney added a comment - Fixed in both trunk and release branch as of r6877

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
15m
Original Estimate - 15 minutes
Remaining:
15m
Remaining Estimate - 15 minutes
Logged:
Not Specified
Time Spent - Not Specified