Heine

  • home
  • drupal
  • drupal core commits
  • about
Home › Drupal Core Commits

Commit 340632 by dries

- Patch #734762 by Damien Tournoud, sun, scor: tidy up the filter upgrade path.

--- <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install</a>     2010/03/05 13:32:09     1.34
+++ <a href="http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install" title="http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install" rel="nofollow">http://drupalcode.org/viewvc/drupal/drupal/modules/filter/filter.install</a>     2010/03/12 14:31:01     1.35
@@ -54,9 +54,6 @@
       ),
     ),
     'primary key' => array('format', 'name'),
-    'unique keys' => array(
-      'fmn' => array('format', 'module', 'name'),
-    ),
     'indexes' => array(
       'list' => array('weight', 'module', 'name'),
     ),
@@ -161,11 +158,31 @@
  */
 
 /**
- * Add a weight column to the filter formats table.
+ * Increase the size of {filters}.weight and add {filter_formats}.weight.
  */
 function filter_update_7000() {
-  db_add_field('filter_formats', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
-  db_add_index('filter_formats', 'weight', array('weight'));
+  // The list index will be recreated by filter_update_7003().
+  db_drop_index('filters', 'list');
+
+  // Change the weight column of the filter table to normal (ie. non tiny) int.
+  db_change_field('filters', 'weight', 'weight', array(
+    'type' => 'int',
+    'not null' => TRUE,
+    'default' => 0,
+    'description' => 'Weight of filter within format.',
+  ));
+
+  // Add a new filter_format.weight column.
+  db_add_field('filter_formats', 'weight', array(
+    'type' => 'int',
+    'not null' => TRUE,
+    'default' => 0,
+    'description' => 'Weight of text format to use when listing.',
+  ), array(
+    'indexes' => array(
+      'weight' => array('weight'),
+    ),
+  ));
 }
 
 /**
@@ -217,9 +234,11 @@
     ),
   );
 
-  // Rename field 'delta' to 'name'.
+  // The unique key on (filter, module, delta) is not necessary anymore,
+  // as filter_update_7004() will add a primary key on (filter, name).
   db_drop_unique_key('filter', 'fmd');
-  db_drop_index('filter', 'list');
+
+  // Rename field 'delta' to 'name'.
   db_change_field('filter', 'delta', 'name',
     array(
       'type' => 'varchar',
@@ -229,11 +248,8 @@
       'description' => 'Name of the filter being referenced.',
     ),
     array(
-      'unique keys' => array(
-        'fmn' => array('format', 'module', 'name'),
-      ),
       'indexes' => array(
-        'list' => array('format', 'weight', 'module', 'name'),
+        'list' => array('weight', 'module', 'name'),
       ),
     )
   );
@@ -408,43 +424,6 @@
 }
 
 /**
- * Remove the 'format' column from 'list' index on {filter}.
- */
-function filter_update_7006() {
-  db_drop_index('filter', 'list');
-  db_add_index('filter', 'list', array('weight', 'module', 'name'));
-}
-
-/**
- * Change the weight columns to normal int.
- */
-function filter_update_7007() {
-  db_drop_index('filter', 'list');
-  db_change_field('filter', 'weight', 'weight', array(
-    'type' => 'int',
-    'not null' => TRUE,
-    'default' => 0,
-    'description' => 'Weight of filter within format.',
-  ), array(
-    'indexes' => array(
-      'list' => array('weight', 'module', 'name'),
-    ),
-  ));
-
-  db_drop_index('filter_format', 'weight');
-  db_change_field('filter_format', 'weight', 'weight', array(
-    'type' => 'int',
-    'not null' => TRUE,
-    'default' => 0,
-    'description' => 'Weight of text format to use when listing.',
-  ), array(
-    'indexes' => array(
-      'weight' => array('weight'),
-    ),
-  ));
-}
-
-/**
  * Grant usage of all text formats to user roles having the 'administer filters' permission.
  */
 function filter_update_7008() {

No votes yet
  • Drupal Core
  • Download patch

Recent posts

  • Planet Drupal past and current
  • Help! - Cannot access a global variable.
  • Why is my module's update hook not listed on update.php's selection form?
  • How do I add a class to a link generated with l()
  • ZeroDayScan - Full path disclosure bug in Drupal 6.16 (0day)
more

Security reviews

  • Afraid custom code makes your site vulnerable?
  • You don't really trust that module you just downloaded from Drupal.org?

Sleep better after a security review.

Tags

Captcha CSRF Drupal embed Input Format modx OpenID Performance Planet Drupal rants Security Varnish
more tags
  • home
  • drupal
  • drupal core commits
  • about

Copyright © 2010 by Heine Deelstra. All rights reserved.