]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14123 Full IPv6 support - updating all db fields to theoretical 45 char limit
authorskodak <skodak>
Tue, 6 Jan 2009 18:14:28 +0000 (18:14 +0000)
committerskodak <skodak>
Tue, 6 Jan 2009 18:14:28 +0000 (18:14 +0000)
lib/db/install.xml
lib/db/upgrade.php
mod/chat/db/install.xml
mod/chat/db/upgrade.php
mod/chat/version.php
version.php

index b11355d0fba524bc89967c1161d5057a18e1db02..e66d7f2cfaef209b147959437916e1a3b80bc6bd 100644 (file)
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="time"/>
         <FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="userid"/>
         <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="ip"/>
-        <FIELD NAME="ip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
+        <FIELD NAME="ip" TYPE="char" LENGTH="45" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ip" NEXT="module"/>
         <FIELD NAME="module" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="cmid"/>
         <FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="module" NEXT="action"/>
     </TABLE>
     <TABLE NAME="sessions" COMMENT="Database based session storage - now recommended" PREVIOUS="modules" NEXT="timezone">
       <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="sid"/>
-        <FIELD NAME="sid" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Session id" PREVIOUS="id" NEXT="sessdata"/>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="state"/>
+        <FIELD NAME="state" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="0 means normal session" PREVIOUS="id" NEXT="sid"/>
+        <FIELD NAME="sid" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Session id" PREVIOUS="state" NEXT="sessdata"/>
         <FIELD NAME="sessdata" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="session content" PREVIOUS="sid" NEXT="timecreated"/>
         <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="sessdata" NEXT="timemodified"/>
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified" NEXT="lastip"/>
-        <FIELD NAME="lastip" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="sesskey"/>
-        <FIELD NAME="sesskey" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lastip"/>
+        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="timemodified" NEXT="firstip"/>
+        <FIELD NAME="firstip" TYPE="char" LENGTH="45" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="lastip"/>
+        <FIELD NAME="lastip" TYPE="char" LENGTH="45" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="firstip"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="userid"/>
         <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="primary"/>
       </KEYS>
       <INDEXES>
-        <INDEX NAME="sid" UNIQUE="true" FIELDS="sid" NEXT="timecreated"/>
+        <INDEX NAME="state" UNIQUE="false" FIELDS="state" NEXT="sid"/>
+        <INDEX NAME="sid" UNIQUE="true" FIELDS="sid" PREVIOUS="state" NEXT="timecreated"/>
         <INDEX NAME="timecreated" UNIQUE="false" FIELDS="timecreated" PREVIOUS="sid" NEXT="timemodified"/>
         <INDEX NAME="timemodified" UNIQUE="false" FIELDS="timemodified" PREVIOUS="timecreated"/>
       </INDEXES>
         <FIELD NAME="lastaccess" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="firstaccess" NEXT="lastlogin"/>
         <FIELD NAME="lastlogin" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lastaccess" NEXT="currentlogin"/>
         <FIELD NAME="currentlogin" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lastlogin" NEXT="lastip"/>
-        <FIELD NAME="lastip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="currentlogin" NEXT="secret"/>
+        <FIELD NAME="lastip" TYPE="char" LENGTH="45" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="currentlogin" NEXT="secret"/>
         <FIELD NAME="secret" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lastip" NEXT="picture"/>
         <FIELD NAME="picture" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="secret" NEXT="url"/>
         <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="picture" NEXT="description"/>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="Unique Host ID" NEXT="deleted"/>
         <FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="wwwroot"/>
         <FIELD NAME="wwwroot" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="deleted" NEXT="ip_address"/>
-        <FIELD NAME="ip_address" TYPE="char" LENGTH="39" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="wwwroot" NEXT="name"/>
+        <FIELD NAME="ip_address" TYPE="char" LENGTH="45" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="wwwroot" NEXT="name"/>
         <FIELD NAME="name" TYPE="char" LENGTH="80" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="ip_address" NEXT="public_key"/>
         <FIELD NAME="public_key" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="public_key_expires"/>
         <FIELD NAME="public_key_expires" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="public_key" NEXT="transport"/>
         <FIELD NAME="remoteid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="hostid" NEXT="time"/>
         <FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="remoteid" NEXT="userid"/>
         <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="ip"/>
-        <FIELD NAME="ip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
+        <FIELD NAME="ip" TYPE="char" LENGTH="45" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ip" NEXT="coursename"/>
         <FIELD NAME="coursename" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="module"/>
         <FIELD NAME="module" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="coursename" NEXT="cmid"/>
index c407436521db83cd3ce77cb1dcd8a6f1ddb93783..abb89504d3dc20048dedffe832af9e425daf9fdd 100644 (file)
@@ -926,7 +926,7 @@ function xmldb_main_upgrade($oldversion) {
         if (isset($roleids['user'])) {
             $rolecontextlevels[$roleids['user']] = get_default_contextlevels('user');
         }
-    
+
     /// See what other role assignments are in this database, extend the allowed
     /// lists to allow them too.
         $existingrolecontextlevels = $DB->get_recordset_sql('SELECT DISTINCT ra.roleid, con.contextlevel FROM
@@ -1165,7 +1165,82 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint($result, 2008121701);
     }
 
-    if ($result && $oldversion < 2008123100) {
+    if ($result && $oldversion < 2009010500) {
+    /// clean up config table a bit
+        unset_config('session_error_counter');
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010500);
+    }
+
+    if ($result && $oldversion < 2009010600) {
+
+    /// Define field originalquestion to be dropped from question_states
+        $table = new xmldb_table('question_states');
+        $field = new xmldb_field('originalquestion');
+
+    /// Conditionally launch drop field originalquestion
+        if ($dbman->field_exists($table, $field)) {
+            $dbman->drop_field($table, $field);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010600);
+    }
+
+    if ($result && $oldversion < 2009010601) {
+
+    /// Changing precision of field ip on table log to (45)
+        $table = new xmldb_table('log');
+        $field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
+
+    /// Launch change of precision for field ip
+        $dbman->change_field_precision($table, $field);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010601);
+    }
+
+    if ($result && $oldversion < 2009010602) {
+
+    /// Changing precision of field lastip on table user to (45)
+        $table = new xmldb_table('user');
+        $field = new xmldb_field('lastip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'currentlogin');
+
+    /// Launch change of precision for field lastip
+        $dbman->change_field_precision($table, $field);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010602);
+    }
+
+    if ($result && $oldversion < 2009010603) {
+
+    /// Changing precision of field ip_address on table mnet_host to (45)
+        $table = new xmldb_table('mnet_host');
+        $field = new xmldb_field('ip_address', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'wwwroot');
+
+    /// Launch change of precision for field ip_address
+        $dbman->change_field_precision($table, $field);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010603);
+    }
+
+    if ($result && $oldversion < 2009010604) {
+
+    /// Changing precision of field ip on table mnet_log to (45)
+        $table = new xmldb_table('mnet_log');
+        $field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'userid');
+
+    /// Launch change of precision for field ip
+        $dbman->change_field_precision($table, $field);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009010604);
+    }
+
+    if ($result && $oldversion < 2009010605) {
 
     /// Define table sessions to be dropped
         $table = new xmldb_table('sessions2');
@@ -1175,30 +1250,40 @@ function xmldb_main_upgrade($oldversion) {
             $dbman->drop_table($table);
         }
 
+    /// Define table sessions to be dropped
+        $table = new xmldb_table('sessions');
+
+    /// Conditionally launch drop table for sessions
+        if ($dbman->table_exists($table)) {
+            $dbman->drop_table($table);
+        }
+
     /// Main savepoint reached
-        upgrade_main_savepoint($result, 2008123100);
+        upgrade_main_savepoint($result, 2009010605);
     }
 
-    if ($result && $oldversion < 2008123101) {
+    if ($result && $oldversion < 2009010606) {
 
     /// Define table sessions to be created
         $table = new xmldb_table('sessions');
 
     /// Adding fields to table sessions
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
+        $table->add_field('state', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->add_field('sid', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL, null, null, null, null);
         $table->add_field('sessdata', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
         $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
         $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
         $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->add_field('lastip', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null);
-        $table->add_field('sesskey', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null);
+        $table->add_field('firstip', XMLDB_TYPE_CHAR, '45', null, null, null, null, null, null);
+        $table->add_field('lastip', XMLDB_TYPE_CHAR, '45', null, null, null, null, null, null);
 
     /// Adding keys to table sessions
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
         $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
 
     /// Adding indexes to table sessions
+        $table->add_index('state', XMLDB_INDEX_NOTUNIQUE, array('state'));
         $table->add_index('sid', XMLDB_INDEX_UNIQUE, array('sid'));
         $table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
         $table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
@@ -1207,30 +1292,7 @@ function xmldb_main_upgrade($oldversion) {
         $dbman->create_table($table);
 
     /// Main savepoint reached
-        upgrade_main_savepoint($result, 2008123101);
-    }
-
-    if ($result && $oldversion < 2009010500) {
-    /// clean up config table a bit
-        unset_config('session_error_counter');
-
-    /// Main savepoint reached
-        upgrade_main_savepoint($result, 2009010500);
-    }
-
-    if ($result && $oldversion < 2009010600) {
-
-    /// Define field originalquestion to be dropped from question_states
-        $table = new xmldb_table('question_states');
-        $field = new xmldb_field('originalquestion');
-
-    /// Conditionally launch drop field originalquestion
-        if ($dbman->field_exists($table, $field)) {
-            $dbman->drop_field($table, $field);
-        }
-
-    /// Main savepoint reached
-        upgrade_main_savepoint($result, 2009010600);
+        upgrade_main_savepoint($result, 2009010606);
     }
 
     return $result;
index 1cad1e1fe64e6c0d449365739738ea3aa5daad58..63b9b91e38ac8ab5e5aec6f8644ffdc4cb732a4a 100644 (file)
@@ -70,7 +70,7 @@
         <FIELD NAME="userid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="chatid" NEXT="groupid"/>
         <FIELD NAME="groupid" TYPE="int" LENGTH="11" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="version"/>
         <FIELD NAME="version" TYPE="char" LENGTH="16" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="ip"/>
-        <FIELD NAME="ip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="firstping"/>
+        <FIELD NAME="ip" TYPE="char" LENGTH="45" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="version" NEXT="firstping"/>
         <FIELD NAME="firstping" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ip" NEXT="lastping"/>
         <FIELD NAME="lastping" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="firstping" NEXT="lastmessageping"/>
         <FIELD NAME="lastmessageping" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="lastping" NEXT="sid"/>
index acf4d72a887ce016e778a46d39b1c9c014a5881f..875e6cfd008461a2e2ba2efd1c1ed941e07e6dec 100644 (file)
@@ -58,6 +58,19 @@ function xmldb_chat_upgrade($oldversion) {
         upgrade_mod_savepoint($result, 2008072400, 'chat');
     }
 
+    if ($result && $oldversion < 2009010600) {
+
+    /// Changing precision of field ip on table chat_users to (45)
+        $table = new xmldb_table('chat_users');
+        $field = new xmldb_field('ip', XMLDB_TYPE_CHAR, '45', null, XMLDB_NOTNULL, null, null, null, null, 'version');
+
+    /// Launch change of precision for field ip
+        $dbman->change_field_precision($table, $field);
+
+    /// chat savepoint reached
+        upgrade_mod_savepoint($result, 2009010600, 'chat');
+    }
+
     return $result;
 }
 
index 70e959a59eca6fcf4dd5865c589cbc0dc3a4d7ee..4a38fe6f63009f97f295b12049b9d2fc5cf06a35 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2008081401;   // The (date) version of this module
+$module->version  = 2009010600;   // The (date) version of this module
 $module->requires = 2007101509;  // Requires this Moodle version
 $module->cron     = 300;          // How often should cron check this module (seconds)?
 
index d08cd028f795ad29d6c94d5c6a037e70de6a3497..637d700e4d6598b35179a6eb06a80aad02cb40fe 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2009010600;  // YYYYMMDD   = date of the last version bump
+    $version = 2009010606;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20090106)';  // Human-friendly version name