2 function upgrade_do25() {
3 global $upgrade_failures;
4 //needed as some queries depend on the success of others
6 if (upgrade_checkinstall(25))
7 return 'already installed';
9 // -------------------- 2.0 -> 2.2 (dev only) --------------------
10 // (avoid doing this twice :))
11 if (!upgrade_checkinstall(22)) {
12 // 1. create nucleus_plugin_option_desc table
13 // create new table: nucleus_plugin_option
14 if (!upgrade_checkIfTableExists('plugin_option_desc')) {
15 $query = 'CREATE TABLE '. sql_table('plugin_option_desc') . ' ('
16 ." oid int(11) NOT NULL auto_increment UNIQUE,"
17 ." opid int(11) NOT NULL,"
18 ." oname varchar(20) NOT NULL,"
19 ." ocontext varchar(20) NOT NULL,"
20 ." odesc varchar(255),"
21 ." otype varchar(20),"
24 ." PRIMARY KEY(opid, oname, ocontext)"
26 upgrade_query('Creating ' . sql_table('plugin_option_desc') . ' table',$query);
29 // 2. move all data from plugin_option to plugin_option_desc
30 if (0 == $upgrade_failures){
31 $query = 'DELETE FROM ' . sql_table('plugin_option_desc');
32 upgrade_query('Flushing plugin option descriptions', $query);
33 $query = 'SELECT * FROM ' . sql_table('plugin_option') .' ORDER BY oid ASC';
34 $res = sql_query($query);
36 while ($o = mysql_fetch_object($res)) {
37 $query = 'INSERT INTO ' . sql_table('plugin_option_desc')
38 .' (opid, oname, ocontext, odesc, otype)'
40 ."'".addslashes($o->opid)."',"
41 ."'".addslashes($o->oname) ."',"
43 ."'".addslashes($o->odesc) ."',"
44 ."'".addslashes($o->otype) ."')";
45 upgrade_query('Moving option description for '.htmlspecialchars($o->oname).' to ' . sql_table('plugin_option_desc'), $query);
49 'id' => mysql_insert_id(),
55 // 3. alter plugin_options table
56 if (0 == $upgrade_failures && !upgrade_checkIfColumnExists('plugin_option','ocontextid')) {
57 $query = 'ALTER TABLE ' . sql_table('plugin_option')
61 .' DROP COLUMN oname,'
62 .' DROP COLUMN odesc,'
63 .' DROP COLUMN otype,'
64 .' ADD ocontextid INT(11) NOT NULL,'
65 .' ADD PRIMARY KEY (oid, ocontextid)';
66 upgrade_query('Altering ' . sql_table('plugin_option') . ' table', $query);
68 if(0 == $upgrade_failures){
69 // 4. delete from plugin_options
70 $query = 'DELETE FROM ' . sql_table('plugin_option');
71 upgrade_query('Cleaning ' . sql_table('plugin_option'), $query);
73 // 5. refill plugin_options
74 foreach ($aValues as $aInfo) {
75 $query = 'INSERT INTO ' . sql_table('plugin_option')
76 .' (oid, ocontextid, ovalue)'
77 ." VALUES (".$aInfo['id'].",'0','".addslashes($aInfo['value'])."')";
78 upgrade_query('Re-filling ' . sql_table('plugin_option') . ' ('.$aInfo['id'].')', $query);
84 // -------------------- 2.0 -> 2.5 --------------------
86 if (!upgrade_checkIfIndexExists('item', array('ibody', 'ititle', 'imore'))) {
87 // add fulltext indices for search
88 $query = 'ALTER TABLE ' . sql_table('item') . ' ADD FULLTEXT(ibody, ititle, imore)';
89 upgrade_query('Adding fulltext index to item table', $query);
90 // repair table is needed (build index)
91 upgrade_query('Repairing item table', 'REPAIR TABLE ' . sql_table('item'));
94 if (!upgrade_checkIfIndexExists('comment', array('cbody'))) {
95 $query = 'ALTER TABLE ' . sql_table('comment') . ' ADD FULLTEXT(cbody)';
96 upgrade_query('Adding fulltext index to comments table', $query);
97 upgrade_query('Repairing comment table', 'REPAIR TABLE ' . sql_table('comment'));
100 if (!upgrade_checkinstall(24)) {
101 $query = ' ALTER TABLE ' . sql_table('blog') . ' ADD bincludesearch TINYINT(2) DEFAULT 0';
102 upgrade_query('Adding bincludesearch column to blog', $query);
105 // modify plugin option table value column type to TEXT
106 $query = 'ALTER TABLE ' . sql_table('plugin_option') . ' MODIFY ovalue TEXT NOT NULL default \'\'';
107 upgrade_query('Modifying plugin options column type', $query);
109 // insert External Authentication global option
110 if (!upgrade_checkIfCVExists('ExtAuth')) {
111 $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'ExtAuth\',\'0\')';
112 upgrade_query('Adding External Authentication option to config table', $query);
115 // insert database version (allows us to do better version checking in v3.0 upgrades)
116 // But only if no errors in upgrade
117 if (0 == $upgrade_failures && !upgrade_checkIfCVExists('DatabaseVersion')) {
118 $query = 'INSERT INTO ' . sql_table('config') . ' (name,value) VALUES (\'DatabaseVersion\',\'250\')';
119 upgrade_query('Adding DatabaseVersion to config table', $query);
121 echo "<li>Adding DatabaseVersion to config table ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";