Errata (First Edition)
This page lists the errors found in the first edition of the book.
Chapter 20. Writing Secure Code, Page 310
Fri, 07/27/2007 - 2:59pm — tfriedhofif (!in_array($type, node_get_types())) {
if (!in_array($type, array_values(node_get_types()))) {
The php function in_array() will not work the way it is written in the book. The php function checks the values of the array returned by node_get_types() and not the keys, which are what holds that names of the content types in the array returned from node_get_types(). The values of the arrays from node_get_types() are objects. The test suggested in the book will always fail unless you only get the keys, as suggested in the code correction I've submitted.
[The correction is incorrect. We should be getting the keys for comparison, not the values. It should probably be if (!in_array($type, array_keys(node_get_types('name')))) { ... } We would use the 'name' parameter to node_get_types() to avoid returning objects that we will just throw away; 'name' gets us just the internal node type name and its friendly name. -JV]
Chapter 20. Writing Secure Code, Page 311
Tue, 05/13/2008 - 11:02am — jvandyk$titles array_map($titles, 'check_plain');
$titles = array_map('check_plain', $titles);
Parameters for array_map() are reversed.
Chapter 20. Writing Secure Code, Page 314
Sun, 06/24/2007 - 9:13am — soxofaanno definition of $num
$num = 10; (or something)
there is no definition of the $num variable
Chapter 22. Optimizing Drupal, Page 354
Mon, 01/21/2008 - 1:57pm — Benjamin Melançonhttp://drupal.org/project/filesystem currently goes to "Page not found"
Not sure, as this probably worked when the book was written. Right now the closest approximate is:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/filesystem/
Broken link.
Chapter 23. Installation Profiles, Page 360
Wed, 06/20/2007 - 7:01am — Benjamin Melançon'help' module is listed both under "// Enable required core modules" (we assume this line is necessary) and "// Enable optional core modules"
According to the Drupal 5.1 modules administration page, help is an optional core module.
The list under "// Enable required core modules" should now read:
'block', 'filter', 'node', 'system', 'user', 'watchdog',
typo or copy-paste type of error
Chapter 23. Installation Profiles, Page 362
Wed, 06/20/2007 - 8:38am — Benjamin MelançonUse of t() instead of st()
(Contrary to note on page 363, "We use st() instead of t() throughout the installation profile to allow the entire installation profile translation, if any, to be stored in an installation profile translation file.")
Replace:
'name' => t('News Categories'),
with:
'name' => st('News Categories'),
typo
