Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this


  1. 1. Drupal 7 development: first impressions <ul><li>Dennis Povshedny, </li></ul>
  2. 2. Minor stuff <ul><li>Like different *.info files format (dependencies[]) </li></ul>
  3. 3. API somewhere changed <ul><li>As well as for D5 to D6 migration </li></ul><ul><li>Versions </li></ul><ul><li>4.6 hook_form(&$node, &$param) </li></ul><ul><li>4.7 hook_form(&$node) </li></ul><ul><li>5 hook_form(&$node, $form_values) </li></ul><ul><li>6 hook_form(&$node, $form_state) </li></ul><ul><li>7 hook_form($node, $form_state) </li></ul>
  4. 4. Registry introduced <ul><li>Two tables in DB to hold all registered functions </li></ul><ul><li>kind of OOP based on procedural platform </li></ul><ul><li>Rebuild registry regularly with clearing cache, like: - call drupal_flush_all_caches() - truncate all cache_* tables </li></ul>
  5. 5. DB is now object oriented, baby! <ul><li>No more good old db_query; </li></ul><ul><li>Use PDO (PHP Data Objects) instead; </li></ul><ul><li>Looks like a hell at a first sight </li></ul>
  6. 6. D6 way <ul><li>$entry = db_query('SELECT parent_nid FROM {ts_activity_hierarchy} WHERE ts_activity_hierarchy.nid = ' . $nid); </li></ul>
  7. 7. D7 way <ul><li>$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); </li></ul>
  8. 8. Translate, please! <ul><li>$num_revoked = db_delete('ts_activity_users') ->condition('activity_nid', $nid) ->condition('uid', $userid, 'IN') ->execute(); </li></ul><ul><li>db_query('DELETE FROM {ts_activity_users} WHERE activity_nid=' . $nid . ' AND uid IN (' . implode(',', $userid) . ')'); </li></ul>
  9. 9. DB: guard pattern <ul><li>{ $guard = db_transaction(); ... } </li></ul>
  10. 10. Beautiful doc for deal with DB hell <ul><li> </li></ul>
  11. 12. How stable is UNSTABLE? <ul><li>Now we use UNSTABLE 9 even node_ tables has changed recently </li></ul><ul><li>Shall I start or wait? </li></ul>
  12. 13. Other good practices <ul><li>Write Doxygen - style comments; </li></ul><ul><li>Enjoy pure PHP5 cause PHP4 is no longer supported – feel free to use 'clone', etc </li></ul><ul><li>... </li></ul>
  13. 14. Thank you! <ul><li>Questions and ideas – welcome! </li></ul><ul><li>Drupal 7 – just try it! :) </li></ul>