Drupal 7 development: first impressions

Preview:

Citation preview

Drupal 7 development: first impressions

Dennis Povshedny, madcap.nl

Minor stuff

Like different *.info files format (dependencies[])

API somewhere changed

As well as for D5 to D6 migration Versions

4.6 hook_form(&$node, &$param)

4.7 hook_form(&$node)

5 hook_form(&$node, $form_values)

6 hook_form(&$node, $form_state)

7 hook_form($node, $form_state)

Registry introduced

Two tables in DB to hold all registered functions

kind of OOP based on procedural platform

Rebuild registry regularly with clearing cache, like:- call drupal_flush_all_caches()- truncate all cache_* tables

DB is now object oriented, baby!

No more good old db_query; Use PDO (PHP Data Objects) instead; Looks like a hell at a first sight

D6 way

$entry = db_query('SELECT parent_nid FROM {ts_activity_hierarchy} WHERE ts_activity_hierarchy.nid = ' . $nid);

D7 way

$query = db_select('ts_activity_hierarchy'); $query->addField('ts_activity_hierarchy', 'parent_nid' ); $query->condition('ts_activity_hierarchy.nid', $nid); $result = $query->execute(); $entry = db_fetch_object($result);

Translate, please!

$num_revoked = db_delete('ts_activity_users') ->condition('activity_nid', $nid) ->condition('uid', $userid, 'IN') ->execute();

db_query('DELETE FROM {ts_activity_users} WHERE activity_nid=' . $nid . ' AND uid IN (' . implode(',', $userid) . ')');

DB: guard pattern

{ $guard = db_transaction(); ...}

Beautiful doc for deal withDB hell

http://drupal.kollm.org/doxygen/drupal-phpdoc/class_select_query.html

How stable is UNSTABLE?

Now we use UNSTABLE 9even node_ tables has changed recently

Shall I start or wait?

Other good practices

Write Doxygen - style comments; Enjoy pure PHP5 cause PHP4 is no

longer supported – feel free to use 'clone', etc

...

Thank you!

Questions and ideas – welcome! Drupal 7 – just try it! :)

Recommended