Developing software in the Real World

Zend Framework in Action Errata

Note that ZFiA was written for version 1.5 of Zend Framework. If you are using version 1.8 or later, then please read this article on Zend Loader.

This is a list of issues that we are aware of:

Chapter 2

  • On page 18, the right hand bracket in the first paragraph is not needed.
  • On page 38, in the last code block, the first line of the method should be:
    $cutOff = date('Y-m-d', strtotime('-3 months'));

Chapter 3

  • On page 58, listing3.7 the declaration of static public $bootstrap; is missing from the top of the class declaration
  • On page 61, listing 3.10, the call to fetchLatest() should be:
    $this->view->places = $placesFinder->fetchLatest();
  • On page 62, in the line asserting the h2 content, it should read:
    $this->assertQueryContentContains('h2', 'Recent places');

Chapter 4

  • On page 67, listing 4.1, the call to startMvc() must be before the call to dispatch().
  • On page 69, the ViewSetup plugin should be registered in position 98:
    $frontController->registerPlugin(
        new Places_Controller_Plugin_ViewSetup(), 98); 

    Related to this, on page 73, the ActionSetup plugin should not be in position 98 and should read:

    $frontController->registerPlugin( 
        new Places_Controller_Plugin_ActionSetup());
    

    This text at the very bottom of page 73 applies to the ViewSetup and so should read:

    Note that we want the ViewSetup’s postDispatch() hook to run after all other plug-
    ins except Zend_Layout, so we explicitly set the position of the plug-in to 98. We

    We don’t mention it in the book, but the reason we set to 98 is because in listing 4.7, we set up a postDispatch() hook in the ViewSetup plugin that we want to run once at the very end of the process. The ActionStack’s postDispatch() injects additional actions into the dispatch loop at position 97, so we have to use position 98 for ViewSetup as Zend_Layout’s postDispatch() at position 99 will render the final page, at which point it will be too late to change the headTitle().

  • On page 79 in the first paragraph, the action method name is advertAction().

Chapter 5

  • In section 5.5, the actions added to the ActionStack in the Places_Controller_Plugin_ActionSetup front controller plugin (listing 4.7) should be wrapped with an:
    if(!$request->isXmlHttpRequest()) { ..... }

    so that they don’t get called in response to an Ajax call.

  • Listing 5.8 on page 99 should have the following two lines of code within indexAction():
    $reviewsFinder = new Reviews();
    $this->view->reviews = $reviewsFinder->fetchByPlaceId($id)

Chapter 6

  • On page 122, the title for listing 6.12 should be: Unit tests for the Users model
  • On page 122, in listing 6.12 you need to add: $newUser->password = 'nick'; after $newUser->last_name = 'Lo';
  • On page 127, the text should read: Selecting the list of places that have reviews that been approved by a given user is done using

Chapter 7

  • On page 134, Listing 7.4 refers to a method _getFormData(). The source for this method is available within the source code download.
  • In Places_Controller_Action_Helper_Acl (listing 7.10, 7.11, 7.12), the line:
    $this->_controllerName = $controller;

    in listing 7.12’s preDispatch() method should be in listing 7.12’s init() method. This is because the use of the ActionStack results in preDispatch() being called multiple times with different controllers.

  • On page 144, in the paragraph above listing 7.12, it should say: “This is called automatically by the front controller and is where we check that the user has sufficient rights to continue.”

Chapter 8

  • On page 154, listing 8.5 should read:
    if ($this->_request->isPost()) { 
        if ($form->isValid( 
            $this->_request->getPost()) 
        )
    
  • On page 164, the first line of listing 8.15 should read:
    form div.loginDiv { width: 400px; }

Chapter 10

  • There is a missing comma in the code on page 207 after ‘example.com’. It should read:
        $mail = new Zend_Mail_Storage_Pop3(array('host' => 'example.com',
                     'user' => 'support',
                     'password' => 'support123')); 
    

Appendix C

  • On page 368, in the third paragraph of section C.1.1 Modules, the module’s controller classes are stored in the directory application/modules/{Module name}/controllers and so Pages_IndexController is stored in /application/modules/Pages/controllers/IndexController.php.
  • On page 379, Listing C.11 has a missing semicolon on the line:
    $msg = $i . ' - Query: "' . $query->getQuery();

If you find any others, please let us know at the Author Online forum.

One thought on “Zend Framework in Action Errata

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *