Drupal CVS reviews

Posts made in this category are based on real reviews made of modules offered as Drupal Contrib modules during the CVS application review process.

Getting to know your friendly neighbourhood Drupal API

A recent application was decline basically because Drupal's database API was just non-existent/not used/badly used. This was pointed out to the applicant and asked to read up on how to get things done properly using Drupal's APIs.

On the second attempt this is an example of swinging just the wrong way and "not getting it"...

  1.   $res = db_query("SELECT id FROM {foo} WHERE url = '%s'",
  2.     db_escape_string($info['bar']));



Spot the difference

This cracker came in recently, can you spot the difference? Which is right and which is wrong?

  1.   db_query("DELETE FROM {$node->type} WHERE vid = %d", $node->vid);
  2.   db_query("DELETE FROM {foo_bar_baz} WHERE vid = %d", $node->vid);

Got it yet? You may have easily spotted the first one was wrong but did you get why it's wrong? It's bad on more levels than you may at first think.



Make sure your modules actually work before applying

Here's a snippet from a recent application...

  1. /**
  2.  * Implementation of hook_menu().
  3.  */
  4. function foo_menu($may_cache) {
  5.   $items = array<();
  6.   if ($may_cache) {
  7.     $items[] = array<(
  8.       'path' => 'admin/settings/foo',
  9.       'title' => t('Foo settings'),
  10.       'callback' => 'system_admin_menu_block',
  11.       'position' => 'right',
  12.       'description' => 'Define Foo Module Settings',
  13.       'acces' => user_access('Access Foo Module'),
  14.     );
  15.  
  16.     $items[] = array<(
  17.       'title' => t('Foo Page'),
  18.       'path' => 'foo_video',
  19.       'callback' => 'foo_page',
  20.       'access' => TRUE,
  21.     );
  22.   }
  23. }



Syndicate content