Drupal 7

16,102 views

Published on

Published in: Technology
  • Be the first to comment

Drupal 7

  1. 1. Drupal 7 Angela “webchick” Byron, Drupalcon DC March 4, 2009
  2. 2. About Me • Started Drupal in 2005 as Google Summer of Code student • Obsessed with everything Drupal (especially getting new people involved!) • Using Drupal co-author, Drupal Association board member, Drupal 7 maintainer • Work at Lullabot doing consulting and education
  3. 3. Agenda • What happens during release? • What’s done so far? • What’s in the future? • How can you help? • Questions?
  4. 4. http://flickr.com/photos/earthandeden/ Mom, where does Drupal come from? A tour of the Drupal release cycle.
  5. 5. Step 1: Release the current version!
  6. 6. Step 1: Release the current version! ! W NE Drupal 6
  7. 7. Step 1: Release the current version! ! W NE Drupal 6
  8. 8. Step 2: Open up next version for development Drupal 6
  9. 9. Step 2: Open up next version for development Drupal 6
  10. 10. Step 2: Open up next version for development Drupal 6
  11. 11. Step 2: Open up next version for development Drupal 6 Drupal 7 (HEAD)
  12. 12. Drupal 4.7 http://flickr.com/photos/shashchatter/
  13. 13. http://flickr.com/photos/shashchatter/ Drupal 4.7 Note: Drupal 5 retires when Drupal 7 is released.
  14. 14. Step 3: “Code thaw” http://flickr.com/photos/monikahoinkis/
  15. 15. http://flickr.com/photos/monikahoinkis/ Step 3: “Code thaw” Fix things that have always annoyed you.
  16. 16. http://flickr.com/photos/monikahoinkis/ Step 3: “Code thaw” Fix things that have always annoyed you. Add features that take Drupal to the next level.
  17. 17. http://flickr.com/photos/monikahoinkis/ Step 3: “Code thaw” Fix things that have always annoyed you. Add features that take Drupal to the next level. Integrate useful contributed modules.
  18. 18. http://flickr.com/photos/monikahoinkis/ Step 3: “Code thaw” Fix things that have always annoyed you. Add features that take Drupal to the next level. Integrate useful contributed modules. World domination!
  19. 19. Step 4: “Code freeze”
  20. 20. Step 4: “Code freeze”
  21. 21. Step 4: “Code freeze”
  22. 22. Step 4: “Code freeze” Alpha / Beta / RC
  23. 23. Step 5: GOTO Step 1
  24. 24. Step 5: GOTO Step 1 ! W NE Drupal 7
  25. 25. Step 5: GOTO Step 1 ! W NE Drupal 7
  26. 26. Step 6: Port all your modules. ;) Drupal 7
  27. 27. Where are we? code thaw code freeze* *Code freeze not necessarily drawn to scale. ;)
  28. 28. Where are we? code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  29. 29. Where are we? February, 2008 Drupal 6 released Drupal 7 opened code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  30. 30. Where are we? March, 2009 February, 2008 Drupalcon DC Drupal 6 released (we are here now) Drupal 7 opened code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  31. 31. Where are we? September 1, 2009 March, 2009 February, 2008 Code freeze Drupalcon DC Drupal 6 released (we are here now) Drupal 7 opened code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  32. 32. Where are we? September 1, 2009 March, 2009 February, 2008 Code freeze Drupalcon DC Drupal 6 released (we are here now) Drupal 7 opened “When it’s ready” Drupal 7 release code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  33. 33. Where are we? September 1, 2009 March, 2009 February, 2008 Code freeze Drupalcon DC Drupal 6 released (we are here now) Drupal 7 opened “When it’s ready” Drupal 7 release 6 months left! code thaw code freeze* Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep 08 08 08 08 08 08 08 08 08 08 08 09 09 09 09 09 09 09 09 09 *Code freeze not necessarily drawn to scale. ;)
  34. 34. When is “When it’s ready”?
  35. 35. When is “When it’s ready”?
  36. 36. When is “When it’s ready”?
  37. 37. When is “When it’s ready”? When this number becomes zero.
  38. 38. Should I start building sites on Drupal 7?
  39. 39. Should I start building sites on Drupal 7? NO!
  40. 40. Should I start porting modules to Drupal 7?
  41. 41. Should I start porting modules to Drupal 7? YES!
  42. 42. Should I start porting modules to Drupal 7? YES! *
  43. 43. Should I start porting modules to Drupal 7? YES! * * Sense of adventure required. ;)
  44. 44. Will $feature be in Drupal 7?
  45. 45. Will $feature be in Drupal 7? IT DEPENDS.
  46. 46. Drupal is a...
  47. 47. Drupal is a... DO-OCRACY
  48. 48. Drupal is a... DO-OCRACY The work that gets done is the work that people like you (yes, you!) actually do! :)
  49. 49. “Core maintainers” Dries Buytaert Drupal project lead Neil Drumm Gábor Hojtsy Angela Byron Drupal 5 maintainer Drupal 6 maintainer Drupal 7 maintainer
  50. 50. SLAC “Core maintainers” KERS Dries Buytaert Drupal project lead Neil Drumm Gábor Hojtsy Angela Byron Drupal 5 maintainer Drupal 6 maintainer Drupal 7 maintainer
  51. 51. The people who do the actual work. ;) Over 300 contributors to 1,000+ patches so far!
  52. 52. (some of) Team Drupal 7
  53. 53. (some of) Team Drupal 7
  54. 54. Help wanted! http://drupal.org/community-initiatives/drupal-core Sprint Day on Saturday!
  55. 55. What’s new ? in Drupal 7? So far, anyway...
  56. 56. Changes for site builders
  57. 57. New Minimum Requirements 5.0 5.2 8.3
  58. 58. Installation
  59. 59. Installation
  60. 60. Installation
  61. 61. Installation
  62. 62. Installation
  63. 63. Installation
  64. 64. Installation
  65. 65. Default profile
  66. 66. Default profile
  67. 67. Default profile
  68. 68. Default profile
  69. 69. Permission screen
  70. 70. Permission screen
  71. 71. Permission screen
  72. 72. Users can cancel own accounts
  73. 73. Users can cancel own accounts
  74. 74. Users can cancel own accounts
  75. 75. Users can cancel own accounts
  76. 76. Improved Translation Interface
  77. 77. Improved Translation Interface
  78. 78. Forums
  79. 79. Forums
  80. 80. Content Type Screen
  81. 81. Content Type Screen
  82. 82. Content Type Screen
  83. 83. Content Type Screen
  84. 84. Content Type Screen
  85. 85. Modules page
  86. 86. Modules page
  87. 87. Modules page
  88. 88. Modules page
  89. 89. Themes page
  90. 90. Themes page
  91. 91. Themes page
  92. 92. Configurable Error Reporting
  93. 93. Configurable Error Reporting
  94. 94. Configurable Error Reporting
  95. 95. What’s next for usability? • Vastly improved Help system • Clearer separation of admin vs. user tasks • Filter system improvements • Mark Boulton Design to help re-design Drupal 7 • Fixing issues found in University of Baltimore usability study (Designers, come and join us!)
  96. 96. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/usability • http://groups.drupal.org/usability • http://groups.drupal.org/mark-boulton- design-drupal-7-project • Go to the Usability team’s sessions on Thursday afternoon!
  97. 97. Changes for designers
  98. 98. Re-vamped page.tpl.php
  99. 99. Re-vamped page.tpl.php
  100. 100. Re-vamped page.tpl.php
  101. 101. Re-vamped page.tpl.php • Re-engineered XHTML structure to facilitate CSS-only design.
  102. 102. Re-vamped page.tpl.php • Re-engineered XHTML structure to facilitate CSS-only design. • Standard, semantic class/ID names (.section, #navigation, etc.)
  103. 103. Re-vamped page.tpl.php • Re-engineered XHTML structure to facilitate CSS-only design. • Standard, semantic class/ID names (.section, #navigation, etc.) • Improved consistency throughout.
  104. 104. Re-vamped page.tpl.php • Re-engineered XHTML structure to facilitate CSS-only design. • Standard, semantic class/ID names (.section, #navigation, etc.) • Improved consistency throughout. • Enables designers to create beautiful, CSS- only themes without touching PHP.
  105. 105. And to show it off...
  106. 106. Stark: “Naked” Drupal
  107. 107. drupal_add_js() improvements • Now pass in $options rather than 500 function arguments • Uses actual weighting rather than awkward ‘core’ vs. ‘module’ vs. ‘theme’ types. • Add external JavaScript files to the page. • hook_js_alter() • drupal_add_css() is next!
  108. 108. Cross-library compatibility works in 6! Before: After: (function($) { $('a').fadeOut().fadeIn(); $('a').fadeOut().fadeIn(); })(jQuery);
  109. 109. What’s next for designers? • Re-vamped node, block, comment, etc. templates to further cater to CSS-only themes. • Removing old core themes (and adding new ones)? • jQuery 1.3.x (and jQuery UI?) • Additional interface elements: pop-ups, modal dialogs, vertical tabs, results filters...
  110. 110. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/theming • http://groups.drupal.org/theme- development • http://drupal.org/community-initiatives/ drupal-core/javascript • http://groups.drupal.org/javascript
  111. 111. Changes for coders 01110111 01101001 01101100 01101100 00100000 01100011 01101111 01100100 01100101 00100000 01110000 01101000 01110000 00100000 01100110 01101111 01110010 00100000 01100110 01101111 01101111 01100100
  112. 112. Warning: Things are about to get... geeky.
  113. 113. http://www.flickr.com/photos/sebastian_bergmann/
  114. 114. SimpleTest
  115. 115. SimpleTest
  116. 116. SimpleTest
  117. 117. SimpleTest
  118. 118. SimpleTest • Writing tests causes you to really think through a problem, and helps flesh out obscure bugs.
  119. 119. SimpleTest • Writing tests causes you to really think through a problem, and helps flesh out obscure bugs. • Know instantly if your changes break something; freedom to refactor wildly.
  120. 120. SimpleTest • Writing tests causes you to really think through a problem, and helps flesh out obscure bugs. • Know instantly if your changes break something; freedom to refactor wildly. • Submit a test with your bug fix, it’ll stay fixed forever.
  121. 121. SimpleTest • Writing tests causes you to really think through a problem, and helps flesh out obscure bugs. • Know instantly if your changes break something; freedom to refactor wildly. • Submit a test with your bug fix, it’ll stay fixed forever. • Over 75% test coverage!
  122. 122. SimpleTest works in Excerpt from modules/block/block.test: 6!
  123. 123. testing.drupal.org
  124. 124. testing.drupal.org
  125. 125. testing.drupal.org
  126. 126. testing.drupal.org
  127. 127. testing.drupal.org • “Patch (code needs review)” and “Patch (reviewed & tested by community)” statuses can now be trusted.
  128. 128. testing.drupal.org • “Patch (code needs review)” and “Patch (reviewed & tested by community)” statuses can now be trusted. • Reviewers no longer getting carpal tunnel clicking through all the basic stuff.
  129. 129. testing.drupal.org • “Patch (code needs review)” and “Patch (reviewed & tested by community)” statuses can now be trusted. • Reviewers no longer getting carpal tunnel clicking through all the basic stuff. • Running the full test suite takes a long time; let a computer do it for you!
  130. 130. testing.drupal.org • “Patch (code needs review)” and “Patch (reviewed & tested by community)” statuses can now be trusted. • Reviewers no longer getting carpal tunnel clicking through all the basic stuff. • Running the full test suite takes a long time; let a computer do it for you! • Notifies author within 24 hours if patch no longer applies or breaks tests.
  131. 131. What’s next for testing? • testing.drupal.org testing on multiple databases/platforms • Automated testing for contributed modules • Testing site per patch • Automated testing for JavaScript • Improved core test coverage
  132. 132. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/testing • http://groups.drupal.org/testing-qa • testing.drupal.org back-end: Go see the “Saving Webchick Time” session • Donate to testing framework improvements @ http://testing.drupal.org/
  133. 133. Database The next geNERATION
  134. 134. The who in the what now? • Database abstraction layer built with PHP Data Objects (PDO) • Theoretical support for any database PHP supports; mysql, sqlite, and pgsql drivers in D7. • Dynamic query builder (db_rewrite_sql is DEAD!), with support for old-fashioned SELECTs for simple queries. • Transaction support • Master/slave replication
  135. 135. Static Select Queries Drupal 6: $result = db_query(quot;SELECT nid, title FROM {node} WHERE type = '%s' AND nid = %dquot;, array($type, $nid)); $node = db_fetch_object($result); Drupal 7: $node = db_query('SELECT nid, title FROM {node} WHERE type = :type AND nid = :nid', array(':type' => $type, ':nid' => $nid))->fetchObject();
  136. 136. Dynamic Select Queries Drupal 6: $result = pager_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10)); Drupal 7: $select = db_select('node', 'n') ->fields('n', array('nid')) ->condition('promote', 1) ->condition('status', 1) ->orderBy('sticky', 'DESC') ->orderBy('created', 'DESC') ->extend('PagerDefault') ->limit(variable_get('default_nodes_main', 10)) ->addTag('node_access');
  137. 137. Other Queries Insert Delete $nid = db_insert('node') $num_deleted = db_delete('node') ->fields(array('title', 'uid')) ->condition('nid', 5) ->values(array( ->execute(); 'title' => 'Example', 'uid' => 1, )) ->execute(); Update $num_updated = db_update('node') ->fields(array( 'uid' => 5, 'status' => 1, )) ->condition('created', REQUEST_TIME - 3600, '>=') ->execute();
  138. 138. hook_query_alter() Drupal 6: function hook_db_rewrite_sql($query, $primary_table, $primary_field, $args) { switch ($primary_field) { case 'nid': $return = array(); if ($primary_table != 'n') { $return['join'] = quot;LEFT JOIN {node} n ON $primary_table.nid = n.nidquot;; } $return['where'] = 'created >' . time() - 3600; return $return; break; } Drupal 7: function hook_query_alter(&$query) { if ($query->hasTag(‘node_access’)) { $query->condition(‘created’, time() - 3600, ‘>’); } }
  139. 139. What’s next for databases? • Improvements to: • Slave replication • Schema API • Update system • Multiple database support • Conversion of all core queries to DBTNG
  140. 140. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/database • http://groups.drupal.org/database • DBTNG session (uh. right now :) • API docs: http://drupal.org/node/310069 • Core conversion party on Saturday!
  141. 141. Field API http://www.flickr.com/photos/piper/
  142. 142. About Field API • CCK API in Drupal core (UI in contrib) • No longer node-specific: can attach fields to users, potentially other objects. • Swappable storage back-ends (currently, SQL but potentially web services, etc.) • Consistent way of storing/referencing fields to ease making changes.
  143. 143. Overview Bundles Field Fields instances name = Article name = subtitle type = node type = text Article subtitle widget = text area name = User name = photo type = user type = image Article photo widget = file upload Group of fields that make up Base types User photo a larger entity widget = file upload A field attached to a particular bundle
  144. 144. CCK Today content_type_profile (content type) nid vid name gender age color picture 1 1 Sally F 37 Purple sally.png 2 2 Jesse M 32 Red jesse.png
  145. 145. CCK Today
  146. 146. CCK Today content_type_profile (content type) nid vid name gender age color picture 1 1 Sally F 37 Purple sally.png 2 2 Jesse M 32 Red jesse.png content_field_fav_colors (multi-value field) nid vid delta color 1 1 0 Purple 1 1 1 Green 2 2 0 Red
  147. 147. CCK Today
  148. 148. CCK Today content_type_profile (content type) nid vid name gender age picture 1 1 Sally F 37 sally.png 2 2 Jesse M 32 jesse.png content_field_fav_colors content_field_picture (multi-value field) (shared field) nid vid delta color nid vid image 1 1 0 Purple 1 1 sally.png 1 1 1 Green 1 1 album_cover.png
  149. 149. Field API “revision id” “entity type” Corresponds 1 = user field_data_name to node rev. ID 2 = node etid bundle entity_id revision_id delta name_value 2 profile 1 1 0 Sally 2 profile 2 2 0 Jesse “bundle” “entity id” Name of Corresponds content type to node ID
  150. 150. Field API etid bundle entity_id revision_id delta name_value 2 profile 1 1 0 Sally 2 profile 2 2 0 Jesse etid bundle entity_id revision_id delta gender_value 2 profile 1 1 0 F 2 profile 2 2 0 M etid bundle entity_id revision_id delta color_value 2 profile 1 1 0 Purple 2 profile 1 1 1 Green 2 profile 2 2 0 Red etid bundle entity_id revision_id delta picture_value 2 profile 1 1 0 sally.png 2 profile 2 2 0 jesse.png 2 album 3 3 0 cover.png
  151. 151. What’s next for Field API? • Performance improvements with per-”bundle” storage and materialized views • Translatable fields • User Interface? • Additional fields types (+ body/teaser/ taxonomy?)
  152. 152. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/fields • http://groups.drupal.org/fields-core • API documentation: http://api.drupal.org/ api/group/field/7
  153. 153. Performance http://flickr.com/photos/thatguyfromcchs08/
  154. 154. Registry
  155. 155. Registry
  156. 156. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files
  157. 157. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files • Facilitates faster hook calls; only loop through modules that implement a hook
  158. 158. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files • Facilitates faster hook calls; only loop through modules that implement a hook • Allows more fine-grained break-up of code (ex: all “info” functions in module.registry.inc)
  159. 159. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files • Facilitates faster hook calls; only loop through modules that implement a hook • Allows more fine-grained break-up of code (ex: all “info” functions in module.registry.inc) • Need to register all files in .info:
  160. 160. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files • Facilitates faster hook calls; only loop through modules that implement a hook • Allows more fine-grained break-up of code (ex: all “info” functions in module.registry.inc) • Need to register all files in .info:
  161. 161. Registry • Auto-parses and caches list of all functions, classes, and interfaces in all files • Facilitates faster hook calls; only loop through modules that implement a hook • Allows more fine-grained break-up of code (ex: all “info” functions in module.registry.inc) • Need to register all files in .info: files[] = example.module files[] = example.install
  162. 162. No more $op works in 6! • hook_nodeapi(), hook_user(), hook_block(), etc. are no longer “mega” hooks: • hook_nodeapi_load(), hook_nodeapi_update() • hook_user_register(), hook_user_login() • hook_block_list(), hook_block_view() • hook_form_FORM_ID_alter()
  163. 163. Multi-load! • node_load_multiple() • file_load_multiple() • taxonomy_term_load_multiple() • user_load_multiple() (coming soon!)
  164. 164. File API http://flickr.com/photos/bunny/
  165. 165. File API improvements • Files are now first-class objects • hook_file_load(), hook_file_save(), hook_file_move(), etc. • Files are managed automatically; no need to deal with {files} table yourself • Potential for modules to share files
  166. 166. What’s next for files? • Image handling in core (for real this time?) • File management console • Native file fields • Improved private file handling?
  167. 167. Sign me up! • http://drupal.org/community-initiatives/ drupal-core/files • http://drupal.org/community-initiatives/ drupal-core/images • http://groups.drupal.org/file-api • http://groups.drupal.org/image
  168. 168. Hooks http://flickr.com/photos/yabanji/
  169. 169. New Hooks in D7 • hook_modules_X(): installed, enabled, disabled, uninstalled • hook_taxonomy_term_X(): load, insert, update, delete • hook_taxonomy_vocabulary_X(): load, insert, update, delete • hook_aggregator_X(): fetch, parse, process, remove
  170. 170. hook_page_alter() Drupal 6: Drupal 7: function page_callback($nids) { function page_callback($nids) { $output =   $nodes = node_load_multiple($nids); t('Welcome to a big list of nodes.');   $build['message'] = array(   foreach ($nids as $nid) {   '#markup' =>   $output .= node_view(node_load($nid)); t('Welcome to a big list of nodes.'),  }   );   $output .= theme('pager');   foreach ($nodes as $node) {   $build['nodes'][$node->nid] =   return $output; node_build($node); }  }   $build['pager'] = array(   '#markup' => theme('pager'),   '#weight' => 5,   );   return drupal_get_page($build); }
  171. 171. $page object $page['left']['blocks']['user-navigation']['#block'] = (block object); $page['content']['message']['#markup'] = 'Welcome to a big list of nodes.'; $page['content']['nodes'] = (array of node objects keyed by node ID); $page['content']['pager']['#markup'] = (HTML markup of pager); $page['footer']['blocks']['system-powered-by']['#block'] = (block object); Mwahahahahaha....!
  172. 172. Questions?

×