ZF-7594: Fatal error: Call to a member function getHeader()


Using the Zend_Rest_Route throws fatal error PHP Fatal error: Call to a member function getHeader() on a non-object in ...\Zend\Rest\Route.php on line 165

i commented this part out to get the rest working

      } elseif ( $this->_request->getHeader('X-HTTP-Method-Override') ) {
      $values[$this->_actionKey] = strtolower($this->_request->getHeader('X-HTTP-Method-Override'));

The problem remains under php 5.2.10 under Windows XP Apache 2.2 as module.

(Info: inside creating issues the component selector does not show all components, so i decided to chose unknown)


Set component and change assinee

Can you show me the setup code you used to construct the Route object? I need a way to duplicate the issue with a test so I can fix it reliably.

Thanks, -L

I'm using the Zend_Application with my own run method inside the Bootstrap adding the Zend_Rest_Route for my test controller 'member' inside the default module:

public function run() { $front = $this->getResource('FrontController'); $default = $front->getDefaultModule(); if (null === $front->getControllerDirectory($default)) { throw new Zend_Application_Bootstrap_Exception( 'No default controller directory registered with front controller' ); }

    try {        
        $front = Zend_Controller_Front::getInstance();
    $restRoute = new Zend_Rest_Route($front, array(), array(
            'default' => array('member')
   $front->getRouter()->addRoute('rest', $restRoute);

        $front->setParam('bootstrap', $this)    

    } catch (Exception $e) {
        echo $e->getMessage();

This is the $request object from inside Zend_Rest_Route->match($request)

Fixed in trunk and 1.9 release branch.

Thanks MWO. Did we need a test case for it? I had the same fix ready to go but had trouble reproducing in a test case. :(