Permalink
Browse files

updating core to D7.8 and update some modules

  • Loading branch information...
1 parent f8d542b commit 321f09f0752df431b1ad41ab7ae0587824edfb26 Helrunar committed Sep 18, 2011
Showing with 6,658 additions and 2,346 deletions.
  1. +3 −3 .gitignore
  2. +1 −1 .htaccess
  3. +23 −0 CHANGELOG.txt
  4. +3 −2 MAINTAINERS.txt
  5. +243 −10 includes/bootstrap.inc
  6. +43 −24 includes/common.inc
  7. +36 −7 includes/database/database.inc
  8. +8 −14 includes/database/mysql/database.inc
  9. +3 −4 includes/database/pgsql/database.inc
  10. +91 −13 includes/database/query.inc
  11. +23 −0 includes/database/schema.inc
  12. +100 −42 includes/database/select.inc
  13. +1 −0 includes/database/sqlite/schema.inc
  14. +5 −2 includes/entity.inc
  15. +44 −6 includes/file.inc
  16. +1 −1 includes/file.mimetypes.inc
  17. +33 −2 includes/form.inc
  18. +4 −1 includes/lock.inc
  19. +1 −1 includes/menu.inc
  20. +10 −3 includes/pager.inc
  21. +1 −1 includes/stream_wrappers.inc
  22. +1 −1 includes/theme.inc
  23. +29 −0 includes/update.inc
  24. +12 −15 misc/tabledrag.js
  25. +3 −3 modules/aggregator/aggregator.info
  26. +1 −1 modules/aggregator/aggregator.module
  27. +3 −3 modules/aggregator/tests/aggregator_test.info
  28. +3 −3 modules/block/block.info
  29. +3 −7 modules/block/block.install
  30. +6 −0 modules/block/block.module
  31. +43 −0 modules/block/block.test
  32. +3 −3 modules/block/tests/block_test.info
  33. +3 −3 modules/blog/blog.info
  34. +3 −3 modules/book/book.info
  35. +3 −3 modules/color/color.info
  36. +5 −1 modules/color/color.module
  37. +3 −3 modules/comment/comment.info
  38. +7 −5 modules/comment/comment.install
  39. +3 −3 modules/contact/contact.info
  40. +19 −0 modules/contact/contact.install
  41. +3 −3 modules/contextual/contextual.info
  42. +3 −3 modules/dashboard/dashboard.info
  43. +3 −3 modules/dblog/dblog.info
  44. +78 −8 modules/field/field.api.php
  45. +5 −6 modules/field/field.default.inc
  46. +23 −0 modules/field/field.form.inc
  47. +3 −3 modules/field/field.info
  48. +78 −40 modules/field/field.module
  49. +3 −3 modules/field/modules/field_sql_storage/field_sql_storage.info
  50. +3 −3 modules/field/modules/list/list.info
  51. +3 −3 modules/field/modules/list/tests/list_test.info
  52. +3 −3 modules/field/modules/number/number.info
  53. +2 −2 modules/field/modules/number/number.module
  54. +3 −3 modules/field/modules/options/options.info
  55. +3 −3 modules/field/modules/text/text.info
  56. +0 −13 modules/field/modules/text/text.install
  57. +4 −4 modules/field/modules/text/text.module
  58. +2 −0 modules/field/tests/field.test
  59. +3 −3 modules/field/tests/field_test.info
  60. +21 −3 modules/field_ui/field_ui.admin.inc
  61. +4 −4 modules/field_ui/field_ui.api.php
  62. +3 −3 modules/field_ui/field_ui.info
  63. +3 −3 modules/file/file.info
  64. +1 −1 modules/file/tests/file.test
  65. +3 −3 modules/file/tests/file_module_test.info
  66. +3 −3 modules/filter/filter.info
  67. +3 −2 modules/filter/filter.install
  68. +7 −3 modules/filter/filter.module
  69. +5 −0 modules/forum/forum-list.tpl.php
  70. +3 −4 modules/forum/forum-rtl.css
  71. +10 −6 modules/forum/forum.css
  72. +3 −3 modules/forum/forum.info
  73. +5 −0 modules/forum/forum.install
  74. +5 −1 modules/forum/forum.module
  75. +25 −0 modules/forum/forum.test
  76. +3 −3 modules/help/help.info
  77. +1 −1 modules/image/image.field.inc
  78. +3 −3 modules/image/image.info
  79. +3 −3 modules/image/tests/image_module_test.info
  80. +3 −3 modules/locale/locale.info
  81. +3 −3 modules/locale/tests/locale_test.info
  82. +3 −3 modules/menu/menu.info
  83. +19 −0 modules/menu/menu.install
  84. +3 −3 modules/node/node.info
  85. +46 −7 modules/node/node.install
  86. +12 −2 modules/node/node.module
  87. +1 −1 modules/node/node.pages.inc
  88. +3 −3 modules/node/tests/node_access_test.info
  89. +3 −3 modules/node/tests/node_test.info
  90. +3 −3 modules/node/tests/node_test_exception.info
  91. +3 −3 modules/openid/openid.info
  92. +3 −3 modules/openid/tests/openid_test.info
  93. +9 −9 modules/overlay/overlay-child.css
  94. +49 −1 modules/overlay/overlay-parent.js
  95. +3 −3 modules/overlay/overlay.info
  96. +23 −7 modules/overlay/overlay.module
  97. +3 −3 modules/path/path.info
  98. +3 −3 modules/php/php.info
  99. +3 −3 modules/poll/poll.info
  100. +8 −1 modules/poll/poll.module
  101. +56 −1 modules/poll/poll.test
  102. +3 −3 modules/profile/profile.info
  103. +3 −3 modules/rdf/rdf.info
  104. +3 −3 modules/rdf/tests/rdf_test.info
  105. +3 −3 modules/search/search.info
  106. +43 −0 modules/search/search.test
  107. +3 −3 modules/search/tests/search_embedded_form.info
  108. +3 −3 modules/search/tests/search_extra_type.info
  109. +1 −0 modules/shortcut/shortcut-rtl.css
  110. +3 −3 modules/shortcut/shortcut.info
  111. +1 −1 modules/shortcut/shortcut.module
  112. +13 −0 modules/shortcut/shortcut.test
  113. +5 −0 modules/simpletest/drupal_web_test_case.php
  114. +4 −3 modules/simpletest/simpletest.info
  115. +3 −3 modules/simpletest/tests/actions_loop_test.info
  116. +3 −3 modules/simpletest/tests/ajax_forms_test.info
  117. +3 −3 modules/simpletest/tests/ajax_test.info
  118. +3 −3 modules/simpletest/tests/batch_test.info
  119. +21 −0 modules/simpletest/tests/cache.test
  120. +3 −3 modules/simpletest/tests/common_test.info
  121. +13 −0 modules/simpletest/tests/common_test.module
  122. +3 −3 modules/simpletest/tests/database_test.info
  123. +178 −15 modules/simpletest/tests/database_test.test
  124. +3 −3 ...simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info
  125. +3 −3 ...letest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info
  126. +3 −3 modules/simpletest/tests/entity_cache_test.info
  127. +3 −3 modules/simpletest/tests/entity_cache_test_dependency.info
  128. +3 −3 modules/simpletest/tests/entity_crud_hook_test.info
  129. +3 −3 modules/simpletest/tests/error_test.info
  130. +2 −0 modules/simpletest/tests/file.test
  131. +3 −3 modules/simpletest/tests/file_test.info
  132. +3 −3 modules/simpletest/tests/filter_test.info
  133. +3 −3 modules/simpletest/tests/form_test.info
  134. +3 −3 modules/simpletest/tests/image_test.info
  135. +3 −3 modules/simpletest/tests/menu_test.info
  136. +3 −3 modules/simpletest/tests/module_test.info
  137. +3 −3 modules/simpletest/tests/requirements1_test.info
  138. +3 −3 modules/simpletest/tests/requirements2_test.info
  139. +3 −3 modules/simpletest/tests/session_test.info
  140. +3 −3 modules/simpletest/tests/system_dependencies_test.info
  141. +3 −3 modules/simpletest/tests/system_test.info
  142. +3 −3 modules/simpletest/tests/taxonomy_test.info
  143. +3 −3 modules/simpletest/tests/theme_test.info
  144. +3 −3 modules/simpletest/tests/update_test_1.info
  145. +3 −3 modules/simpletest/tests/update_test_2.info
  146. +3 −3 modules/simpletest/tests/update_test_3.info
  147. +46 −0 modules/simpletest/tests/upgrade/drupal-6.menu.database.php
  148. +5 −0 modules/simpletest/tests/upgrade/upgrade.menu.test
  149. +4 −0 modules/simpletest/tests/upgrade/upgrade.test
  150. +3 −3 modules/simpletest/tests/url_alter_test.info
  151. +3 −3 modules/simpletest/tests/xmlrpc_test.info
  152. +3 −3 modules/statistics/statistics.info
  153. +1 −1 modules/statistics/statistics.module
  154. +3 −3 modules/syslog/syslog.info
  155. +1 −1 modules/system/system.admin.inc
  156. +28 −3 modules/system/system.api.php
  157. +3 −3 modules/system/system.info
  158. +9 −4 modules/system/system.install
  159. +11 −4 modules/system/system.module
  160. +92 −40 modules/system/system.test
  161. +13 −10 modules/system/system.tokens.inc
  162. +2 −1 modules/taxonomy/taxonomy-term.tpl.php
  163. +3 −3 modules/taxonomy/taxonomy.info
  164. +5 −20 modules/taxonomy/taxonomy.install
  165. +35 −11 modules/taxonomy/taxonomy.module
  166. +1 −1 modules/taxonomy/taxonomy.test
  167. +3 −3 modules/toolbar/toolbar.info
  168. +3 −3 modules/tracker/tracker.info
  169. +3 −3 modules/translation/tests/translation_test.info
  170. +3 −3 modules/translation/translation.info
  171. +3 −3 modules/trigger/tests/trigger_test.info
  172. +3 −3 modules/trigger/trigger.info
  173. +3 −3 modules/update/tests/aaa_update_test.info
  174. +3 −3 modules/update/tests/bbb_update_test.info
  175. +3 −3 modules/update/tests/ccc_update_test.info
  176. +3 −3 modules/update/tests/update_test.info
  177. +3 −3 modules/update/update.info
  178. +5 −0 modules/update/update.test
  179. +3 −3 modules/user/tests/user_form_test.info
  180. +1 −1 modules/user/user.admin.inc
  181. +3 −3 modules/user/user.info
  182. +21 −21 modules/user/user.install
  183. +1 −0 robots.txt
  184. +29 −0 sites/all/modules/contrib/better_formats/README.txt
  185. +2 −2 sites/all/modules/contrib/better_formats/better_formats.info
  186. +2 −1 sites/all/modules/contrib/better_formats/better_formats.module
  187. +2 −2 sites/all/modules/contrib/cck/cck.info
  188. +2 −2 sites/all/modules/contrib/cck/modules/content_migrate/content_migrate.info
  189. +12 −4 sites/all/modules/contrib/cck/modules/content_migrate/includes/content_migrate.drush.inc
  190. +19 −0 sites/all/modules/contrib/cck/modules/content_migrate/includes/content_migrate.values.inc
  191. +3 −4 sites/all/modules/contrib/email/email.info
  192. +0 −1 sites/all/modules/contrib/email/email.install
  193. +9 −4 sites/all/modules/contrib/email/email.module
  194. +0 −124 sites/all/modules/contrib/email/translations/da.po
  195. +0 −123 sites/all/modules/contrib/email/translations/de.po
  196. +0 −137 sites/all/modules/contrib/email/translations/email.pot
  197. +0 −140 sites/all/modules/contrib/email/translations/fr.po
  198. +0 −148 sites/all/modules/contrib/email/translations/hu.po
  199. +12 −0 sites/all/modules/contrib/entity/entity.api.php
  200. +2 −2 sites/all/modules/contrib/entity/entity.info
  201. +64 −6 sites/all/modules/contrib/entity/entity.module
  202. +14 −11 sites/all/modules/contrib/entity/entity.rules.inc
  203. +2 −0 sites/all/modules/contrib/entity/entity.test
  204. +2 −2 sites/all/modules/contrib/entity/entity_token.info
  205. +40 −0 sites/all/modules/contrib/entity/includes/entity.controller.inc
  206. +2 −2 sites/all/modules/contrib/entity/includes/entity.inc
  207. +11 −3 sites/all/modules/contrib/entity/includes/entity.property.inc
  208. +1 −1 sites/all/modules/contrib/entity/includes/entity.wrapper.inc
  209. +70 −0 sites/all/modules/contrib/entity/modules/callbacks.inc
  210. +2 −2 sites/all/modules/contrib/entity/tests/entity_feature.info
  211. +2 −2 sites/all/modules/contrib/entity/tests/entity_test.info
  212. +2 −2 sites/all/modules/contrib/filter_perms/filter_perms.info
  213. +1 −1 sites/all/modules/contrib/filter_perms/filter_perms.module
  214. +15 −4 sites/all/modules/contrib/module_filter/CHANGELOG.txt
  215. +0 −7 sites/all/modules/contrib/module_filter/css/module_filter.css
  216. +62 −9 sites/all/modules/contrib/module_filter/css/module_filter_tab.css
  217. +105 −15 sites/all/modules/contrib/module_filter/js/module_filter_tab.js
  218. +23 −22 sites/all/modules/contrib/module_filter/module_filter.admin.inc
  219. +3 −3 sites/all/modules/contrib/module_filter/module_filter.info
  220. +9 −2 sites/all/modules/contrib/module_filter/module_filter.install
  221. +25 −17 sites/all/modules/contrib/module_filter/module_filter.module
  222. +16 −4 sites/all/modules/contrib/module_filter/module_filter.theme.inc
  223. +225 −73 sites/all/modules/contrib/rules/includes/rules.core.inc
  224. +60 −41 sites/all/modules/contrib/rules/includes/rules.plugins.inc
  225. +95 −40 sites/all/modules/contrib/rules/includes/rules.state.inc
  226. +1 −1 sites/all/modules/contrib/rules/includes/rules.upgrade.inc
  227. +5 −4 sites/all/modules/contrib/rules/modules/data.eval.inc
  228. +5 −3 sites/all/modules/contrib/rules/modules/data.rules.inc
  229. +3 −3 sites/all/modules/contrib/rules/modules/entity.eval.inc
  230. +9 −5 sites/all/modules/contrib/rules/modules/entity.rules.inc
  231. +5 −5 sites/all/modules/contrib/rules/modules/rules_core.eval.inc
  232. +45 −0 sites/all/modules/contrib/rules/modules/rules_core.rules.inc
  233. +11 −2 sites/all/modules/contrib/rules/modules/system.eval.inc
  234. +0 −4 sites/all/modules/contrib/rules/rules.features.inc
  235. +2 −2 sites/all/modules/contrib/rules/rules.info
  236. +70 −0 sites/all/modules/contrib/rules/rules.install
  237. +201 −38 sites/all/modules/contrib/rules/rules.module
  238. +61 −5 sites/all/modules/contrib/rules/rules_admin/rules_admin.inc
  239. +2 −2 sites/all/modules/contrib/rules/rules_admin/rules_admin.info
  240. +3 −3 sites/all/modules/contrib/rules/rules_scheduler/rules_scheduler.info
  241. +5 −18 sites/all/modules/contrib/rules/rules_scheduler/rules_scheduler.module
  242. +42 −6 sites/all/modules/contrib/rules/rules_scheduler/rules_scheduler.rules.inc
  243. +1 −0 sites/all/modules/contrib/rules/rules_scheduler/rules_scheduler.test
  244. +122 −29 sites/all/modules/contrib/rules/tests/rules.test
  245. +2 −2 sites/all/modules/contrib/rules/tests/rules_test.info
  246. +30 −1 sites/all/modules/contrib/rules/tests/rules_test.module
  247. +55 −6 sites/all/modules/contrib/rules/tests/rules_test.rules.inc
  248. +1 −1 sites/all/modules/contrib/rules/tests/rules_test.test.inc
  249. +48 −2 sites/all/modules/contrib/rules/ui/rules.ui.css
  250. +8 −0 sites/all/modules/contrib/rules/ui/rules.ui.seven.css
  251. +29 −15 sites/all/modules/contrib/rules/ui/ui.controller.inc
  252. +117 −39 sites/all/modules/contrib/rules/ui/ui.core.inc
  253. 0 sites/all/modules/contrib/rules/ui/ui.data.inc
  254. +9 −11 sites/all/modules/contrib/rules/ui/ui.forms.inc
  255. +10 −6 sites/all/modules/contrib/rules/ui/ui.plugins.inc
  256. +36 −2 sites/all/modules/contrib/rules/ui/ui.theme.inc
  257. +3 −3 sites/all/modules/contrib/token/tests/token_test.info
  258. +5 −0 sites/all/modules/contrib/token/token.css
  259. +3 −3 sites/all/modules/contrib/token/token.info
  260. +109 −8 sites/all/modules/contrib/token/token.install
  261. +117 −44 sites/all/modules/contrib/token/token.module
  262. +82 −43 sites/all/modules/contrib/token/token.pages.inc
  263. +42 −18 sites/all/modules/contrib/token/token.test
  264. +231 −18 sites/all/modules/contrib/token/token.tokens.inc
  265. +18 −0 sites/all/modules/contrib/views_bulk_operations/README.txt
  266. +3 −3 sites/all/modules/contrib/views_bulk_operations/actions_permissions.info
  267. +14 −13 sites/all/modules/contrib/views_bulk_operations/css/views_bulk_operations.css
  268. +78 −36 sites/all/modules/contrib/views_bulk_operations/js/views_bulk_operations.js
  269. +34 −2 sites/all/modules/contrib/views_bulk_operations/views/views_bulk_operations.views_default.inc
  270. +32 −30 ...ll/modules/contrib/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc
  271. +2 −4 sites/all/modules/contrib/views_bulk_operations/views_bulk_operations.drush.inc
  272. +3 −3 sites/all/modules/contrib/views_bulk_operations/views_bulk_operations.info
  273. +166 −112 sites/all/modules/contrib/views_bulk_operations/views_bulk_operations.module
  274. +446 −0 sites/d7install.l/d7install.l/default.settings.php
  275. +446 −0 sites/d7install.l/d7install.l/settings.php
  276. +446 −0 sites/d7install.l/default.settings.php
  277. +3 −3 themes/bartik/bartik.info
  278. +0 −7 themes/bartik/css/style.css
  279. +3 −3 themes/garland/garland.info
  280. +3 −1 themes/seven/page.tpl.php
  281. +3 −3 themes/seven/seven.info
  282. +230 −5 themes/seven/style-rtl.css
  283. +82 −76 themes/seven/style.css
  284. +4 −2 themes/seven/template.php
  285. +3 −3 themes/stark/stark.info
  286. +3 −3 themes/tests/test_theme/test_theme.info
  287. +3 −3 themes/tests/update_test_basetheme/update_test_basetheme.info
  288. +3 −3 themes/tests/update_test_subtheme/update_test_subtheme.info
View
@@ -1,6 +1,6 @@
+# Ignore configuration files that may contain sensitive information.
+sites/*/settings*.php
+
# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private
-
-d7install.l
-d7install.l/*
View
@@ -101,7 +101,7 @@ DirectoryIndex index.php index.html index.htm
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
- RewriteBase /
+ # RewriteBase /
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
View
@@ -1,4 +1,27 @@
+Drupal 7.8, 2011-08-31
+----------------------
+- Fixed critical upgrade path issue with multilingual sites, leading to lost
+ content.
+- Numerous fixes to upgrade path, preventing fatal errors due to incorrect
+ dependencies.
+- Fixed issue with saving files on hosts with open_basedir restrictions.
+- Fixed Update manger error when used with Overlay.
+- Fixed RTL support in Seven administration theme and Overlay.
+- Fixes to nested transaction support.
+- Introduced performance pattern to reduce Drupal core's RAM usage.
+- Added support for HTML 5 tags to filter_xss_admin().
+- Added exception handling to cron.
+- Added new hook hook_field_widget_form_alter() for contribtued modules.
+- element_validate_*() functions now available to contrib.
+- Added new maintainers for several subsystems.
+- Numerous testing system improvements.
+- Numerous markup and CSS fixes.
+- Numerous poll module fixes.
+- Numerous notice/warning fixes.
+- Numerous documentation fixes.
+- Numerous token fixes.
+
Drupal 7.7, 2011-07-27
----------------------
- Fixed VERSION string.
View
@@ -54,7 +54,7 @@ Database system
- Károly Négyesi 'chx' <http://drupal.org/user/9446>
Database update system
-- ?
+- Károly Négyesi 'chx' <http://drupal.org/user/9446>
Entity system
- Nathaniel Catchpole 'catch' <http://drupal.org/user/35733>
@@ -190,7 +190,7 @@ Filter module
- Daniel F. Kudwien 'sun' <http://drupal.org/user/54136>
Forum module
-- ?
+- Lee Rowlands 'larowlan' <http://drupal.org/user/395439>
Help module
- ?
@@ -237,6 +237,7 @@ Search module
Shortcut module
- David Rothstein 'David_Rothstein' <http://drupal.org/user/124982>
+- Kristof De Jaeger 'swentel' <http://drupal.org/user/107403>
Simpletest module
- Jimmy Berry 'boombatower' <http://drupal.org/user/214218>
View
@@ -8,7 +8,7 @@
/**
* The current system version.
*/
-define('VERSION', '7.7');
+define('VERSION', '7.8');
/**
* Core API compatibility.
@@ -226,6 +226,195 @@ define('REGISTRY_WRITE_LOOKUP_CACHE', 2);
define('DRUPAL_PHP_FUNCTION_PATTERN', '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*');
/**
+ * Provides a caching wrapper to be used in place of large array structures.
+ *
+ * This class should be extended by systems that need to cache large amounts
+ * of data and have it represented as an array to calling functions. These
+ * arrays can become very large, so ArrayAccess is used to allow different
+ * strategies to be used for caching internally (lazy loading, building caches
+ * over time etc.). This can dramatically reduce the amount of data that needs
+ * to be loaded from cache backends on each request, and memory usage from
+ * static caches of that same data.
+ *
+ * Note that array_* functions do not work with ArrayAccess. Systems using
+ * DrupalCacheArray should use this only internally. If providing API functions
+ * that return the full array, this can be cached separately or returned
+ * directly. However since DrupalCacheArray holds partial content by design, it
+ * should be a normal PHP array or otherwise contain the full structure.
+ *
+ * Note also that due to limitations in PHP prior to 5.3.4, it is impossible to
+ * write directly to the contents of nested arrays contained in this object.
+ * Only writes to the top-level array elements are possible. So if you
+ * previously had set $object['foo'] = array(1, 2, 'bar' => 'baz'), but later
+ * want to change the value of 'bar' from 'baz' to 'foobar', you cannot do so
+ * a targeted write like $object['foo']['bar'] = 'foobar'. Instead, you must
+ * overwrite the entire top-level 'foo' array with the entire set of new
+ * values: $object['foo'] = array(1, 2, 'bar' => 'foobar'). Due to this same
+ * limitation, attempts to create references to any contained data, nested or
+ * otherwise, will fail silently. So $var = &$object['foo'] will not throw an
+ * error, and $var will be populated with the contents of $object['foo'], but
+ * that data will be passed by value, not reference. For more information on
+ * the PHP limitation, see the note in the official PHP documentation at·
+ * http://php.net/manual/en/arrayaccess.offsetget.php on
+ * ArrayAccess::offsetGet().
+ *
+ * By default, the class accounts for caches where calling functions might
+ * request keys in the array that won't exist even after a cache rebuild. This
+ * prevents situations where a cache rebuild would be triggered over and over
+ * due to a 'missing' item. These cases are stored internally as a value of
+ * NULL. This means that the offsetGet() and offsetExists() methods
+ * must be overridden if caching an array where the top level values can
+ * legitimately be NULL, and where $object->offsetExists() needs to correctly
+ * return (equivalent to array_key_exists() vs. isset()). This should not
+ * be necessary in the majority of cases.
+ *
+ * Classes extending this class must override at least the
+ * resolveCacheMiss() method to have a working implementation.
+ *
+ * offsetSet() is not overridden by this class by default. In practice this
+ * means that assigning an offset via arrayAccess will only apply while the
+ * object is in scope and will not be written back to the persistent cache.
+ * This follows a similar pattern to static vs. persistent caching in
+ * procedural code. Extending classes may wish to alter this behaviour, for
+ * example by overriding offsetSet() and adding an automatic call to persist().
+ *
+ * @see SchemaCache
+ */
+abstract class DrupalCacheArray implements ArrayAccess {
+
+ /**
+ * A cid to pass to cache_set() and cache_get().
+ */
+ private $cid;
+
+ /**
+ * A bin to pass to cache_set() and cache_get().
+ */
+ private $bin;
+
+ /**
+ * An array of keys to add to the cache at the end of the request.
+ */
+ protected $keysToPersist = array();
+
+ /**
+ * Storage for the data itself.
+ */
+ protected $storage = array();
+
+ /**
+ * Constructor.
+ *
+ * @param $cid
+ * The cid for the array being cached.
+ * @param $bin
+ * The bin to cache the array.
+ */
+ public function __construct($cid, $bin) {
+ $this->cid = $cid;
+ $this->bin = $bin;
+
+ if ($cached = cache_get($this->cid, $this->bin)) {
+ $this->storage = $cached->data;
+ }
+ }
+
+ public function offsetExists($offset) {
+ return $this->offsetGet($offset) !== NULL;
+ }
+
+ public function offsetGet($offset) {
+ if (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) {
+ return $this->storage[$offset];
+ }
+ else {
+ return $this->resolveCacheMiss($offset);
+ }
+ }
+
+ public function offsetSet($offset, $value) {
+ $this->storage[$offset] = $value;
+ }
+
+ public function offsetUnset($offset) {
+ unset($this->storage[$offset]);
+ }
+
+ /**
+ * Flags an offset value to be written to the persistent cache.
+ *
+ * If a value is assigned to a cache object with offsetSet(), by default it
+ * will not be written to the persistent cache unless it is flagged with this
+ * method. This allows items to be cached for the duration of a request,
+ * without necessarily writing back to the persistent cache at the end.
+ *
+ * @param $offset
+ * The array offset that was request.
+ * @param $persist
+ * Optional boolean to specify whether the offset should be persisted or
+ * not, defaults to TRUE. When called with $persist = FALSE the offset will
+ * be unflagged so that it will not written at the end of the request.
+ */
+ protected function persist($offset, $persist = TRUE) {
+ $this->keysToPersist[$offset] = $persist;
+ }
+
+ /**
+ * Resolves a cache miss.
+ *
+ * When an offset is not found in the object, this is treated as a cache
+ * miss. This method allows classes implementing the interface to look up
+ * the actual value and allow it to be cached.
+ *
+ * @param $offset
+ * The offset that was requested.
+ *
+ * @return
+ * The value of the offset, or NULL if no value was found.
+ */
+ abstract protected function resolveCacheMiss($offset);
+
+ /**
+ * Immediately write a value to the persistent cache.
+ *
+ * @param $cid
+ * The cache ID.
+ * @param $bin
+ * The cache bin.
+ * @param $data
+ * The data to write to the persistent cache.
+ * @param $lock
+ * Whether to acquire a lock before writing to cache.
+ */
+ protected function set($cid, $data, $bin, $lock = TRUE) {
+ // Lock cache writes to help avoid stampedes.
+ // To implement locking for cache misses, override __construct().
+ $lock_name = $cid . ':' . $bin;
+ if (!$lock || lock_acquire($lock_name)) {
+ if ($cached = cache_get($cid, $bin)) {
+ $data = $cached->data + $data;
+ }
+ cache_set($cid, $data, $bin);
+ if ($lock) {
+ lock_release($lock_name);
+ }
+ }
+ }
+
+ public function __destruct() {
+ $data = array();
+ foreach ($this->keysToPersist as $offset => $persist) {
+ if ($persist) {
+ $data[$offset] = $this->storage[$offset];
+ }
+ }
+ if (!empty($data)) {
+ $this->set($this->cid, $data, $this->bin);
+ }
+ }
+}
+
+/**
* Start the timer with the specified name. If you start and stop the same
* timer multiple times, the measured intervals will be accumulated.
*
@@ -2532,6 +2721,55 @@ function ip_address() {
* If true, the schema will be rebuilt instead of retrieved from the cache.
*/
function drupal_get_schema($table = NULL, $rebuild = FALSE) {
+ static $schema;
+
+ if ($rebuild || !isset($table)) {
+ $schema = drupal_get_complete_schema($rebuild);
+ }
+ elseif (!isset($schema)) {
+ $schema = new SchemaCache();
+ }
+
+ if (!isset($table)) {
+ return $schema;
+ }
+ if (isset($schema[$table])) {
+ return $schema[$table];
+ }
+ else {
+ return FALSE;
+ }
+}
+
+/**
+ * Extends DrupalCacheArray to allow for dynamic building of the schema cache.
+ */
+class SchemaCache extends DrupalCacheArray {
+
+ public function __construct() {
+ // Cache by request method.
+ parent::__construct('schema:runtime:' . $_SERVER['REQUEST_METHOD'] == 'GET', 'cache');
+ }
+
+ protected function resolveCacheMiss($offset) {
+ $complete_schema = drupal_get_complete_schema();
+ $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] : NULL;
+ $this->storage[$offset] = $value;
+ $this->persist($offset);
+ return $value;
+ }
+}
+
+/**
+ * Get the whole database schema.
+ *
+ * The returned schema will include any modifications made by any
+ * module that implements hook_schema_alter().
+ *
+ * @param $rebuild
+ * If true, the schema will be rebuilt instead of retrieved from the cache.
+ */
+function drupal_get_complete_schema($rebuild = FALSE) {
static $schema = array();
if (empty($schema) || $rebuild) {
@@ -2573,18 +2811,13 @@ function drupal_get_schema($table = NULL, $rebuild = FALSE) {
if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
cache_set('schema', $schema);
}
+ if ($rebuild) {
+ cache_clear_all('schema:', 'cache', TRUE);
+ }
}
}
- if (!isset($table)) {
- return $schema;
- }
- elseif (isset($schema[$table])) {
- return $schema[$table];
- }
- else {
- return FALSE;
- }
+ return $schema;
}
/**
Oops, something went wrong. Retry.

0 comments on commit 321f09f

Please sign in to comment.