Errata (First Edition)

This page lists the errors found in the first edition of the book.

Chapter 2. Writing a Module, Page 15

Location on the page: 
sentance before figure 2-1
Error: 

Now navigating to Administer>Settings>Annotate

Correction: 

Now navigating to Administer>Site Configuration>Annotation Settings

Description of the Error: 

The navigation titles given are slightly off. I saw that the first typo (Site configuration) was caught earlier, but my site is also giving Annotate a different name; annotation settings.

Chapter 2. Writing a Module, Page 18

Location on the page: 
figure 2-2
Error: 

The data form (as shown in figure 2-2) does not appear

Correction: 

see description

Description of the Error: 

I know it may seem insignificant or blatantly obvious to some, but I think mentioning that the "page" and "story" check boxes as shown in figure 2-1 (pg.15) should be checked to make the data form appear would be helpful. I am a first time user of Drupal and the fact that my data table wasn't showing up had me perplexed (and triple checking my code against the book's) for a while. Part of the problem is I am working with a site a coworker (who is no longer available to talk to) made and they only have "story" content created on the site.

Chapter 2. Writing a Module, Page 19

Location on the page: 
in CREATE TABLE statements
Error: 

CREATE TABLE annotations

Correction: 

CREATE TABLE {annotations}

Description of the Error: 

The curly brackets necessary for Drupal's automatic table prefixing were omitted.

Chapter 2. Writing a Module, Page 19

Location on the page: 
1/3 and 1/2 way down
Error: 

This appears twice in code block (once for mySQL version, once for pgsql version):
db_query("CREATE TABLE annotations (

Correction: 

Users inputting their own code from the book should add brackets, as was previously reported by another poster. Authors should update the downloadable code.

Description of the Error: 

As mentioned, another poster previously reported that the brackets were missing in the book.
I'm reporting that this error still exists in the downloadable code for the chapter. (I don't know about the code for the whole book; I only downloaded the code for Chapter 2.)

Chapter 2. Writing a Module, Page 20

Location on the page: 
function annotate_entry_form_submit()
Error: 

db_query("DELETE FROM {annotations} WHERE uid = %d and nid = %d", $user->uid, $nid);

Correction: 

db_query("DELETE FROM {annotations} WHERE uid = %d AND nid = %d", $user->uid, $nid);

Description of the Error: 

AND not capitalized.

Chapter 2. Writing a Module, Page 21

Location on the page: 
Before "Further Steps" (2)
Error: 

DB is wasted too if a user is beeng deleted so you have also to catch an user-delete (please read first the following post from dshaw).

Correction: 

The following code does the job:
/**
* After Deleting User we have to delete all his annotations too
*/
function annotate_user($op,&$edit,&$user,$category=NULL) {
  switch ($op) {
  case 'delete':
    db_query("DELETE FROM {annotations} WHERE uid = %d", $user->uid);
    break;
  }
}

And here are some additional lines to complete the annotate_nodeapi with a "delete"-functionality (see post from dshaw):

function annotate_nodeapi(&$node,$op,$teaser,$page) {
  global $user; //move this to top
   ...
    break; //don't forget this break !
  case 'delete':
    // delete annotations from all Users of this node
    db_query("DELETE FROM {annotations} WHERE nid = %d", $node->nid);
    break;
  }
}

Description of the Error: 

Omission

Chapter 2. Writing a Module, Page 21

Location on the page: 
Before "Further Steps"
Error: 

If a node is deleted its annotation is not, leading to wasted space in the DB. Deletion is a key feature, so even though this is an introductory chapter on writing a module I think it should be included. This feature is dealt with fully in Chapter 7, so the treatment in Chapter 2 could be brief and refer to Chapter 7 for more info.

Correction: 

A short section on deleting the annotation for a node when a node is deleted.

Description of the Error: 

Omission

Chapter 3. Module-Specific Settings, Page 26

Location on the page: 
Last line of code
Error: 

'#default_value' => variable_get('annotate_deletion', 0) // default to Never

Correction: 

'#default_value' => variable_get('annotate_deletion', 0), // default to Never

Description of the Error: 

To adhere to Drupal coding standards, the last array element should be followed by a comma.

[That's true throughout the book. See my post here.]

Chapter 3. Module-Specific Settings, Page 26

Location on the page: 
Bottom code block
Error: 

t('After 30 days')

Correction: 

t('After 30 days'),

Description of the Error: 

To adhere to Drupal coding standards, the last array element should be followed by a comma.

[That's true throughout the book. See my post here.]

Chapter 3. Module-Specific Settings, Page 27

Location on the page: 
Top of page, end of $form code block
Error: 

'#size' => 3

Correction: 

'#size' => 3,

Description of the Error: 

To adhere to Drupal coding standards, the last array element should be followed by a comma.

[That's true throughout the book. See my post here.]