Index: content.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/cck/content.install,v
retrieving revision 1.85.2.30
diff -u -p -r1.85.2.30 content.install
--- content.install 7 Nov 2008 16:24:58 -0000 1.85.2.30
+++ content.install 16 Nov 2008 21:56:38 -0000
@@ -1,6 +1,18 @@
$data) {
+ // Only consider modules that have pending updates to be run.
+ if (in_array($module, array_keys($updates)) && $updates[$module] <= max(drupal_get_schema_versions($module))) {
+ // Only consider CCK and any modules that depend on it.
+ if ($module == 'content' || (!empty($data->info['dependencies']) && in_array('content', $data->info['dependencies']))) {
+ // If CCK or the module itself is disabled, do not run this module's
+ // updates.
+ if (!module_exists('content') || !module_exists($module)) {
+ unset($updates[$module]);
+ $modules_not_updated[] = $data->info['name'];
+ }
+ }
+ }
+ }
+
+ // If updates were skipped, queue a message to appear later in the update
+ // process.
+ if (!empty($modules_not_updated)) {
+ content_queue_message(t("Updates for CCK-related modules are not run until the modules are enabled on the administer modules page. The following modules which are available on your system therefore did not have their pending updates run:
If and when you enable them, you'll need to return to update.php and run the remaining updates.", array('@admin-modules-path' => url('admin/build/modules'), '!module_list' => ''. implode('', array_map('check_plain', $modules_not_updated)) .'', '@update-php' => base_path() .'update.php?op=selection')), 'warning');
+ }
+}
+
+/**
+ * Comparison function for sorting module updates.
+ */
+function _content_alter_module_updates_cmp($a, $b) {
+ // Preserve the Drupal core behavior where system.module's updates run
+ // first.
+ if ($a == 'system' || $b == 'system') {
+ return $a == 'system' ? -1 : 1;
+ }
+ // Make sure CCK's updates run next, before any others.
+ elseif ($a == 'content' || $b == 'content') {
+ return $a == 'content' ? -1 : 1;
+ }
+ // Otherwise we don't care what order the updates run in.
+ return 0;
+}
+
+/**
+ * Queue a message to be displayed later.
+ *
+ * This is necessary so that messages do not flash on the screen while
+ * updates are being run, but rather can be presented to the user at the
+ * end of the update process.
+ */
+function content_queue_message($message, $type = 'status') {
+ if (!isset($_SESSION['content_queued_update_messages'])) {
+ $_SESSION['content_queued_update_messages'] = array();
+ }
+ if (!isset($_SESSION['content_queued_update_messages'][$type])) {
+ $_SESSION['content_queued_update_messages'][$type] = array();
+ }
+ $_SESSION['content_queued_update_messages'][$type][] = $message;
+}
+
+/**
+ * Set all messages that have been queued for display.
+ */
+function content_set_queued_messages() {
+ if (isset($_SESSION['content_queued_update_messages'])) {
+ foreach ($_SESSION['content_queued_update_messages'] as $type => $messages) {
+ foreach ($messages as $message) {
+ drupal_set_message($message, $type);
+ }
+ }
+ unset($_SESSION['content_queued_update_messages']);
+ }
+}
+
+/**
* Helper function for module updates :
* - checks no updates are pending for content.module
* - checks content module and the module being updated are both enabled.
@@ -518,4 +615,4 @@ function content_update_6009() {
}
variable_set('content_schema_version', 6009);
return $ret;
-}
\ No newline at end of file
+}