[geeklog-cvs] geeklog: First batch of fixes for bug #0001354 (MySQL only)

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun May 29 13:19:51 EDT 2011


changeset 8294:671c7abaa779
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/671c7abaa779
user: Dirk Haun <dirk at haun-online.de>
date: Sun May 29 17:20:11 2011 +0200
description:
First batch of fixes for bug #0001354 (MySQL only)

diffstat:

 plugins/calendar/functions.inc            |   36 +++-
 plugins/calendar/sql/mysql_updates.php    |   31 +++-
 plugins/links/functions.inc               |   74 +++++--
 plugins/links/sql/mysql_updates.php       |   69 ++++++-
 plugins/polls/functions.inc               |   56 ++++-
 plugins/polls/sql/mysql_updates.php       |   52 +++++-
 plugins/spamx/functions.inc               |   27 ++-
 plugins/spamx/sql/mysql_updates.php       |    4 +-
 plugins/staticpages/functions.inc         |   33 +++
 plugins/staticpages/sql/mysql_updates.php |    8 +-
 public_html/admin/install/lib-upgrade.php |   41 +----
 sql/updates/mysql_1.4.1_to_1.5.0.php      |  281 ------------------------------
 sql/updates/mysql_1.5.1_to_1.5.2.php      |   12 -
 13 files changed, 348 insertions(+), 376 deletions(-)

diffs (truncated from 1040 to 300 lines):

diff -r 16b6fab2dd4a -r 671c7abaa779 plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc	Sun May 29 13:06:50 2011 +0200
+++ b/plugins/calendar/functions.inc	Sun May 29 17:20:11 2011 +0200
@@ -10,7 +10,7 @@
 // | API method and 2) implements all the common code needed by the Calendar   |
 // | plugin's PHP files.                                                       |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2010 by the following authors:                         |
+// | Copyright (C) 2000-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Tony Bibbs       - tony AT tonybibbs DOT com                     |
 // |          Tom Willett      - twillett AT users DOT sourceforge DOT net     |
@@ -1527,7 +1527,41 @@
     $done = false;
     while (! $done) {
         switch ($current_version) {
+        case '1.0.0':
+            require_once $_CONF['path_system'] . 'classes/config.class.php';
+
+            $plugin_path = $_CONF['path'] . 'plugins/calendar/';
+            require_once $plugin_path . 'install_defaults.php';
+
+            if (file_exists($plugin_path . 'config.php')) {
+                global $_DB_table_prefix, $_CA_CONF;
+
+                require_once $plugin_path . 'config.php';
+            }
+
+            if (!plugin_initconfig_calendar()) {
+                echo 'There was an error upgrading the Calendar plugin';
+                return false;
+            }
+
+            if (isset($_UPDATES[$current_version])) {
+                $_SQL = $_UPDATES[$current_version];
+                foreach ($_SQL as $sql) {
+                    DB_query($sql);
+                }
+            }
+            calendar_update_move_states();
+
+            $current_version = '1.0.2';
+            break;
+
+        case '1.0.2':
+            // no db changes
+            $current_version = '1.0.3';
+            break;
+
         case '1.0.3':
+            // no db changes
             $current_version = '1.1.0';
             break;
 
diff -r 16b6fab2dd4a -r 671c7abaa779 plugins/calendar/sql/mysql_updates.php
--- a/plugins/calendar/sql/mysql_updates.php	Sun May 29 13:06:50 2011 +0200
+++ b/plugins/calendar/sql/mysql_updates.php	Sun May 29 17:20:11 2011 +0200
@@ -6,7 +6,7 @@
 // +---------------------------------------------------------------------------+
 // | Upgrade SQL                                                               |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2009 by the following authors:                              |
+// | Copyright (C) 2009-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Dirk Haun        - dirk AT haun-online DOT de                    |
 // +---------------------------------------------------------------------------+
@@ -27,12 +27,18 @@
 // +---------------------------------------------------------------------------+
 
 /**
-* MY SQL updates
+* MySQL updates
 *
 * @package Calendar
 */
 
 $_UPDATES = array(
+
+    '1.0.0' => array(
+        "ALTER TABLE {$_TABLES['events']} CHANGE state state varchar(40) default NULL",
+        "ALTER TABLE {$_TABLES['eventsubmission']} CHANGE state state varchar(40) default NULL",
+        "ALTER TABLE {$_TABLES['personal_events']} CHANGE state state varchar(40) default NULL"
+    ),
     
     '1.1.0' => array(
         "ALTER TABLE {$_TABLES['eventsubmission']} ADD owner_id mediumint(8) unsigned NOT NULL default '1' AFTER timeend"
@@ -49,6 +55,27 @@
 );
 
 /**
+* Replace the old $_STATES array with a free-form text field
+*
+*/
+function calendar_update_move_states()
+{
+    global $_TABLES, $_STATES;
+
+    if (isset($_STATES) && is_array($_STATES)) {
+        $tables = array($_TABLES['events'], $_TABLES['eventsubmission'],
+                        $_TABLES['personal_events']);
+
+        foreach ($_STATES as $key => $state) {
+            foreach ($tables as $table) {
+                DB_change($table, 'state', addslashes($state),
+                                  'state', addslashes($key));
+            }
+        }
+    }
+}
+
+/**
  * Add is new security rights for the Group "Calendar Admin"
  *
  */
diff -r 16b6fab2dd4a -r 671c7abaa779 plugins/links/functions.inc
--- a/plugins/links/functions.inc	Sun May 29 13:06:50 2011 +0200
+++ b/plugins/links/functions.inc	Sun May 29 17:20:11 2011 +0200
@@ -670,15 +670,15 @@
 {
     global $_CONF, $_TABLES, $_LI_CONF, $_DB_dbms;
 
-    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',         
+    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
                                     "pi_name = 'links'");
     $code_version = plugin_chkVersion_links();
     if ($installed_version == $code_version) {
-        // nothing to do                                                       
-        return true; 
+        // nothing to do
+        return true;
     }
 
-    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';          
+    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';
 
     if (! plugin_compatible_with_this_version_links('links')) {
         return 3002;
@@ -686,53 +686,89 @@
 
     $inst_parms = plugin_autoinstall_links('links');
     $pi_gl_version = $inst_parms['info']['pi_gl_version'];
-    
+
     require_once $_CONF['path'] . 'plugins/links/sql/'
                                 . $_DB_dbms . '_updates.php';
-                                
-    require_once $_CONF['path'] . 'plugins/links/install_updates.php';                                
+
+    require_once $_CONF['path'] . 'plugins/links/install_updates.php';
 
     $current_version = $installed_version;
     $done = false;
     while (! $done) {
         switch ($current_version) {
+        case '1.0.1':
+            require_once $_CONF['path_system'] . 'classes/config.class.php';
+
+            $plugin_path = $_CONF['path'] . 'plugins/links/';
+            require_once $plugin_path . 'install_defaults.php';
+
+            if (file_exists($plugin_path . 'config.php')) {
+                global $_DB_table_prefix, $_LI_CONF;
+
+                require_once $plugin_path . 'config.php';
+            }
+
+            if (!plugin_initconfig_links()) {
+                echo 'There was an error upgrading the Links plugin';
+                return false;
+            }
+
+            $li_config = config::get_instance();
+            $_LI_CONF = $li_config->get_config('links');
+
+            if (isset($_UPDATES[$current_version])) {
+                $_SQL = $_UPDATES[$current_version];
+                $_SQL = INST_checkInnodbUpgrade($_SQL);
+                foreach ($_SQL as $sql) {
+                    DB_query($sql);
+                }
+            }
+            links_update_set_categories();
+
+            $current_version = '2.0.0';
+            break;
+
+        case '2.0.0':
+            // no db changes
+            $current_version = '2.0.1';
+            break;
+
         case '2.0.1': // Last version of old install (Geeklog 1.5.2)
             if (! isset($_LI_CONF['new_window'])) {
                 $c = config::get_instance();
                 $c->add('new_window',false,'select',0,0,1,55,TRUE,'links');
             }
-        
+
             if (! isset($_LI_CONF['category_permissions'])) {
                 $c = config::get_instance();
                 $c->add('fs_cpermissions', NULL, 'fieldset', 0, 3, NULL, 0, true, 'links');
                 $c->add('category_permissions', array (3, 2, 2, 2),
                         '@select', 0, 3, 12, 150, true, 'links');
-            }            
-            
+            }
+
             $current_version = '2.1.0';
-            break;    
+            break;
+
         case '2.1.0':
             if (isset($_UPDATES[$current_version])) {
                 $_SQL = $_UPDATES[$current_version];
                 foreach ($_SQL as $sql) {
                     DB_query($sql);
                 }
-            }            
+            }
 
             links_update_ConfValues_2_1_0();
-            
+
             links_update_ConfigSecurity_2_1_0();
-            
+
             $current_version = '2.1.1';
-            break;            
+            break;
 
         default:
             $done = true;
         }
-    }    
-    
-    
-    
+    }
+
     DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'links'");
 
     return true;
diff -r 16b6fab2dd4a -r 671c7abaa779 plugins/links/sql/mysql_updates.php
--- a/plugins/links/sql/mysql_updates.php	Sun May 29 13:06:50 2011 +0200
+++ b/plugins/links/sql/mysql_updates.php	Sun May 29 17:20:11 2011 +0200
@@ -2,11 +2,11 @@
 
 /* Reminder: always indent with 4 spaces (no tabs). */
 // +---------------------------------------------------------------------------+
-// | Links Plugin 2.0                                                          |
+// | Links Plugin 2.1                                                          |
 // +---------------------------------------------------------------------------+
 // | Installation SQL                                                          |
 // +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2010 by the following authors:                         |
+// | Copyright (C) 2000-2011 by the following authors:                         |
 // |                                                                           |
 // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
 // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
@@ -32,13 +32,36 @@
 // +---------------------------------------------------------------------------+
 
 /**
-* MY SQL updates
+* MySQL updates
 *
 * @package Links
 */
 
 $_UPDATES = array(
 
+    '1.0.1' => array(
+        "CREATE TABLE {$_TABLES['linkcategories']} (
+          cid varchar(32) NOT NULL,
+          pid varchar(32) NOT NULL,
+          category varchar(32) NOT NULL,
+          description text DEFAULT NULL,
+          tid varchar(20) DEFAULT NULL,
+          created datetime DEFAULT NULL,
+          modified datetime DEFAULT NULL,
+          owner_id mediumint(8) unsigned NOT NULL default '1',
+          group_id mediumint(8) unsigned NOT NULL default '1',
+          perm_owner tinyint(1) unsigned NOT NULL default '3',
+          perm_group tinyint(1) unsigned NOT NULL default '2',
+          perm_members tinyint(1) unsigned NOT NULL default '2',
+          perm_anon tinyint(1) unsigned NOT NULL default '2',
+          PRIMARY KEY (cid),
+          KEY links_pid (pid)
+        ) TYPE=MyISAM",
+        "ALTER TABLE {$_TABLES['linksubmission']} ADD owner_id mediumint(8) unsigned NOT NULL default '1' AFTER date",
+        "ALTER TABLE {$_TABLES['linksubmission']} CHANGE category cid varchar(32) NOT NULL",
+        "ALTER TABLE {$_TABLES['links']} CHANGE category cid varchar(32) NOT NULL"
+    ),
+
     '2.1.0' => array(
         // Set new Tab column to whatever fieldset is
         "UPDATE {$_TABLES['conf_values']} SET tab = fieldset WHERE group_name = 'links'",   
@@ -52,7 +75,45 @@
 );
 



More information about the geeklog-cvs mailing list