14
Drupal 7 development: first impressions Dennis Povshedny, madcap.nl

Drupal 7 development: first impressions

Embed Size (px)

Citation preview

Page 1: Drupal 7 development: first impressions

Drupal 7 development: first impressions

Dennis Povshedny, madcap.nl

Page 2: Drupal 7 development: first impressions

Minor stuff

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

Page 3: Drupal 7 development: first impressions

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)

Page 4: Drupal 7 development: first impressions

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

Page 5: Drupal 7 development: first impressions

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

Page 6: Drupal 7 development: first impressions

D6 way

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

Page 7: Drupal 7 development: first impressions

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);

Page 8: Drupal 7 development: first impressions

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) . ')');

Page 9: Drupal 7 development: first impressions

DB: guard pattern

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

Page 10: Drupal 7 development: first impressions

Beautiful doc for deal withDB hell

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

Page 11: Drupal 7 development: first impressions
Page 12: Drupal 7 development: first impressions

How stable is UNSTABLE?

Now we use UNSTABLE 9even node_ tables has changed recently

Shall I start or wait?

Page 13: Drupal 7 development: first impressions

Other good practices

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

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

...

Page 14: Drupal 7 development: first impressions

Thank you!

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