Errata (First Edition)

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

Chapter 6. Working with Users, Page 66

Location on the page: 
bottom
Error: 

hook_user($op, &$edit, &$user, $category = NULL)

Correction: 

hook_user($op, &$edit, &$account, $category = NULL)

Description of the Error: 

The given signature of the hook_user() function uses argument name $user, while http://api.drupal.org/api/5/function/hook_user uses $account, which leads to less confusion with the global $user variable of the currently logged in user. This could also eliminate the caution paragraph on page 67. On further pages (e.g. in first code block on page 68, legalagree_user() function on page 69) $user is also used, while $account could be safer. Sidenote: on page 73 in function loginhistory_user() $account is used like suggested.

Chapter 6. Working with Users, Page 66

Location on the page: 
Testing If A User is Logged In
Error: 

This heading and subsequent text is inaccurate and misleading.

Correction: 

Change the heading and explanatory text to
Testing If a User is an Anonymous or Authenticated User

Description of the Error: 

If $user->uid is 0 it indicates an anonymous user; if it is not 0 then it indicates an authenticated or registered user. An authenticated user will be given a uid which is the primary key into the users table. I cannot find any field that will provide accurate information on whether a user is currently logged on or not. The user->login field will have a timestamp but that only indicates the time of last login, not the current logged in state.

[You are thinking about this too hard. During a request, the global $user variable will have uid->0 if the current user is anonymous (i.e., not logged in). That's all we're testing. I probably should have stated that the test is during the request. -JV]

Chapter 6. Working with Users, Page 68

Location on the page: 
Last code example
Error: 

function hide_profile_alter(&$account, &$fields) {

Correction: 

function blog_profile_alter(&$account, &$fields) {

Description of the Error: 

Change hide_profile_alter to blog_profile_alter. Since we are nominally working with the blog module, the hook_profile_alter() should reflect this.

[No! By implication we are working with the hide.module. We do not tromp on core module namespaces. -JV]

Chapter 6. Working with Users, Page 70

Location on the page: 
In figure 6-2
Error: 

...smash your belongs with a ball-peen hammer

Correction: 

...smash your belongings with a ball-peen hammer

Description of the Error: 

Typo.

Chapter 7. Working with Nodes, Page 86

Location on the page: 
Last Paragraph and just above
Error: 

I do not know enough to determine whether it is an error. But you tell us to refer to Chapter 2 for "more information on creating .install files" where on pg. 11 you tell us that custom modules reside in the "sites/all/modules" subdirectory, however on pg. 86 you say to put the joke module in the "sites/all/modules/custom" directory. I do not know if one is an error and the other is not or if there is some basis for putting joke inside "custom" and leaving "annotate" one level above. Is this something to do with implementing a node, is it an alternative?

Correction: 

Again, the author must use his expertise to decide: If it is an error I would imagine that you either use the custom directory both places or you don't use the custom directory both places, or the author can include a sentence or two explaining the decision to do it differently on the two pages.

Description of the Error: 

It is an unexplained inconsistency in directions for creating a module that *may* be an error.

Chapter 7. Working with Nodes, Page 86

Location on the page: 
Last sentence in Creating a Node Module section
Error: 

Start by creating a folder a named

Correction: 

Start by creating a folder named

Description of the Error: 

Typo.

Chapter 7. Working with Nodes, Page 87

Location on the page: 
code listing, pgsql part
Error: 

nid int unsigned ...
vid int unsigned ...

Correction: 

nid int_unsigned ...
vid int_unsigned ...

Description of the Error: 

I'm not familiar with pgsql, but in all .install files i've looked into i've only found "int_unsigned" as pgsql counterpart of the mysql "int unsigned" definitions.

Chapter 7. Working with Nodes, Page 93

Location on the page: 
3rd Paragraph
Error: 

This hook is only called for the current node type. For example, if the node type is joke, then joke_insert() would be called. If a new node of type book were added, joke_insert() would not be called (book_insert() would be called instead).

Correction: 

This hook is only called for the current module type. ...

Description of the Error: 

The information in this para is misleading, because it's ambiguous in its distinction between node and module namespaces. For example if a new node of type book were added to the joke module, joke_insert() would be called for the book node type.

Chapter 7. Working with Nodes, Page 97

Location on the page: 
Within the "node-joke-tpl.php" template.
Error: 

The markup doesn't validate:

  • There is an extra closing </legend> tag.
  • check_markup() shouldn't be used in a label element. (A paragraph element is not valid here).
Correction: 
  • Remove the stray </legend> tag.
  • Change "check_markup($node->punchline)" to "$node->punchline".
Description of the Error: 

Invalid XHTML.

Chapter 7. Working with Nodes, Page 104

Location on the page: 
Figure 7-5
Error: 

At the top left, the path from the diamond containing "user allowed to access this input format?" to the rectangle containing "Disallowed" is not labelled.

Correction: 

Add a label of "No" to this path.

Description of the Error: 

Small omission.