Errata (Second Edition)

This page lists the errors found in the book.

Chapter 2. Writing a Module, Page 30

Location on the page: 
n/a
Chapter: 
2. Writing a Module
Error: 

After creating new variables ('annotate_limit_per_node' and 'annotate_deletion') the .install file should be updated to delete those variables on uninstall.

Correction: 

Either instructions on what to add to annotate.install or just a brief note to remind the reader to do so would be helpful.

Chapter 2. Writing a Module, Page 34

Location on the page: 
Further Steps
Chapter: 
2. Writing a Module
Error: 

Include "annotate.admin.inc" in listing of files in the annotate directory.

Chapter 3. Hooks, Actions, and Triggers, Page 36

Location on the page: 
4th chunk of example code at bottom of page
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

function hook_nodeapi(&$node, $op, $a3=NULL, $a4=NULL) {

Correction: 

function beep_nodeapi(&$node, $op, $a3=NULL, $a4=NULL) {

Description of the Error: 

The function name should be "beep_nodeapi" rather than "hook_nodeapi". The hook itself is named hook_nodeapi(). The hooked version for the module needs to be name [module name]_nodeapi().

Chapter 3. Hooks, Actions, and Triggers, Page 41

Location on the page: 
third paragraph
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

Not strictly an error, but definitely a gotcha for the unwary user. The book says: If you've done everything correctly, your action should be available in the user interface [...] Some users of Drupal 6.6 (and possibly other versions) may find this misleading and waste time looking for errors in their code, which may not be there or, at any rate, not have anything to do with the observed effect of the actions not becoming available.

Correction: 

State that you may have to click on admin/settings/actions in order for your changes to be reflected on the admin/build/trigger page.

Description of the Error: 

I've left the path of strict and verbatim obedience to the book's prescription, and defined the actions in a module that had already been installed. The actions didn't show up in the user interface. In Drupal 6.6, which is what I'm using, you have to click on admin/settings/actions in order for the actions to be registered in the actions table, whence they are retrieved to be displayed in the dropdown menus on admin/build/trigger.

Chapter 3. Hooks, Actions, and Triggers, Page 41

Location on the page: 
2nd paragraph
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

If you've done everything correctly, your action should be available

Correction: 

If you've done everything correctly and enabled the Beep module, your action should be available

Description of the Error: 

Minor suggestion: a reminder to enable the Beep module would be helpful.

Chapter 3. Hooks, Actions, and Triggers, Page 47

Location on the page: 
near the top
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

for ($i=1; $i < $context['beeps']; $i++)

Correction: 

($i=0; ...)

Description of the Error: 

In my paper copy and the electronic version that I just downloaded (30 Jan 09) from the APress Website, the code in wrong near the top of page 47. Off by one error. Loop will terminate early. The problem does not exist in the downloadable code.

Chapter 3. Hooks, Actions, and Triggers, Page 48

Location on the page: 
bottom
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

array_merge($info['user_block_user_action']['hooks']['comment'], array('insert'));

Correction: 

array_unique(array_merge($info['user_block_user_action']['hooks']['comment'], array('insert')));

Description of the Error: 

array_merge() appends values instead of combining them when keys are numeric, as they are implicitly in the above array.

Chapter 3. Hooks, Actions, and Triggers, Page 48

Location on the page: 
Heading half way down page
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

Changing Existing Actions with drupal_alter

Correction: 

Changing Existing Actions with hook_action_info_alter

Description of the Error: 

drupal_alter is a generic dispatching mechanism used for many hooks. That it is used to dispatch hook_action_info_alter is an irrelevant and confusing implementation detail. (Note: the same error should be corrected in the comment for the code example beneath the heading.)

Chapter 3. Hooks, Actions, and Triggers, Page 53

Location on the page: 
Block of code after 1st paragraph
Chapter: 
3. Hooks, Actions, and Triggers
Error: 

"Beep multiple times" callback function as in the table description is printed in book as "beep_beep_action".

Correction: 

Should be:
callback: 'beep_multiple_beep_action'

Description of the Error: 

Point is made clear -- just a small oversight on what the callback function of the configurable function 'beep_multiple_beep_action' is as opposed to the chapters non-configurable counterpart, 'beep_beep_action'.

Chapter 4. The Menu System, Page 70

Location on the page: 
bottom
Chapter: 
4. The Menu System
Error: 

'page callback' => 'menufun_goodbye',

Correction: 

'page callback' => 'menufun_goodbye',
'access arguments' => array('receive greeting'),

Description of the Error: 

The code relies on the inheritance of menu access callbacks. During the writing of the book, Drupal changed to no longer do inheritance so access arguments must be declared explicitly (see "Note for Module Developers" here). The code example slipped through final technical review of the book.