Errata (Second Edition)

This page lists the errors found in the book.

Chapter 10. The Form API, Page 248

Location on the page: 
First line of code in formwizard_multiform().
Chapter: 
10. The Form API
Error: 

$step = isset($form_state['values']) ? (int) $form_state['storage']['step'] : 0;

Correction: 

$step = isset($form_state['values']) ? (int) $form_state['storage']['step'] : 1;

Description of the Error: 

$step should be initialized to the same value as $form_state['storage']['step']. Because they are not synchronized, if the code is used as written the wizard will go through an extra step. (Fixed in downloadable code.)

Chapter 10. The Form API, Page 249

Location on the page: 
Halfway down
Chapter: 
10. The Form API
Error: 

function formwizard_multiform(&$form_state = NULL) {

Correction: 

function formwizard_multiform(&$form_state) {

Description of the Error: 

On PHP 4, the above will fail with PHP Parse error: parse error, unexpected '=', expecting ')' in /sites/all/modules/custom/formwizard/formwizard.module on line 34 because PHP 4 does not allow assignment of values to variables passed by reference.

Reported by Mike Volmar.

Chapter 10. The Form API, Page 264

Location on the page: 
List of properties just before Fieldset heading
Chapter: 
10. The Form API
Error: 

Properties commonly used with the file element are #attributes, #default_value, #description, #prefix, #required, #size...

Correction: 

Properties commonly used with the file element are #attributes, #default_value, #description, #prefix, #size...

Description of the Error: 

#required is not allowed on file elements. Try CCK or webform.

Chapter 12. Searching and Indexing Content, Page 304

Location on the page: 
implementation of hook_install() for legacysearch.module
Chapter: 
12. Searching and Indexing Content
Error: 

db_query("INSERT INTO technote VALUES ...

Correction: 

db_query("INSERT INTO {technote} VALUES ...

Description of the Error: 

You have to include '{' and '}' brackets, so the database engine can add table prefix (if needed) to the table name.

Chapter 12. Searching and Indexing Content, Page 306

Location on the page: 
listing of the legacysearch.module, legacy_update_shutdown()
Chapter: 
12. Searching and Indexing Content
Error: 

variable_set('legacysearch_cron_last', $last_change);

Correction: 

variable_set('legacysearch_cron_last_change', $last_change);

Description of the Error: 

On the listing of the legacysearch.module the variables
'legacysearch_cron_last_id' and 'legacysearch_cron_last_change' are pulled
out from the database using variable_get. Later in the code the
legacysearch_update_shutdown() function uses variable_set to store those
variables in the database and at this time they have names
'legacysearch_cron_last_id' which is correct and 'legacysearch_cron_last'
which should be 'legacysearch_cron_last_change'.

Chapter 12. Searching and Indexing Content, Page 307

Location on the page: 
listing of the legacysearch.module, Implementation of hook_search()
Chapter: 
12. Searching and Indexing Content
Error: 

variable_del('legacy_cron_last');

Correction: 

variable_del('legacy_cron_last_change');

Description of the Error: 

See description of error on page 306

Chapter 13. Working with Files, Page 314

Location on the page: 
Table 13-1
Chapter: 
13. Working with Files
Error: 

Flag indicating whether files is temporary (1) or permanent (0)

Correction: 

Flag indicating whether files is temporary (0) or permanent (1)

Description of the Error: 

Drupal's internal documentation had this backwards and it made it into the book. This is now fixed in Drupal 6 and 7. Thanks to Fran for the report.

Chapter 14. Working with Taxonomy, Page 337

Location on the page: 
code listing of _image_gallery_get_vid()
Chapter: 
14. Working with Taxonomy
Error: 

is_null(taxonomy_vocabulary_load($vid))

Correction: 

taxonomy_vocabulary_load($vid) === FALSE

Description of the Error: 

taxonomy_vocabulary_load($vid) does not return NULL when the vocabulary does not exists, but FALSE. see http://api.drupal.org/api/function/taxonomy_vocabulary_load/6

Chapter 14. Working with Taxonomy, Page 340

Location on the page: 
Source code prelast line
Chapter: 
14. Working with Taxonomy
Error: 

drupal_mail('taxonomymonitor-notify', $to, $subject, $body);

Correction: 

drupal_mail('taxonomymonitor', 'notice', '$to, $language, $params);
Plus a new function is needed, taxonomymonitor_mail(), as an implementation of hook_mail().

Description of the Error: 

The API of drupal_mail has changed. The code used in the book is for DRUPAL 5.

[Ulrich is correct. The module uses the old function signature. I swear I remember testing this module, though. I will update the downloadable code with the new version. -JV]

Chapter 15. Caching, Page 356

Location on the page: 
Figure 15.3
Chapter: 
15. Caching
Error: 

(DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE)

Correction: 

_drupal_bootstrap(DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE)