Errata (Second Edition)

This page lists the errors found in the book.

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 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 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)

Chapter 15. Caching, Page 360

Location on the page: 
Just after Caching Data with cache_set()
Chapter: 
15. Caching
Error: 

cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = null)

Correction: 

cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = null)

Description of the Error: 

The order of the second and third parameters are switched.

Chapter 15. Caching, Page 361

Location on the page: 
Code example at top (from filter.module)
Chapter: 
15. Caching
Error: 

cache_set($cid, 'cache_filter', $text, time() + (60 * 60 * 24));

Correction: 

cache_set($cid, $text, 'cache_filter', time() + (60 * 60 * 24));

Description of the Error: 

Order of second and third parameters are switched.

Chapter 16. Sessions, Page 365

Location on the page: 
Section "What Are Sessions?", 1st paragraph
Chapter: 
16. Sessions
Error: 

... PHP issues the browser a cookie containing a randomly generated 32-character ID, called PHPSESSID by default.

Correction: 

... PHP issues the browser a cookie containing a randomly generated 32-character ID. The name of the cookie is a 36-character string such as SESS41847725f5e919b45880017743781461 (which is the cookie name for this site). The apparently random 32-character ID that follows SESS is actually an MD5 hash based on the base URL of the site, or on the cookie domain if set in settings.php.

The examples of HTTP response and request headers also show the cookie name to be PHPSESSID, where it should be of the form described above.