Source for file _functions_evoupgrade.php
Documentation is available at _functions_evoupgrade.php
* This file implements upgrading of DB tables
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
* Create a DB version checkpoint
* This is useful when the next operation might timeout or fail!
* The checkpoint will allow to restart the script and continue where it stopped
* @param string version of DB at checkpoint
global $DB, $script_start_time, $locale;
echo
"Creating DB schema version checkpoint at $version... ";
$query =
'UPDATE T_settings SET db_version = '.
$version;
$query =
"UPDATE T_settings
SET set_value = '$version'
WHERE set_name = 'db_version'";
$elapsed_time =
time() -
$script_start_time;
echo
"OK. (Elapsed upgrade time: $elapsed_time seconds)<br />\n";
$max_exe_time =
ini_get( 'max_execution_time' );
if( $max_exe_time &&
$elapsed_time >
$max_exe_time -
10 )
{ // Max exe time not disabled and we're recahing the end
echo
'We are reaching the time limit for this script. Please click <a href="index.php?locale='.
$locale.
'&action=evoupgrade">continue</a>...';
// Dirty temporary solution:
* @return boolean Does a given index key name exist in DB?
$DB->query('SHOW INDEX FROM '.
$table);
while( $row =
$DB->get_row() )
* @param string Table name
* @param array Column names
* @return boolean Does a list of given column names exist in DB?
foreach( $col_names as $k =>
$v )
foreach( $DB->get_results('SHOW COLUMNS FROM '.
$table) as $row )
unset
( $col_names[$key] );
return count($col_names) ==
0;
* Drops a column, if it exists.
$DB->query( 'ALTER TABLE '.
$table.
' DROP COLUMN '.
$col_name );
* Add a column, if it does not already exist.
* If it exists already, a "ALTER TABLE" statement will get executed instead.
* @return boolean True if the column has been added, False if not.
function db_add_col( $table, $col_name, $col_desc )
{ // Column exists already, make sure it's the same.
$DB->query( 'ALTER TABLE '.
$table.
' MODIFY COLUMN '.
$col_name.
' '.
$col_desc );
$DB->query( 'ALTER TABLE '.
$table.
' ADD COLUMN '.
$col_name.
' '.
$col_desc );
* Add an INDEX. If another index with the same name already exists, it will
function db_add_index( $table, $name, $def, $type =
'INDEX' )
$DB->query( 'ALTER TABLE '.
$table.
' DROP INDEX '.
$name );
$DB->query( 'ALTER TABLE '.
$table.
' ADD '.
$type.
' '.
$name.
' ('.
$def.
')' );
* Converts languages in a given table into according locales
* @param string name of the table
* @param string name of the column where lang is stored
* @param string name of the table's ID column
global $DB, $locales, $default_locale;
if( !preg_match('/[a-z]{2}-[A-Z]{2}(-.{1,14})?/', $default_locale) )
{ // we want a valid locale
$default_locale =
'en-EU';
echo
'Converting langs to locales for '.
$table.
'...<br />';
// query given languages in $table
$query =
"SELECT $columnID, $columnlang FROM $table";
$languagestoconvert =
array();
foreach( $DB->get_results( $query, ARRAY_A ) as $row )
// remember the ID for that locale
$languagestoconvert[ $row[ $columnlang ] ][] =
$row[ $columnID ];
foreach( $languagestoconvert as $lkey =>
$lIDs)
{ // converting the languages we've found
echo
' Converting lang \''.
$lkey.
'\' '; // (with IDs: '. implode( ', ', $lIDs ). ').. ';
if( preg_match('/[a-z]{2}-[A-Z]{2}(-.{1,14})?/', $lkey) )
echo
'nothing to update, already valid!<br />';
if( (strlen($lkey) ==
2) &&
( substr( $default_locale, 0, 2 ) !=
$lkey ) )
{ // we have an old two letter lang code to convert
// and it doesn't match the default locale
foreach( $locales as $newlkey =>
$v )
if( substr($newlkey, 0, 2) ==
strtolower($lkey) ) # TODO: check if valid/suitable
{ // if language matches, update
$converted =
$DB->query( "
SET $columnlang = '$newlkey'
WHERE $columnlang = '$lkey'" );
echo
'to locale \''.
$newlkey.
'\'<br />';
{ // we have nothing converted yet, setting default:
$DB->query( "UPDATE $table
SET $columnlang = '$default_locale'
WHERE $columnlang = '$lkey'" );
echo
'forced to default locale \''.
$default_locale.
'\'<br />';
} // convert_lang_to_locale(-)
* upgrade_b2evo_tables(-)
global $db_config, $tableprefix;
global $baseurl, $old_db_version, $new_db_version;
global $Group_Admins, $Group_Privileged, $Group_Bloggers, $Group_Users;
global $locales, $default_locale;
// used for defaults, when upgrading to 1.6
global $use_fileupload, $fileupload_allowedtypes, $fileupload_maxk, $doubleCheckReferers;
// new DB-delta functionality
global $schema_queries, $inc_path;
// Load DB schema from modules
echo
'<p>'.
T_('Checking DB schema version...').
' ';
if( empty($old_db_version) )
echo
'<p><strong>OOPS! b2evolution doesn\'t seem to be installed yet.</strong></p>';
echo
$old_db_version, ' : ';
if( $old_db_version <
8000 ) debug_die( T_('This version is too old!') );
if( $old_db_version >
$new_db_version ) debug_die( T_('This version is too recent! We cannot downgrade to the version you are trying to install...') );
// Try to obtain some serious time to do some serious processing (5 minutes)
if( $old_db_version <
8010 )
echo
'Upgrading users table... ';
$query =
"ALTER TABLE T_users
MODIFY COLUMN user_pass CHAR(32) NOT NULL";
echo
'Upgrading blogs table... ';
$query =
"ALTER TABLE T_blogs
MODIFY COLUMN blog_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',
MODIFY COLUMN blog_longdesc TEXT NULL DEFAULT NULL";
echo
'Upgrading categories table... ';
$query =
"ALTER TABLE T_categories
ADD COLUMN cat_description VARCHAR(250) NULL DEFAULT NULL,
ADD COLUMN cat_longdesc TEXT NULL DEFAULT NULL,
ADD COLUMN cat_icon VARCHAR(30) NULL DEFAULT NULL";
echo
'Upgrading posts table... ';
$query =
"ALTER TABLE {$tableprefix}posts
MODIFY COLUMN post_lang VARCHAR(20) NOT NULL DEFAULT 'en_US',
ADD COLUMN post_urltitle VARCHAR(50) NULL DEFAULT NULL AFTER post_title,
ADD COLUMN post_url VARCHAR(250) NULL DEFAULT NULL AFTER post_urltitle,
ADD COLUMN post_comments ENUM('disabled', 'open', 'closed') NOT NULL DEFAULT 'open' AFTER post_wordcount";
echo
'Generating wordcounts... ';
$query =
"SELECT ID, post_content FROM {$tableprefix}posts WHERE post_wordcount IS NULL";
foreach( $DB->get_results( $query, ARRAY_A ) as $row )
$query_update_wordcount =
"UPDATE {$tableprefix}posts
WHERE ID = " .
$row['ID'];
$DB->query($query_update_wordcount);
echo
"OK. ($i rows updated)<br />\n";
if( $old_db_version <
8020 )
echo
'Encoding passwords... ';
SET user_pass = MD5(user_pass)";
if( $old_db_version <
8030 )
echo
'Deleting unecessary logs... ';
$query =
"DELETE FROM T_hitlog
WHERE hit_ignore = 'badchar'";
echo
'Updating blog urls... ';
$query =
"SELECT blog_ID, blog_siteurl FROM T_blogs";
foreach( $DB->get_results( $query, ARRAY_A ) as $row )
$blog_ID =
$row['blog_ID'];
$blog_siteurl =
$row['blog_siteurl'];
// echo $blog_ID.':'.$blog_siteurl;
if( strpos( $blog_siteurl.
'/', $baseurl ) !==
0 )
{ // If not found at position 0
echo
' <strong>WARNING: please check blog #', $blog_ID, ' manually.</strong><br /> ';
$blog_siteurl =
substr( $blog_siteurl.
'/', strlen( $baseurl) );
// echo ' -> ', $blog_siteurl,'<br />';
$query_update_blog =
"UPDATE T_blogs SET blog_siteurl = '$blog_siteurl' WHERE blog_ID = $blog_ID";
// echo $query_update_blog, '<br />';
$DB->query( $query_update_blog );
echo
"OK. ($i rows updated)<br />\n";
if( $old_db_version <
8040 )
echo
'Creating table for Antispam Blackist... ';
$query =
"CREATE TABLE T_antispam (
aspm_ID bigint(11) NOT NULL auto_increment,
aspm_string varchar(80) NOT NULL,
aspm_source enum( 'local','reported','central' ) NOT NULL default 'reported',
PRIMARY KEY aspm_ID (aspm_ID),
UNIQUE aspm_string (aspm_string)
echo
'Creating default blacklist entries... ';
// This string contains antispam information that is obfuscated because some hosting
// companies prevent uploading PHP files containing "spam" strings.
// pre_dump(get_antispam_query());
echo
'Upgrading Settings table... ';
$query =
"ALTER TABLE T_settings
ADD COLUMN last_antispam_update datetime NOT NULL default '2000-01-01 00:00:00'";
if( $old_db_version <
8050 )
echo
'Upgrading blogs table... ';
$query =
"ALTER TABLE T_blogs
ADD COLUMN blog_allowtrackbacks tinyint(1) NOT NULL default 1,
ADD COLUMN blog_allowpingbacks tinyint(1) NOT NULL default 0,
ADD COLUMN blog_pingb2evonet tinyint(1) NOT NULL default 0,
ADD COLUMN blog_pingtechnorati tinyint(1) NOT NULL default 0,
ADD COLUMN blog_pingweblogs tinyint(1) NOT NULL default 0,
ADD COLUMN blog_pingblodotgs tinyint(1) NOT NULL default 0,
ADD COLUMN blog_disp_bloglist tinyint NOT NULL DEFAULT 1";
global $Group_Admins, $Group_Privileged, $Group_Bloggers, $Group_Users;
echo
'Creating table for Groups... ';
$query =
"CREATE TABLE T_groups (
grp_ID int(11) NOT NULL auto_increment,
grp_name varchar(50) NOT NULL default '',
grp_perm_admin enum('none','hidden','visible') NOT NULL default 'visible',
grp_perm_blogs enum('user','viewall','editall') NOT NULL default 'user',
grp_perm_stats enum('none','view','edit') NOT NULL default 'none',
grp_perm_spamblacklist enum('none','view','edit') NOT NULL default 'none',
grp_perm_options enum('none','view','edit') NOT NULL default 'none',
grp_perm_users enum('none','view','edit') NOT NULL default 'none',
grp_perm_templates TINYINT NOT NULL DEFAULT 0,
grp_perm_files enum('none','view','add','edit') NOT NULL default 'none',
PRIMARY KEY grp_ID (grp_ID)
echo
'Creating default groups... ';
$Group_Admins =
new Group(); // COPY !
$Group_Admins->set( 'name', 'Administrators' );
$Group_Admins->set( 'perm_admin', 'visible' );
$Group_Admins->set( 'perm_blogs', 'editall' );
$Group_Admins->set( 'perm_stats', 'edit' );
$Group_Admins->set( 'perm_spamblacklist', 'edit' );
$Group_Admins->set( 'perm_files', 'all' );
$Group_Admins->set( 'perm_options', 'edit' );
$Group_Admins->set( 'perm_templates', 1 );
$Group_Admins->set( 'perm_users', 'edit' );
$Group_Admins->dbinsert();
$Group_Privileged =
new Group(); // COPY !
$Group_Privileged->set( 'name', 'Privileged Bloggers' );
$Group_Privileged->set( 'perm_admin', 'visible' );
$Group_Privileged->set( 'perm_blogs', 'viewall' );
$Group_Privileged->set( 'perm_stats', 'view' );
$Group_Privileged->set( 'perm_spamblacklist', 'edit' );
$Group_Privileged->set( 'perm_files', 'add' );
$Group_Privileged->set( 'perm_options', 'view' );
$Group_Privileged->set( 'perm_templates', 0 );
$Group_Privileged->set( 'perm_users', 'view' );
$Group_Privileged->dbinsert();
$Group_Bloggers =
new Group(); // COPY !
$Group_Bloggers->set( 'name', 'Bloggers' );
$Group_Bloggers->set( 'perm_admin', 'visible' );
$Group_Bloggers->set( 'perm_blogs', 'user' );
$Group_Bloggers->set( 'perm_stats', 'none' );
$Group_Bloggers->set( 'perm_spamblacklist', 'view' );
$Group_Bloggers->set( 'perm_files', 'view' );
$Group_Bloggers->set( 'perm_options', 'none' );
$Group_Bloggers->set( 'perm_templates', 0 );
$Group_Bloggers->set( 'perm_users', 'none' );
$Group_Bloggers->dbinsert();
$Group_Users =
new Group(); // COPY !
$Group_Users->set( 'name', 'Basic Users' );
$Group_Users->set( 'perm_admin', 'none' );
$Group_Users->set( 'perm_blogs', 'user' );
$Group_Users->set( 'perm_stats', 'none' );
$Group_Users->set( 'perm_spamblacklist', 'none' );
$Group_Users->set( 'perm_files', 'none' );
$Group_Users->set( 'perm_options', 'none' );
$Group_Users->set( 'perm_templates', 0 );
$Group_Users->set( 'perm_users', 'none' );
$Group_Users->dbinsert();
echo
'Creating table for Blog-User permissions... ';
$query =
"CREATE TABLE T_coll_user_perms (
bloguser_blog_ID int(11) unsigned NOT NULL default 0,
bloguser_user_ID int(11) unsigned NOT NULL default 0,
bloguser_ismember tinyint NOT NULL default 0,
bloguser_perm_poststatuses set('published','deprecated','protected','private','draft') NOT NULL default '',
bloguser_perm_delpost tinyint NOT NULL default 0,
bloguser_perm_comments tinyint NOT NULL default 0,
bloguser_perm_cats tinyint NOT NULL default 0,
bloguser_perm_properties tinyint NOT NULL default 0,
bloguser_perm_media_upload tinyint NOT NULL default 0,
bloguser_perm_media_browse tinyint NOT NULL default 0,
bloguser_perm_media_change tinyint NOT NULL default 0,
PRIMARY KEY bloguser_pk (bloguser_blog_ID,bloguser_user_ID)
$tablegroups_isuptodate =
true;
$tableblogusers_isuptodate =
true;
echo
'Creating user blog permissions... ';
// Admin: full rights for all blogs (look 'ma, doing a natural join! :>)
$query =
"INSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,
bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments,
bloguser_perm_cats, bloguser_perm_properties)
SELECT blog_ID, ID, 1, 'published,deprecated,protected,private,draft', 1, 1, 1, 1
// Normal users: basic rights for all blogs (can't stop doing joins :P)
$query =
"INSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,
bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments,
bloguser_perm_cats, bloguser_perm_properties)
SELECT blog_ID, ID, 1, 'published,protected,private,draft', 0, 1, 0, 0
WHERE user_level > 0 AND user_level < 10";
echo
'Upgrading users table... ';
$query =
"ALTER TABLE T_users
ADD COLUMN user_notify tinyint(1) NOT NULL default 1,
ADD COLUMN user_grp_ID int(4) NOT NULL default 1,
MODIFY COLUMN user_idmode varchar(20) NOT NULL DEFAULT 'login',
ADD KEY user_grp_ID (user_grp_ID)";
echo
'Assigning user groups... ';
// Default is 1, so admins are already set.
SET user_grp_ID = $Group_Users->ID
SET user_grp_ID = $Group_Bloggers->ID
WHERE user_level > 0 AND user_level < 10";
echo
'Upgrading settings table... ';
$query =
"ALTER TABLE T_settings
ADD COLUMN pref_newusers_grp_ID int unsigned DEFAULT 4 NOT NULL,
ADD COLUMN pref_newusers_level tinyint unsigned DEFAULT 1 NOT NULL,
ADD COLUMN pref_newusers_canregister tinyint unsigned DEFAULT 0 NOT NULL";
echo
'Creating default groups... ';
$Group_Admins =
new Group(); // COPY !
$Group_Admins->set( 'name', 'Administrators' );
$Group_Admins->set( 'perm_admin', 'visible' );
$Group_Admins->set( 'perm_blogs', 'editall' );
$Group_Admins->set( 'perm_stats', 'edit' );
$Group_Admins->set( 'perm_spamblacklist', 'edit' );
$Group_Admins->set( 'perm_files', 'all' );
$Group_Admins->set( 'perm_options', 'edit' );
$Group_Admins->set( 'perm_templates', 1 );
$Group_Admins->set( 'perm_users', 'edit' );
$Group_Admins->dbinsert();
$Group_Privileged =
new Group(); // COPY !
$Group_Privileged->set( 'name', 'Privileged Bloggers' );
$Group_Privileged->set( 'perm_admin', 'visible' );
$Group_Privileged->set( 'perm_blogs', 'viewall' );
$Group_Privileged->set( 'perm_stats', 'view' );
$Group_Privileged->set( 'perm_spamblacklist', 'edit' );
$Group_Privileged->set( 'perm_files', 'add' );
$Group_Privileged->set( 'perm_options', 'view' );
$Group_Privileged->set( 'perm_templates', 0 );
$Group_Privileged->set( 'perm_users', 'view' );
$Group_Privileged->dbinsert();
$Group_Bloggers =
new Group(); // COPY !
$Group_Bloggers->set( 'name', 'Bloggers' );
$Group_Bloggers->set( 'perm_admin', 'visible' );
$Group_Bloggers->set( 'perm_blogs', 'user' );
$Group_Bloggers->set( 'perm_stats', 'none' );
$Group_Bloggers->set( 'perm_spamblacklist', 'view' );
$Group_Bloggers->set( 'perm_files', 'view' );
$Group_Bloggers->set( 'perm_options', 'none' );
$Group_Bloggers->set( 'perm_templates', 0 );
$Group_Bloggers->set( 'perm_users', 'none' );
$Group_Bloggers->dbinsert();
$Group_Users =
new Group(); // COPY !
$Group_Users->set( 'name', 'Basic Users' );
$Group_Users->set( 'perm_admin', 'none' );
$Group_Users->set( 'perm_blogs', 'user' );
$Group_Users->set( 'perm_stats', 'none' );
$Group_Users->set( 'perm_spamblacklist', 'none' );
$Group_Users->set( 'perm_files', 'none' );
$Group_Users->set( 'perm_options', 'none' );
$Group_Users->set( 'perm_templates', 0 );
$Group_Users->set( 'perm_users', 'none' );
$Group_Users->dbinsert();
if( $old_db_version <
8060 )
$stub_list =
$DB->get_col( "
echo
'<div class="error"><p class="error">';
printf( T_("It appears that the following blog stub names are used more than once: ['%s']" ), implode( "','", $stub_list ) );
printf( T_("I can't upgrade until you make them unique. DB field: [%s]" ), $db_config['aliases']['T_blogs'].
'.blog_stub' );
echo
'Creating table for Locales... ';
$query =
"CREATE TABLE T_locales (
loc_locale varchar(20) NOT NULL default '',
loc_charset varchar(15) NOT NULL default 'iso-8859-1',
loc_datefmt varchar(10) NOT NULL default 'y-m-d',
loc_timefmt varchar(10) NOT NULL default 'H:i:s',
loc_name varchar(40) NOT NULL default '',
loc_messages varchar(20) NOT NULL default '',
loc_priority tinyint(4) UNSIGNED NOT NULL default '0',
loc_enabled tinyint(4) NOT NULL default '1',
PRIMARY KEY loc_locale( loc_locale )
) COMMENT='saves available locales'";
echo
'Upgrading posts table... ';
$query =
"UPDATE {$tableprefix}posts
SET post_urltitle = NULL";
$query =
"ALTER TABLE {$tableprefix}posts
CHANGE COLUMN post_date post_issue_date datetime NOT NULL default '1000-01-01 00:00:00',
ADD COLUMN post_mod_date datetime NOT NULL default '1000-01-01 00:00:00'
CHANGE COLUMN post_lang post_locale varchar(20) NOT NULL default 'en-EU',
CHANGE COLUMN post_trackbacks post_url varchar(250) NULL default NULL,
MODIFY COLUMN post_flags SET( 'pingsdone', 'imported' ),
ADD COLUMN post_renderers VARCHAR(179) NOT NULL default 'default',
ADD INDEX post_issue_date( post_issue_date ),
ADD UNIQUE post_urltitle( post_urltitle )";
$query =
"UPDATE {$tableprefix}posts
SET post_mod_date = post_issue_date";
// convert given languages to locales
echo
'Upgrading blogs table... ';
$query =
"ALTER TABLE T_blogs
CHANGE blog_lang blog_locale varchar(20) NOT NULL default 'en-EU',
CHANGE blog_roll blog_notes TEXT NULL,
MODIFY COLUMN blog_default_skin VARCHAR(30) NOT NULL DEFAULT 'custom',
DROP COLUMN blog_filename,
ADD COLUMN blog_access_type VARCHAR(10) NOT NULL DEFAULT 'index.php' AFTER blog_locale,
ADD COLUMN blog_force_skin tinyint(1) NOT NULL default 0 AFTER blog_default_skin,
ADD COLUMN blog_in_bloglist tinyint(1) NOT NULL DEFAULT 1 AFTER blog_disp_bloglist,
ADD COLUMN blog_links_blog_ID INT(4) NOT NULL DEFAULT 0,
ADD UNIQUE KEY blog_stub (blog_stub)";
SET blog_access_type = 'stub',
blog_default_skin = 'custom'";
// convert given languages to locales
echo
'Converting settings table... ';
$query =
'SELECT * FROM T_settings';
$row =
$DB->get_row( $query, ARRAY_A );
#echo 'oldrow:<br />'; pre_dump($row);
'posts_per_page' =>
array(5), // note: moved to blogsettings in 2.0
'what_to_show' =>
array('posts'), // note: moved to blogsettings in 2.0
'archive_mode' =>
array('monthly'),// note: moved to blogsettings in 2.0
'time_difference' =>
array(0),
'last_antispam_update' =>
array('2000-01-01 00:00:00', 'antispam_last_update'),
'pref_newusers_grp_ID' =>
array($Group_Users->ID, 'newusers_grp_ID'),
'pref_newusers_level' =>
array(1, 'newusers_level'),
'pref_newusers_canregister' =>
array(0, 'newusers_canregister'),
foreach( $transform as $oldkey =>
$newarr )
$newname =
( isset
($newarr[1]) ?
$newarr[1] :
$oldkey );
if( !isset
( $row[$oldkey] ) )
echo
' ·Setting '.
$oldkey.
' not found, using defaults.<br />';
$_trans[ $newname ] =
$newarr[0];
$_trans[ $newname ] =
$row[$oldkey];
$DB->query( 'DROP TABLE IF EXISTS T_settings' );
'CREATE TABLE T_settings (
set_name VARCHAR( 30 ) NOT NULL ,
set_value VARCHAR( 255 ) NULL ,
// insert defaults and use transformed settings
if( !isset
( $tableblogusers_isuptodate ) )
echo
'Upgrading Blog-User permissions table... ';
$query =
"ALTER TABLE T_coll_user_perms
ADD COLUMN bloguser_ismember tinyint NOT NULL default 0 AFTER bloguser_user_ID";
// Any row that is created holds at least one permission,
// minimum permsission is to be a member, so we add that one too, to all existing rows.
$DB->query( "UPDATE T_coll_user_perms
SET bloguser_ismember = 1" );
echo
'Upgrading Comments table... ';
$query =
"ALTER TABLE T_comments
ADD COLUMN comment_author_ID int unsigned NULL default NULL AFTER comment_status,
MODIFY COLUMN comment_author varchar(100) NULL,
MODIFY COLUMN comment_author_email varchar(100) NULL,
MODIFY COLUMN comment_author_url varchar(100) NULL,
MODIFY COLUMN comment_author_IP varchar(23) NOT NULL default ''";
echo
'Upgrading Users table... ';
$query =
"ALTER TABLE T_users ADD user_locale VARCHAR( 20 ) DEFAULT 'en-EU' NOT NULL AFTER user_yim";
if( $old_db_version <
8062 )
echo
"Checking for extra quote escaping in posts... ";
$query =
"SELECT ID, post_title, post_content
WHERE post_title LIKE '%\\\\\\\\\'%'
OR post_title LIKE '%\\\\\\\\\"%'
OR post_content LIKE '%\\\\\\\\\'%'
OR post_content LIKE '%\\\\\\\\\"%' ";
/* FP: the above looks overkill, but MySQL is really full of surprises...
$rows =
$DB->get_results( $query, ARRAY_A );
echo
'Updating '.
$DB->num_rows.
' posts... ';
// echo '<br />'.$row['post_title'];
$query =
"UPDATE {$tableprefix}posts
SET post_title = ".
$DB->quote( stripslashes( $row['post_title'] ) ).
",
post_content = ".
$DB->quote( stripslashes( $row['post_content'] ) ).
"
if( $old_db_version <
8064 )
if( $old_db_version <
8066 )
echo
'Adding catpost index... ';
$DB->query( 'ALTER TABLE T_postcats ADD UNIQUE catpost ( postcat_cat_ID, postcat_post_ID )' );
if( $old_db_version <
8800 )
{ // ---------------------------------- upgrade to 1.6 "phoenix ALPHA"
echo
'Dropping old Hitlog table... ';
$DB->query( 'DROP TABLE IF EXISTS T_hitlog' );
echo
'Creating table for active sessions... ';
$DB->query( "CREATE TABLE T_sessions (
sess_ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
sess_lastseen DATETIME NOT NULL,
sess_ipaddress VARCHAR(15) NOT NULL DEFAULT '',
sess_user_ID INT(10) DEFAULT NULL,
sess_agnt_ID INT UNSIGNED NULL,
sess_data TEXT DEFAULT NULL,
echo
'Creating user settings table... ';
$DB->query( "CREATE TABLE T_usersettings (
uset_user_ID INT(11) UNSIGNED NOT NULL,
uset_name VARCHAR( 30 ) NOT NULL,
uset_value VARCHAR( 255 ) NULL,
PRIMARY KEY ( uset_user_ID, uset_name )
echo
'Creating plugins table... ';
$DB->query( "CREATE TABLE T_plugins (
plug_ID INT(11) UNSIGNED NOT NULL auto_increment,
plug_priority INT(11) NOT NULL default 50,
plug_classname VARCHAR(40) NOT NULL default '',
echo
'Creating table for Post Statuses... ';
$query=
"CREATE TABLE {$tableprefix}poststatuses (
pst_ID int(11) unsigned not null AUTO_INCREMENT,
pst_name varchar(30) not null,
echo
'Creating table for Post Types... ';
$query=
"CREATE TABLE {$tableprefix}posttypes (
ptyp_ID int(11) unsigned not null AUTO_INCREMENT,
ptyp_name varchar(30) not null,
echo
'Creating table for File Meta Data... ';
$DB->query( "CREATE TABLE T_files (
file_ID int(11) unsigned not null AUTO_INCREMENT,
file_root_type enum('absolute','user','group','collection') not null default 'absolute',
file_root_ID int(11) unsigned not null default 0,
file_path varchar(255) not null default '',
unique file (file_root_type, file_root_ID, file_path)
echo
'Creating table for base domains... ';
$DB->query( "CREATE TABLE T_basedomains (
dom_ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
dom_name VARCHAR(250) NOT NULL DEFAULT '',
dom_status ENUM('unknown','whitelist','blacklist') NOT NULL DEFAULT 'unknown',
dom_type ENUM('unknown','normal','searcheng','aggregator') NOT NULL DEFAULT 'unknown',
UNIQUE dom_name (dom_name)
)" ); // fp> the unique key was only named in version 1.9. Crap. Put the name back here to save as many souls as possible. bulk has not upgraded from 0.9 yet :/
if( $old_db_version <
8840 )
echo
'Creating table for user agents... ';
$DB->query( "CREATE TABLE T_useragents (
agnt_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
agnt_signature VARCHAR(250) NOT NULL,
agnt_type ENUM('rss','robot','browser','unknown') DEFAULT 'unknown' NOT NULL,
PRIMARY KEY (agnt_ID) )" );
echo
'Creating table for Hit-Logs... ';
$query =
"CREATE TABLE T_hitlog (
hit_ID INT(11) NOT NULL AUTO_INCREMENT,
hit_sess_ID INT UNSIGNED,
hit_datetime DATETIME NOT NULL,
hit_uri VARCHAR(250) DEFAULT NULL,
hit_referer_type ENUM('search','blacklist','referer','direct','spam') NOT NULL,
hit_referer VARCHAR(250) DEFAULT NULL,
hit_referer_dom_ID INT UNSIGNED DEFAULT NULL,
hit_blog_ID int(11) UNSIGNED NULL DEFAULT NULL,
hit_remote_addr VARCHAR(40) DEFAULT NULL,
INDEX hit_datetime ( hit_datetime ),
INDEX hit_blog_ID (hit_blog_ID)
echo
'Creating table for subscriptions... ';
$DB->query( "CREATE TABLE T_subscriptions (
sub_coll_ID int(11) unsigned not null,
sub_user_ID int(11) unsigned not null,
sub_items tinyint(1) not null,
sub_comments tinyint(1) not null,
primary key (sub_coll_ID, sub_user_ID)
echo
'Creating table for blog-group permissions... ';
$DB->query( "CREATE TABLE T_coll_group_perms (
bloggroup_blog_ID int(11) unsigned NOT NULL default 0,
bloggroup_group_ID int(11) unsigned NOT NULL default 0,
bloggroup_ismember tinyint NOT NULL default 0,
bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft') NOT NULL default '',
bloggroup_perm_delpost tinyint NOT NULL default 0,
bloggroup_perm_comments tinyint NOT NULL default 0,
bloggroup_perm_cats tinyint NOT NULL default 0,
bloggroup_perm_properties tinyint NOT NULL default 0,
bloggroup_perm_media_upload tinyint NOT NULL default 0,
bloggroup_perm_media_browse tinyint NOT NULL default 0,
bloggroup_perm_media_change tinyint NOT NULL default 0,
PRIMARY KEY bloggroup_pk (bloggroup_blog_ID,bloggroup_group_ID) )" );
echo
'Upgrading blogs table... ';
$query =
"ALTER TABLE T_blogs
MODIFY COLUMN blog_ID int(11) unsigned NOT NULL auto_increment,
MODIFY COLUMN blog_links_blog_ID INT(11) NULL DEFAULT NULL,
CHANGE COLUMN blog_stub blog_urlname VARCHAR(255) NOT NULL DEFAULT 'urlname',
ADD COLUMN blog_allowcomments VARCHAR(20) NOT NULL default 'post_by_post' AFTER blog_keywords,
ADD COLUMN blog_allowblogcss TINYINT(1) NOT NULL default 1 AFTER blog_allowpingbacks,
ADD COLUMN blog_allowusercss TINYINT(1) NOT NULL default 1 AFTER blog_allowblogcss,
ADD COLUMN blog_stub VARCHAR(255) NOT NULL DEFAULT 'stub' AFTER blog_staticfilename,
ADD COLUMN blog_commentsexpire INT(4) NOT NULL DEFAULT 0 AFTER blog_links_blog_ID,
ADD COLUMN blog_media_location ENUM( 'default', 'subdir', 'custom', 'none' ) DEFAULT 'default' NOT NULL AFTER blog_commentsexpire,
ADD COLUMN blog_media_subdir VARCHAR( 255 ) NOT NULL AFTER blog_media_location,
ADD COLUMN blog_media_fullpath VARCHAR( 255 ) NOT NULL AFTER blog_media_subdir,
ADD COLUMN blog_media_url VARCHAR(255) NOT NULL AFTER blog_media_fullpath,
ADD UNIQUE blog_urlname ( blog_urlname )";
if( $old_db_version <
8850 )
echo
'Updating relative URLs... ';
// We need to move the slashes to the end:
SET blog_siteurl = CONCAT( SUBSTRING(blog_siteurl,2) , '/' )
WHERE blog_siteurl LIKE '/%'";
echo
'Copying urlnames to stub names... ';
SET blog_stub = blog_urlname';
if( $old_db_version <
8855 )
echo
'Upgrading posts table... ';
$query =
"ALTER TABLE {$tableprefix}posts
DROP INDEX post_issue_date,
DROP INDEX post_category,
CHANGE COLUMN ID post_ID int(11) unsigned NOT NULL auto_increment,
CHANGE COLUMN post_author post_creator_user_ID int(11) unsigned NOT NULL,
CHANGE COLUMN post_issue_date post_datestart datetime NOT NULL,
CHANGE COLUMN post_mod_date post_datemodified datetime NOT NULL,
CHANGE COLUMN post_category post_main_cat_ID int(11) unsigned NOT NULL,
ADD post_parent_ID int(11) unsigned NULL AFTER post_ID,
ADD post_lastedit_user_ID int(11) unsigned NULL AFTER post_creator_user_ID,
ADD post_assigned_user_ID int(11) unsigned NULL AFTER post_lastedit_user_ID,
ADD post_datedeadline datetime NULL AFTER post_datestart,
ADD post_datecreated datetime NULL AFTER post_datedeadline,
ADD post_pst_ID int(11) unsigned NULL AFTER post_status,
ADD post_ptyp_ID int(11) unsigned NULL AFTER post_pst_ID,
ADD post_views int(11) unsigned NOT NULL DEFAULT 0 AFTER post_flags,
ADD post_commentsexpire datetime DEFAULT NULL AFTER post_comments,
ADD post_priority int(11) unsigned null,
ADD INDEX post_creator_user_ID( post_creator_user_ID ),
ADD INDEX post_parent_ID( post_parent_ID ),
ADD INDEX post_assigned_user_ID( post_assigned_user_ID ),
ADD INDEX post_datestart( post_datestart ),
ADD INDEX post_main_cat_ID( post_main_cat_ID ),
ADD INDEX post_ptyp_ID( post_ptyp_ID ),
ADD INDEX post_pst_ID( post_pst_ID ) ";
if( $old_db_version <
8860 )
echo
'Updating post data... ';
$query =
"UPDATE {$tableprefix}posts
SET post_lastedit_user_ID = post_creator_user_ID,
post_datecreated = post_datestart";
$DB->query( 'UPDATE T_users
SET dateYMDhour = \'2000-01-01 00:00:00\'
WHERE dateYMDhour = \'0000-00-00 00:00:00\'' );
$DB->query( 'ALTER TABLE T_users
MODIFY COLUMN dateYMDhour DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
CHANGE COLUMN ID user_ID int(11) unsigned NOT NULL auto_increment,
MODIFY COLUMN user_icq int(11) unsigned DEFAULT 0 NOT NULL,
ADD COLUMN user_showonline tinyint(1) NOT NULL default 1 AFTER user_notify' );
if( $old_db_version <
8900 )
echo
'Setting new defaults... ';
$query =
'INSERT INTO T_settings (set_name, set_value)
( "reloadpage_timeout", "300" ),
( "upload_enabled", "'.
(isset
($use_fileupload) ? (int)
$use_fileupload :
'1').
'" ),
( "upload_allowedext", "'.
(isset
($fileupload_allowedtypes) ?
$fileupload_allowedtypes :
'jpg gif png').
'" ),
( "upload_maxkb", "'.
(isset
($fileupload_maxk) ? (int)
$fileupload_maxk :
'96').
'" )
// Replace "paged" mode with "posts" // note: moved to blogsettings in 2.0
$DB->query( 'UPDATE T_settings
WHERE set_name = "what_to_show"
AND set_value = "paged"' );
if( !isset
( $tableblogusers_isuptodate ) )
{ // We have created the blogusers table before and it's already clean!
echo
'Altering table for Blog-User permissions... ';
$DB->query( 'ALTER TABLE T_coll_user_perms
MODIFY COLUMN bloguser_blog_ID int(11) unsigned NOT NULL default 0,
MODIFY COLUMN bloguser_user_ID int(11) unsigned NOT NULL default 0,
ADD COLUMN bloguser_perm_media_upload tinyint NOT NULL default 0,
ADD COLUMN bloguser_perm_media_browse tinyint NOT NULL default 0,
ADD COLUMN bloguser_perm_media_change tinyint NOT NULL default 0' );
$DB->query( 'UPDATE T_comments
SET comment_date = \'2000-01-01 00:00:00\'
WHERE comment_date = \'0000-00-00 00:00:00\'' );
$DB->query( 'ALTER TABLE T_comments
MODIFY COLUMN comment_date DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
MODIFY COLUMN comment_post_ID int(11) unsigned NOT NULL default 0' );
if( $old_db_version <
9000 )
echo
'Altering Posts to Categories table... ';
$DB->query( "ALTER TABLE T_postcats
MODIFY COLUMN postcat_post_ID int(11) unsigned NOT NULL,
MODIFY COLUMN postcat_cat_ID int(11) unsigned NOT NULL" );
echo
'Altering Categories table... ';
$DB->query( "ALTER TABLE T_categories
MODIFY COLUMN cat_ID int(11) unsigned NOT NULL auto_increment,
MODIFY COLUMN cat_parent_ID int(11) unsigned NULL,
MODIFY COLUMN cat_blog_ID int(11) unsigned NOT NULL default 2" );
echo
'Altering Locales table... ';
$DB->query( 'ALTER TABLE T_locales
ADD loc_startofweek TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER loc_timefmt' );
if( !isset
( $tablegroups_isuptodate ) )
{ // We have created the groups table before and it's already clean!
echo
'Altering Groups table... ';
$DB->query( "ALTER TABLE T_groups
ADD COLUMN grp_perm_admin enum('none','hidden','visible') NOT NULL default 'visible' AFTER grp_name,
ADD COLUMN grp_perm_files enum('none','view','add','edit') NOT NULL default 'none'" );
echo
'Creating table for Post Links... ';
$DB->query( "CREATE TABLE T_links (
link_ID int(11) unsigned not null AUTO_INCREMENT,
link_datecreated datetime not null,
link_datemodified datetime not null,
link_creator_user_ID int(11) unsigned not null,
link_lastedit_user_ID int(11) unsigned not null,
link_item_ID int(11) unsigned NOT NULL,
link_dest_item_ID int(11) unsigned NULL,
link_file_ID int(11) unsigned NULL,
link_ltype_ID int(11) unsigned NOT NULL default 1,
link_external_url VARCHAR(255) NULL,
INDEX link_item_ID( link_item_ID ),
INDEX link_dest_item_ID (link_dest_item_ID),
INDEX link_file_ID (link_file_ID)
echo
'Creating default Post Types... ';
INSERT INTO {$tableprefix}posttypes ( ptyp_ID, ptyp_name )
if( $old_db_version <
9100 )
echo
'Creating table for plugin events... ';
CREATE TABLE T_pluginevents(
pevt_plug_ID INT(11) UNSIGNED NOT NULL,
pevt_event VARCHAR(40) NOT NULL,
pevt_enabled TINYINT NOT NULL DEFAULT 1,
PRIMARY KEY( pevt_plug_ID, pevt_event )
echo
'Altering Links table... ';
$DB->query( 'ALTER TABLE T_links
CHANGE link_item_ID link_itm_ID INT( 11 ) UNSIGNED NOT NULL,
CHANGE link_dest_item_ID link_dest_itm_ID INT( 11 ) UNSIGNED NULL' );
if( $old_db_version >=
9000 )
{ // sess_agnt_ID used in Phoenix-Alpha
echo
'Altering sessions table... ';
DROP COLUMN sess_agnt_ID";
echo
'Creating table for file types... ';
CREATE TABLE T_filetypes (
ftyp_ID int(11) unsigned NOT NULL auto_increment,
ftyp_extensions varchar(30) NOT NULL,
ftyp_name varchar(30) NOT NULL,
ftyp_mimetype varchar(50) NOT NULL,
ftyp_icon varchar(20) default NULL,
ftyp_viewtype varchar(10) NOT NULL,
ftyp_allowed tinyint(1) NOT NULL default 0,
echo
'Creating default file types... ';
// TODO: dh> shouldn't they get localized to the app's default locale?
$DB->query( "INSERT INTO T_filetypes
(ftyp_ID, ftyp_extensions, ftyp_name, ftyp_mimetype, ftyp_icon, ftyp_viewtype, ftyp_allowed)
(1, 'gif', 'GIF image', 'image/gif', 'image2.png', 'image', 1),
(2, 'png', 'PNG image', 'image/png', 'image2.png', 'image', 1),
(3, 'jpg jpeg', 'JPEG image', 'image/jpeg', 'image2.png', 'image', 1),
(4, 'txt', 'Text file', 'text/plain', 'document.png', 'text', 1),
(5, 'htm html', 'HTML file', 'text/html', 'html.png', 'browser', 0),
(6, 'pdf', 'PDF file', 'application/pdf', 'pdf.png', 'browser', 1),
(7, 'doc', 'Microsoft Word file', 'application/msword', 'doc.gif', 'external', 1),
(8, 'xls', 'Microsoft Excel file', 'application/vnd.ms-excel', 'xls.gif', 'external', 1),
(9, 'ppt', 'Powerpoint', 'application/vnd.ms-powerpoint', 'ppt.gif', 'external', 1),
(10, 'pps', 'Slideshow', 'pps', 'pps.gif', 'external', 1),
(11, 'zip', 'ZIP archive', 'application/zip', 'zip.gif', 'external', 1),
(12, 'php php3 php4 php5 php6', 'PHP script', 'application/x-httpd-php', 'php.gif', 'text', 0),
(13, 'css', 'Style sheet', 'text/css', '', 'text', 1)
echo
'Giving Administrator Group edit perms on files... ';
$DB->query( 'UPDATE T_groups
SET grp_perm_files = "edit"
// Later versions give 'all' on install, but we won't upgrade to that for security.
echo
'Giving Administrator Group full perms on media for all blogs... ';
$DB->query( 'UPDATE T_coll_group_perms
SET bloggroup_perm_media_upload = 1,
bloggroup_perm_media_browse = 1,
bloggroup_perm_media_change = 1
WHERE bloggroup_group_ID = 1' );
if( $old_db_version >=
9000 )
{ // Uninstall all ALPHA (potentially incompatible) plugins
echo
'Uninstalling all existing plugins... ';
$DB->query( 'DELETE FROM T_plugins WHERE 1=1' );
// NOTE: basic plugins get installed separatly for upgrade and install..
if( $old_db_version <
9190 ) // Note: changed from 9200, to include the block below, if DB is not yet on 1.8
{ // 1.8 ALPHA (block #2)
echo
'Altering Posts table... ';
$DB->query( "ALTER TABLE {$tableprefix}posts
CHANGE post_comments post_comment_status ENUM('disabled', 'open', 'closed') NOT NULL DEFAULT 'open'" );
if( $old_db_version <
9192 )
{ // 1.8 ALPHA (block #3) - The payload that db_delta() handled before
// This is a fix, which broke upgrade to 1.8 (from 1.6) in MySQL strict mode (inserted after 1.8 got released!):
if( $DB->get_row( 'SHOW COLUMNS FROM T_hitlog LIKE "hit_referer_type"' ) )
{ // a niiiiiiiice extra check :p
task_begin( 'Deleting all "spam" hitlog entries... ' );
WHERE hit_referer_type = "spam"' );
$DB->query( 'ALTER TABLE T_users
CHANGE COLUMN user_firstname user_firstname varchar(50) NULL,
CHANGE COLUMN user_lastname user_lastname varchar(50) NULL,
CHANGE COLUMN user_nickname user_nickname varchar(50) NULL,
CHANGE COLUMN user_icq user_icq int(11) unsigned NULL,
CHANGE COLUMN user_email user_email varchar(255) NOT NULL,
CHANGE COLUMN user_url user_url varchar(255) NULL,
CHANGE COLUMN user_ip user_ip varchar(15) NULL,
CHANGE COLUMN user_domain user_domain varchar(200) NULL,
CHANGE COLUMN user_browser user_browser varchar(200) NULL,
CHANGE COLUMN user_aim user_aim varchar(50) NULL,
CHANGE COLUMN user_msn user_msn varchar(100) NULL,
CHANGE COLUMN user_yim user_yim varchar(50) NULL,
ADD COLUMN user_allow_msgform TINYINT NOT NULL DEFAULT \'1\' AFTER user_idmode,
ADD COLUMN user_validated TINYINT(1) NOT NULL DEFAULT 0 AFTER user_grp_ID' );
$DB->query( 'CREATE TABLE T_coll_settings (
cset_coll_ID INT(11) UNSIGNED NOT NULL,
cset_name VARCHAR( 30 ) NOT NULL,
cset_value VARCHAR( 255 ) NULL,
PRIMARY KEY ( cset_coll_ID, cset_name )
if( $old_db_version <
9195 )
$DB->query( 'ALTER TABLE '.
$tableprefix.
'posts
CHANGE COLUMN post_content post_content text NULL,
CHANGE COLUMN post_url post_url VARCHAR(255) NULL DEFAULT NULL,
CHANGE COLUMN post_renderers post_renderers TEXT NOT NULL' );
$DB->query( 'ALTER TABLE T_comments
CHANGE COLUMN comment_author_email comment_author_email varchar(255) NULL,
CHANGE COLUMN comment_author_url comment_author_url varchar(255) NULL,
ADD COLUMN comment_spam_karma TINYINT NULL AFTER comment_karma,
ADD COLUMN comment_allow_msgform TINYINT NOT NULL DEFAULT 0 AFTER comment_spam_karma' );
if( $old_db_version <
9200 )
$DB->query( 'ALTER TABLE T_hitlog
CHANGE COLUMN hit_referer_type hit_referer_type ENUM(\'search\',\'blacklist\',\'referer\',\'direct\') NOT NULL,
ADD COLUMN hit_agnt_ID INT UNSIGNED NULL AFTER hit_remote_addr' );
$DB->query( 'ALTER TABLE T_links
ADD INDEX link_itm_ID( link_itm_ID ),
ADD INDEX link_dest_itm_ID (link_dest_itm_ID)' );
$DB->query( 'ALTER TABLE T_plugins
CHANGE COLUMN plug_priority plug_priority TINYINT NOT NULL default 50,
ADD COLUMN plug_code VARCHAR(32) NULL AFTER plug_classname,
ADD COLUMN plug_apply_rendering ENUM( \'stealth\', \'always\', \'opt-out\', \'opt-in\', \'lazy\', \'never\' ) NOT NULL DEFAULT \'never\' AFTER plug_code,
ADD COLUMN plug_version VARCHAR(42) NOT NULL default \'0\' AFTER plug_apply_rendering,
ADD COLUMN plug_status ENUM( \'enabled\', \'disabled\', \'needs_config\', \'broken\' ) NOT NULL AFTER plug_version,
ADD COLUMN plug_spam_weight TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER plug_status,
ADD UNIQUE plug_code( plug_code ),
ADD INDEX plug_status( plug_status )' );
task_begin( 'Creating plugin settings table... ' );
$DB->query( 'CREATE TABLE T_pluginsettings (
pset_plug_ID INT(11) UNSIGNED NOT NULL,
pset_name VARCHAR( 30 ) NOT NULL,
PRIMARY KEY ( pset_plug_ID, pset_name )
task_begin( 'Creating plugin user settings table... ' );
$DB->query( 'CREATE TABLE T_pluginusersettings (
puset_plug_ID INT(11) UNSIGNED NOT NULL,
puset_user_ID INT(11) UNSIGNED NOT NULL,
puset_name VARCHAR( 30 ) NOT NULL,
PRIMARY KEY ( puset_plug_ID, puset_user_ID, puset_name )
task_begin( 'Creating scheduled tasks table... ' );
$DB->query( 'CREATE TABLE T_cron__task(
ctsk_ID int(10) unsigned not null AUTO_INCREMENT,
ctsk_start_datetime datetime not null,
ctsk_repeat_after int(10) unsigned,
ctsk_name varchar(50) not null,
ctsk_controller varchar(50) not null,
$DB->query( 'CREATE TABLE T_cron__log(
clog_ctsk_ID int(10) unsigned not null,
clog_realstart_datetime datetime not null,
clog_realstop_datetime datetime,
clog_status enum(\'started\',\'finished\',\'error\',\'timeout\') not null default \'started\',
primary key (clog_ctsk_ID)
// blog_allowpingbacks is "DEFAULT 1" in the 0.9.0.11 dump.. - changed in 0.9.2?!
$DB->query( 'ALTER TABLE T_blogs
ALTER COLUMN blog_allowpingbacks SET DEFAULT 0,
CHANGE COLUMN blog_media_subdir blog_media_subdir VARCHAR( 255 ) NULL,
CHANGE COLUMN blog_media_fullpath blog_media_fullpath VARCHAR( 255 ) NULL,
CHANGE COLUMN blog_media_url blog_media_url VARCHAR( 255 ) NULL' );
// ____________________________ 1.9: ____________________________
if( $old_db_version <
9290 )
echo
'Post-fix hit_referer_type == NULL... ';
// If you've upgraded from 1.6 to 1.8 and it did not break because of strict mode, there are now NULL values for what "spam" was:
WHERE hit_referer_type IS NULL' );
echo
'Marking administrator accounts as validated... ';
WHERE user_grp_ID = 1' );
echo
'Converting auto_prune_stats setting... ';
$old_auto_prune_stats =
$DB->get_var( '
WHERE set_name = "auto_prune_stats"' );
if( ! is_null($old_auto_prune_stats) &&
$old_auto_prune_stats <
1 )
{ // This means it has been disabled before, so set auto_prune_stats_mode to "off"!
REPLACE INTO T_settings ( set_name, set_value )
VALUES ( "auto_prune_stats_mode", "off" )' );
echo
'Converting time_difference from hours to seconds... ';
$DB->query( 'UPDATE T_settings SET set_value = set_value*3600 WHERE set_name = "time_difference"' );
echo
'Updating hitlog capabilities... ';
ALTER TABLE T_useragents ADD INDEX agnt_type ( agnt_type )' );
CHANGE COLUMN hit_referer_type hit_referer_type ENUM(\'search\',\'blacklist\',\'referer\',\'direct\',\'self\',\'admin\') NOT NULL' );
echo
'Updating plugin capabilities... ';
MODIFY COLUMN plug_status ENUM( \'enabled\', \'disabled\', \'needs_config\', \'broken\' ) NOT NULL' );
if( $old_db_version <
9300 )
// This can be so long, it needs its own checkpoint protected block in case of failure
echo
'Updating hitlog indexes... ';
ADD INDEX hit_agnt_ID ( hit_agnt_ID ),
ADD INDEX hit_uri ( hit_uri ),
ADD INDEX hit_referer_dom_ID ( hit_referer_dom_ID )
if( $old_db_version <
9310 )
echo
'Updating basedomains... ';
SET dom_status = "unknown"' ); // someone has filled this up with junk blacklists before
ALTER TABLE T_basedomains ADD INDEX dom_type (dom_type)' );
if( $old_db_version <
9315 )
echo
'Altering locales table... ';
$DB->query( "ALTER TABLE T_locales CHANGE COLUMN loc_datefmt loc_datefmt varchar(20) NOT NULL default 'y-m-d'" );
$DB->query( "ALTER TABLE T_locales CHANGE COLUMN loc_timefmt loc_timefmt varchar(20) NOT NULL default 'H:i:s'" );
echo
'Creating item prerendering cache table... ';
CREATE TABLE {$tableprefix}item__prerendering(
itpr_itm_ID INT(11) UNSIGNED NOT NULL,
itpr_format ENUM('htmlbody', 'entityencoded', 'xml', 'text') NOT NULL,
itpr_renderers TEXT NOT NULL,
itpr_content_prerendered TEXT NULL,
itpr_datemodified TIMESTAMP NOT NULL,
PRIMARY KEY (itpr_itm_ID, itpr_format)
echo
'Altering plugins table... ';
$DB->query( "ALTER TABLE T_plugins ADD COLUMN plug_name VARCHAR(255) NULL default NULL AFTER plug_version" );
$DB->query( "ALTER TABLE T_plugins ADD COLUMN plug_shortdesc VARCHAR(255) NULL default NULL AFTER plug_name" );
if( $old_db_version <
9320 )
{ // Dropping hit_datetime because it's very slow on INSERT (dh)
// This can be so long, it needs its own checkpoint protected block in case of failure
{ // only drop, if it still exists (may have been removed manually)
echo
'Updating hitlog indexes... ';
if( $old_db_version <
9326 )
echo
'Removing obsolete settings... ';
$DB->query( 'DELETE FROM T_settings WHERE set_name = "upload_allowedext"' );
echo
'Updating blogs... ';
// Remove and transform obsolete fields blog_pingb2evonet, blog_pingtechnorati, blog_pingweblogs, blog_pingblodotgs
if( db_cols_exist( 'T_blogs', array('blog_pingb2evonet', 'blog_pingtechnorati', 'blog_pingweblogs', 'blog_pingblodotgs') ) )
foreach( $DB->get_results( '
SELECT blog_ID, blog_pingb2evonet, blog_pingtechnorati, blog_pingweblogs, blog_pingblodotgs
FROM T_blogs' ) as $row )
$ping_plugins =
$DB->get_var( 'SELECT cset_value FROM T_coll_settings WHERE cset_coll_ID = '.
$row->blog_ID.
' AND cset_name = "ping_plugins"' );
$ping_plugins =
explode(',', $ping_plugins);
if( $row->blog_pingb2evonet )
$ping_plugins[] =
'ping_b2evonet';
if( $row->blog_pingtechnorati ||
$row->blog_pingweblogs ||
$row->blog_pingblodotgs )
{ // if either one of the previous pingers was enabled, add ping-o-matic:
$ping_plugins[] =
'ping_pingomatic';
// Insert transformed/generated ping plugins collection setting:
$DB->query( 'REPLACE INTO T_coll_settings
( cset_coll_ID, cset_name, cset_value )
VALUES ( '.
$row->blog_ID.
', "ping_plugins", "'.
implode( ',', $ping_plugins ).
'" )' );
$DB->query( 'ALTER TABLE T_blogs
DROP COLUMN blog_pingb2evonet,
DROP COLUMN blog_pingtechnorati,
DROP COLUMN blog_pingweblogs,
DROP COLUMN blog_pingblodotgs' );
if( $old_db_version <
9328 )
echo
'Updating posts... ';
db_add_col( "{
$tableprefix}posts
", 'post_notifications_status', 'ENUM("noreq","todo","started","finished") NOT NULL DEFAULT "noreq" AFTER post_flags' );
db_add_col( "{
$tableprefix}posts
", 'post_notifications_ctsk_ID', 'INT(10) unsigned NULL DEFAULT NULL AFTER post_notifications_status' );
if( $old_db_version <
9330 )
echo
'Updating post notifications... ';
UPDATE {$tableprefix}posts
SET post_notifications_status = 'finished'
WHERE post_flags LIKE '%pingsdone%'" );
if( $old_db_version <
9340 )
echo
'Removing duplicate post link indexes... ';
{ // only drop, if it still exists (may have been removed manually)
{ // only drop, if it still exists (may have been removed manually)
DROP INDEX link_dest_item_ID
// ____________________________ 1.10: ____________________________
if( $old_db_version <
9345 )
echo
'Updating post table... ';
$DB->query( "ALTER TABLE {$tableprefix}posts CHANGE COLUMN post_content post_content MEDIUMTEXT NULL" );
if( $old_db_version <
9346 )
echo
'Updating prerendering table... ';
$DB->query( "ALTER TABLE {$tableprefix}item__prerendering CHANGE COLUMN itpr_content_prerendered itpr_content_prerendered MEDIUMTEXT NULL" );
if( $old_db_version <
9348 )
echo
'Updating sessions table... ';
$DB->query( 'ALTER TABLE T_sessions CHANGE COLUMN sess_data sess_data MEDIUMBLOB DEFAULT NULL' );
if( $old_db_version <
9350 )
echo
'Updating hitlog table... ';
$DB->query( 'ALTER TABLE T_hitlog CHANGE COLUMN hit_referer_type hit_referer_type ENUM(\'search\',\'blacklist\',\'spam\',\'referer\',\'direct\',\'self\',\'admin\') NOT NULL' );
// TODO: "If a user has permission to edit a blog, he should be able to put files in the media folder for that blog." - see http://forums.b2evolution.net/viewtopic.php?p=36417#36417
// blueyed>> I've came up with the following, but it's too generic IMHO
if( $old_db_version < 9300 )
echo 'Setting automatic media perms on blogs (members can upload)... ';
SET bloguser_perm_media_upload = 1
WHERE bloguser_ismember = 1' );
// ____________________________ 2.0: ____________________________
if( $old_db_version <
9406 )
echo
'Updating chapter url names... ';
ADD COLUMN cat_urlname VARCHAR(255) NOT NULL' );
// Create cat_urlname from cat_name:
// TODO: Also use it for cafelog upgrade.
foreach( $DB->get_results('SELECT cat_ID, cat_name FROM T_categories') as $cat )
$cat_name =
trim($cat->cat_name);
$cat_urlname =
urltitle_validate('', $cat_name, $cat->cat_ID, false, 'cat_urlname', 'cat_ID', 'T_categories');
$cat_urlname =
'c'.
$cat->cat_ID;
SET cat_urlname = '.
$DB->quote($cat_urlname).
'
WHERE cat_ID = '.
$cat->cat_ID );
ADD UNIQUE cat_urlname ( cat_urlname )' );
echo
'Updating Settings... ';
SET set_value = "disabled"
WHERE set_name = "links_extrapath"
WHERE set_name = "links_extrapath"
if( $old_db_version <
9407 )
echo
'Moving general settings to blog settings... ';
$DB->query( 'REPLACE INTO T_coll_settings( cset_coll_ID, cset_name, cset_value )
SELECT blog_ID, set_name, set_value
WHERE set_name = "posts_per_page"
OR set_name = "what_to_show"
OR set_name = "archive_mode"' );
$DB->query( 'DELETE FROM T_settings
WHERE set_name = "posts_per_page"
OR set_name = "what_to_show"
OR set_name = "archive_mode"' );
echo
'Upgrading blogs table... ';
$query =
"ALTER TABLE T_blogs
DROP COLUMN blog_force_skin";
echo
'Upgrading groups table... ';
$query =
"ALTER TABLE T_groups
CHANGE COLUMN grp_perm_files grp_perm_files enum('none','view','add','edit','all') NOT NULL default 'none'";
echo
'Upgrading files table... ';
$query =
"ALTER TABLE T_files
CHANGE COLUMN file_root_type file_root_type enum('absolute','user','group','collection','skins') not null default 'absolute'";
echo
'Updating file types... ';
// Only change this if it's close enough to a default install (non customized)
$DB->query( "UPDATE T_filetypes
SET ftyp_viewtype = 'text'
AND ftyp_extensions = 'php php3 php4 php5 php6'
AND ftyp_mimetype ='application/x-httpd-php'
AND ftyp_icon = 'php.gif'" );
echo
'Remove obsolete user settings... ';
$DB->query( 'DELETE FROM T_usersettings
WHERE uset_name = "plugins_disp_avail"' );
if( $old_db_version <
9408 )
echo
'Creating skins table... ';
$DB->query( 'CREATE TABLE T_skins__skin (
skin_ID int(10) unsigned NOT NULL auto_increment,
skin_name varchar(32) NOT NULL,
skin_type enum(\'normal\',\'feed\') NOT NULL default \'normal\',
skin_folder varchar(32) NOT NULL,
PRIMARY KEY skin_ID (skin_ID),
UNIQUE skin_folder( skin_folder ),
KEY skin_name( skin_name )
echo
'Creating skin containers table... ';
$DB->query( 'CREATE TABLE T_skins__container (
sco_skin_ID int(10) unsigned NOT NULL,
sco_name varchar(40) NOT NULL,
PRIMARY KEY (sco_skin_ID, sco_name)
echo
'Creating widgets table... ';
$DB->query( 'CREATE TABLE T_widget (
wi_ID INT(10) UNSIGNED auto_increment,
wi_coll_ID INT(11) UNSIGNED NOT NULL,
wi_sco_name VARCHAR( 40 ) NOT NULL,
wi_order INT(10) UNSIGNED NOT NULL,
wi_type ENUM( \'core\', \'plugin\' ) NOT NULL DEFAULT \'core\',
wi_code VARCHAR(32) NOT NULL,
UNIQUE wi_order( wi_coll_ID, wi_sco_name, wi_order )
echo
'Updating blogs table... ';
$DB->query( 'ALTER TABLE T_blogs
ALTER COLUMN blog_allowtrackbacks SET DEFAULT 0,
DROP COLUMN blog_default_skin,
ADD COLUMN blog_owner_user_ID int(11) unsigned NOT NULL default 1 AFTER blog_name,
ADD COLUMN blog_skin_ID INT(10) UNSIGNED NOT NULL DEFAULT 1 AFTER blog_allowusercss' );
if( $old_db_version <
9409 )
// Upgrade the blog access types:
echo
'Updating blogs access types... ';
$DB->query( 'UPDATE T_blogs
SET blog_access_type = "absolute"
WHERE blog_siteurl LIKE "http://%"
OR blog_siteurl LIKE "https://%"' );
$DB->query( 'UPDATE T_blogs
SET blog_access_type = "relative",
blog_siteurl = CONCAT( blog_siteurl, blog_stub )
WHERE blog_access_type = "stub"' );
echo
'Updating columns... ';
$DB->query( "ALTER TABLE T_groups CHANGE COLUMN grp_perm_stats grp_perm_stats enum('none','user','view','edit') NOT NULL default 'none'" );
$DB->query( "ALTER TABLE T_coll_user_perms CHANGE COLUMN bloguser_perm_poststatuses bloguser_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default ''" );
$DB->query( "ALTER TABLE T_coll_group_perms CHANGE COLUMN bloggroup_perm_poststatuses bloggroup_perm_poststatuses set('published','deprecated','protected','private','draft','redirected') NOT NULL default ''" );
$DB->query( "ALTER TABLE {$tableprefix}posts CHANGE COLUMN post_status post_status enum('published','deprecated','protected','private','draft','redirected') NOT NULL default 'published'" );
if( $old_db_version <
9410 )
echo
'Updating columns... ';
$DB->query( "ALTER TABLE T_comments CHANGE COLUMN comment_status comment_status ENUM('published','deprecated','protected','private','draft','redirected') DEFAULT 'published' NOT NULL" );
$DB->query( "ALTER TABLE T_sessions CHANGE COLUMN sess_data sess_data MEDIUMBLOB DEFAULT NULL" );
$DB->query( "ALTER TABLE T_hitlog CHANGE COLUMN hit_referer_type hit_referer_type ENUM('search','blacklist','spam','referer','direct','self','admin') NOT NULL" );
if( $old_db_version <
9411 )
echo
'Adding default Post Types... ';
REPLACE INTO {$tableprefix}posttypes ( ptyp_ID, ptyp_name )
( 5000, 'Reserved' ) " );
if( $old_db_version <
9412 )
echo
'Adding field for post excerpts... ';
$DB->query( "ALTER TABLE {$tableprefix}posts ADD COLUMN post_excerpt text NULL AFTER post_content" );
if( $old_db_version <
9414 )
echo
"Renaming tables...";
$DB->query( "RENAME TABLE {$tableprefix}item__prerendering TO T_items__prerendering" );
$DB->query( "RENAME TABLE {$tableprefix}poststatuses TO T_items__status" );
$DB->query( "RENAME TABLE {$tableprefix}posttypes TO T_items__type" );
$DB->query( "RENAME TABLE {$tableprefix}posts TO T_items__item" );
echo
"Creating Tag tables...";
$DB->query( "CREATE TABLE T_items__tag (
tag_ID int(11) unsigned not null AUTO_INCREMENT,
tag_name varchar(50) not null,
UNIQUE tag_name( tag_name )
$DB->query( "CREATE TABLE T_items__itemtag (
itag_itm_ID int(11) unsigned NOT NULL,
itag_tag_ID int(11) unsigned NOT NULL,
PRIMARY KEY (itag_itm_ID, itag_tag_ID),
UNIQUE tagitem ( itag_tag_ID, itag_itm_ID )
if( $old_db_version <
9416 )
echo
"Updating blogs table...";
$DB->query( "ALTER TABLE T_blogs
ADD COLUMN blog_advanced_perms TINYINT(1) NOT NULL default 0 AFTER blog_owner_user_ID,
DROP COLUMN blog_staticfilename" );
$DB->query( "UPDATE T_blogs
SET blog_advanced_perms = 1" );
echo
"Additionnal blog permissions...";
$DB->query( "ALTER TABLE T_coll_user_perms
ADD COLUMN bloguser_perm_admin tinyint NOT NULL default 0 AFTER bloguser_perm_properties,
ADD COLUMN bloguser_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no' AFTER bloguser_perm_poststatuses" );
$DB->query( "ALTER TABLE T_coll_group_perms
ADD COLUMN bloggroup_perm_admin tinyint NOT NULL default 0 AFTER bloggroup_perm_properties,
ADD COLUMN bloggroup_perm_edit ENUM('no','own','lt','le','all','redirected') NOT NULL default 'no' AFTER bloggroup_perm_poststatuses" );
// Preserve full admin perms:
$DB->query( "UPDATE T_coll_user_perms
SET bloguser_perm_admin = 1
WHERE bloguser_perm_properties <> 0" );
$DB->query( "UPDATE T_coll_group_perms
SET bloggroup_perm_admin = 1
WHERE bloggroup_perm_properties <> 0" );
// Preserve full edit perms:
$DB->query( "UPDATE T_coll_user_perms
SET bloguser_perm_edit = 'all'" );
$DB->query( "UPDATE T_coll_group_perms
SET bloggroup_perm_edit = 'all'" );
if( $old_db_version <
9500 )
$DB->query( 'ALTER TABLE T_blogs
ALTER COLUMN blog_shortname SET DEFAULT \'\',
ALTER COLUMN blog_tagline SET DEFAULT \'\',
CHANGE COLUMN blog_description blog_description varchar(250) NULL default \'\',
ALTER COLUMN blog_siteurl SET DEFAULT \'\'' );
$DB->query( 'UPDATE T_users
SET dateYMDhour = \'2000-01-01 00:00:00\'
WHERE dateYMDhour = \'0000-00-00 00:00:00\'' );
$DB->query( 'ALTER TABLE T_users
MODIFY COLUMN dateYMDhour DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\'' );
$DB->query( 'UPDATE T_comments
SET comment_date = \'2000-01-01 00:00:00\'
WHERE comment_date = \'0000-00-00 00:00:00\'' );
$DB->query( 'ALTER TABLE T_comments
MODIFY COLUMN comment_date DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\'' );
$DB->query( 'UPDATE T_cron__task
SET ctsk_controller = REPLACE(ctsk_controller, "cron/_", "cron/jobs/_" )
WHERE ctsk_controller LIKE "cron/_%"' );
$DB->query( 'ALTER TABLE T_comments
ADD COLUMN comment_rating TINYINT(1) NULL DEFAULT NULL AFTER comment_content,
ADD COLUMN comment_featured TINYINT(1) NOT NULL DEFAULT 0 AFTER comment_rating,
ADD COLUMN comment_nofollow TINYINT(1) NOT NULL DEFAULT 1 AFTER comment_featured;');
if( $old_db_version <
9600 )
$DB->query( 'CREATE TABLE T_global__cache (
cach_name VARCHAR( 30 ) NOT NULL ,
cach_cache MEDIUMBLOB NULL ,
PRIMARY KEY ( cach_name )
$DB->query( 'ALTER TABLE T_items__item
MODIFY COLUMN post_datestart DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
MODIFY COLUMN post_datemodified DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\',
ADD COLUMN post_order float NULL AFTER post_priority,
ADD COLUMN post_featured tinyint(1) NOT NULL DEFAULT 0 AFTER post_order,
ADD INDEX post_order( post_order )' );
if( $old_db_version <
9700 )
echo
'Creating PodCast Post Type... ';
REPLACE INTO T_items__type ( ptyp_ID, ptyp_name )
VALUES ( 2000, 'Podcast' )" );
echo
'Adding additional group permissions... ';
ADD COLUMN grp_perm_bypass_antispam TINYINT(1) NOT NULL DEFAULT 0 AFTER grp_perm_blogs,
ADD COLUMN grp_perm_xhtmlvalidation VARCHAR(10) NOT NULL default 'always' AFTER grp_perm_bypass_antispam,
ADD COLUMN grp_perm_xhtmlvalidation_xmlrpc VARCHAR(10) NOT NULL default 'always' AFTER grp_perm_xhtmlvalidation,
ADD COLUMN grp_perm_xhtml_css_tweaks TINYINT(1) NOT NULL DEFAULT 0 AFTER grp_perm_xhtmlvalidation_xmlrpc,
ADD COLUMN grp_perm_xhtml_iframes TINYINT(1) NOT NULL DEFAULT 0 AFTER grp_perm_xhtml_css_tweaks,
ADD COLUMN grp_perm_xhtml_javascript TINYINT(1) NOT NULL DEFAULT 0 AFTER grp_perm_xhtml_iframes,
ADD COLUMN grp_perm_xhtml_objects TINYINT(1) NOT NULL DEFAULT 0 AFTER grp_perm_xhtml_javascript " );
if( $old_db_version <
9800 )
echo
'Upgrading blogs table... ';
echo
'Upgrading items table... ';
$DB->query( "ALTER TABLE T_items__item
CHANGE COLUMN post_urltitle post_urltitle VARCHAR(210) NULL DEFAULT NULL,
CHANGE COLUMN post_order post_order DOUBLE NULL,
ADD COLUMN post_titletag VARCHAR(255) NULL DEFAULT NULL AFTER post_urltitle,
ADD COLUMN post_double1 DOUBLE NULL COMMENT 'Custom double value 1' AFTER post_priority,
ADD COLUMN post_double2 DOUBLE NULL COMMENT 'Custom double value 2' AFTER post_double1,
ADD COLUMN post_double3 DOUBLE NULL COMMENT 'Custom double value 3' AFTER post_double2,
ADD COLUMN post_double4 DOUBLE NULL COMMENT 'Custom double value 4' AFTER post_double3,
ADD COLUMN post_double5 DOUBLE NULL COMMENT 'Custom double value 5' AFTER post_double4,
ADD COLUMN post_varchar1 VARCHAR(255) NULL COMMENT 'Custom varchar value 1' AFTER post_double5,
ADD COLUMN post_varchar2 VARCHAR(255) NULL COMMENT 'Custom varchar value 2' AFTER post_varchar1,
ADD COLUMN post_varchar3 VARCHAR(255) NULL COMMENT 'Custom varchar value 3' AFTER post_varchar2" );
echo
'Creating keyphrase table... ';
$query =
"CREATE TABLE T_track__keyphrase (
keyp_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
keyp_phrase VARCHAR( 255 ) NOT NULL,
UNIQUE keyp_phrase ( keyp_phrase )
echo
'Upgrading hitlog table... ';
$query =
"ALTER TABLE T_hitlog
CHANGE COLUMN hit_ID hit_ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
CHANGE COLUMN hit_datetime hit_datetime DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00',
ADD COLUMN hit_keyphrase_keyp_ID INT UNSIGNED DEFAULT NULL AFTER hit_referer_dom_ID,
ADD INDEX hit_remote_addr ( hit_remote_addr ),
ADD INDEX hit_sess_ID ( hit_sess_ID )";
echo
'Upgrading sessions table... ';
$DB->query( "ALTER TABLE T_sessions
ALTER COLUMN sess_lastseen SET DEFAULT '2000-01-01 00:00:00',
ADD COLUMN sess_hitcount INT(10) UNSIGNED NOT NULL DEFAULT 1 AFTER sess_key,
ADD KEY sess_user_ID (sess_user_ID)" );
echo
'Creating goal tracking table... ';
$DB->query( "CREATE TABLE T_track__goal(
goal_ID int(10) unsigned NOT NULL auto_increment,
goal_name varchar(50) default NULL,
goal_key varchar(32) default NULL,
goal_redir_url varchar(255) default NULL,
goal_default_value double default NULL,
UNIQUE KEY goal_key (goal_key)
$DB->query( "CREATE TABLE T_track__goalhit (
ghit_ID int(10) unsigned NOT NULL auto_increment,
ghit_goal_ID int(10) unsigned NOT NULL,
ghit_hit_ID int(10) unsigned NOT NULL,
ghit_params TEXT default NULL,
KEY ghit_goal_ID (ghit_goal_ID),
KEY ghit_hit_ID (ghit_hit_ID)
if( $old_db_version <
9900 )
task_begin( 'Updating keyphrases in hitlog table... ' );
load_class( 'sessions/model/_hit.class.php', 'Hit' );
$sql =
'SELECT SQL_NO_CACHE hit_ID, hit_referer
WHERE hit_referer_type = "search"
AND hit_keyphrase_keyp_ID IS NULL'; // this line just in case we crashed in the middle, so we restart where we stopped
$rows =
$DB->get_results( $sql, OBJECT, 'get all search hits' );
if( empty( $keyphrase ) )
WHERE keyp_phrase = '.
$DB->quote($keyphrase);
$keyp_ID =
$DB->get_var( $sql, 0, 0, 'Get keyphrase ID' );
$sql =
'INSERT INTO T_track__keyphrase( keyp_phrase )
VALUES ('.
$DB->quote($keyphrase).
')';
$DB->query( $sql, 'Add new keyphrase' );
$keyp_ID =
$DB->insert_id;
$DB->query( 'UPDATE T_hitlog
SET hit_keyphrase_keyp_ID = '.
$keyp_ID.
'
WHERE hit_ID = '.
$row->hit_ID, 'Update hit' );
$DB->query( "ALTER TABLE T_widget
CHANGE COLUMN wi_order wi_order INT(10) NOT NULL" );
$DB->query( "ALTER TABLE T_files
CHANGE COLUMN file_root_type file_root_type enum('absolute','user','collection','shared','skins') not null default 'absolute'" );
if( $old_db_version <
9910 )
$DB->query( "ALTER TABLE T_blogs CHANGE COLUMN blog_name blog_name varchar(255) NOT NULL default ''" );
REPLACE INTO T_items__type( ptyp_ID, ptyp_name )
VALUES ( 1500, 'Intro-Main' ),
( 1600, 'Intro-All' ) " );
$DB->query( "ALTER TABLE T_users
ADD COLUMN user_avatar_file_ID int(10) unsigned default NULL AFTER user_validated" );
task_begin( 'Creating table for User field definitions' );
$DB->query( "CREATE TABLE T_users__fielddefs (
ufdf_ID int(10) unsigned NOT NULL,
ufdf_type char(8) NOT NULL,
ufdf_name varchar(255) collate latin1_general_ci NOT NULL,
task_begin( 'Creating default field definitions...' );
INSERT INTO T_users__fielddefs (ufdf_ID, ufdf_type, ufdf_name)
VALUES ( 10000, 'email', 'MSN/Live IM'),
( 10100, 'word', 'Yahoo IM'),
( 10200, 'word', 'AOL AIM'),
( 10300, 'number', 'ICQ ID'),
( 40000, 'phone', 'Skype'),
( 50000, 'phone', 'Main phone'),
( 50100, 'phone', 'Cell phone'),
( 50200, 'phone', 'Office phone'),
( 50300, 'phone', 'Home phone'),
( 60000, 'phone', 'Office FAX'),
( 60100, 'phone', 'Home FAX'),
(100000, 'url', 'Website'),
(110000, 'url', 'Linkedin'),
(120000, 'url', 'Twitter'),
(130100, 'url', 'Facebook'),
(130200, 'url', 'Myspace'),
(140000, 'url', 'Flickr'),
(150000, 'url', 'YouTube'),
(160100, 'url', 'StumbleUpon'),
(200000, 'text', 'Role'),
(200100, 'text', 'Company/Org.'),
(200200, 'text', 'Division'),
(211000, 'text', 'VAT ID'),
(300000, 'text', 'Main address'),
(300300, 'text', 'Home address');" );
task_begin( 'Creating table for User fields...' );
$DB->query( "CREATE TABLE T_users__fields (
uf_ID int(10) unsigned NOT NULL auto_increment,
uf_user_ID int(10) unsigned NOT NULL,
uf_ufdf_ID int(10) unsigned NOT NULL,
uf_varchar varchar(255) NOT NULL,
if( $old_db_version <
9920 )
// This is for old posts that may have a post type of NULL which should never happen. ptyp 1 is for regular posts
$DB->query( "UPDATE T_items__item
WHERE post_ptyp_ID IS NULL" );
$DB->query( "ALTER TABLE T_items__item
CHANGE COLUMN post_ptyp_ID post_ptyp_ID int(10) unsigned NOT NULL DEFAULT 1" );
$DB->query( "ALTER TABLE T_categories
CHANGE COLUMN cat_name cat_name varchar(255) NOT NULL,
CHANGE COLUMN cat_description cat_description varchar(255) NULL DEFAULT NULL" );
db_add_col( 'T_categories', 'cat_order', 'int(11) NULL DEFAULT NULL AFTER cat_description' );
$DB->query( "UPDATE T_categories
SET cat_order = cat_ID" );
db_add_col( 'T_widget', 'wi_enabled', 'tinyint(1) NOT NULL DEFAULT 1 AFTER wi_order' );
if( $old_db_version <
9930 )
REPLACE INTO T_items__type ( ptyp_ID, ptyp_name )
VALUES ( 3000, 'Sidebar link' )" );
$DB->query( "ALTER TABLE T_items__item ENGINE=innodb" ); // fp> hum... this originally was a test :)
$DB->query( "CREATE TABLE T_items__version (
iver_itm_ID INT UNSIGNED NOT NULL ,
iver_edit_user_ID INT UNSIGNED NOT NULL ,
iver_edit_datetime DATETIME NOT NULL ,
iver_status ENUM('published','deprecated','protected','private','draft','redirected') NULL ,
iver_content MEDIUMTEXT NULL ,
INDEX iver_itm_ID ( iver_itm_ID )
$DB->query( "UPDATE T_groups
SET grp_perm_xhtml_css_tweaks = 1
if( $old_db_version <
9940 )
$DB->query( "ALTER TABLE T_hitlog ADD COLUMN hit_serprank INT UNSIGNED DEFAULT NULL AFTER hit_keyphrase_keyp_ID" );
$DB->query( "ALTER TABLE T_items__version
CHANGE COLUMN iver_edit_user_ID iver_edit_user_ID INT UNSIGNED NULL" );
if( $old_db_version <
9950 )
$DB->query( "ALTER TABLE T_blogs CHANGE COLUMN blog_shortname blog_shortname varchar(255) default ''" );
$DB->query( "ALTER TABLE T_links
ALTER COLUMN link_datecreated SET DEFAULT '2000-01-01 00:00:00',
ALTER COLUMN link_datemodified SET DEFAULT '2000-01-01 00:00:00'" );
$DB->query( "ALTER TABLE T_cron__task
ALTER COLUMN ctsk_start_datetime SET DEFAULT '2000-01-01 00:00:00'" );
$DB->query( "ALTER TABLE T_cron__log
ALTER COLUMN clog_realstart_datetime SET DEFAULT '2000-01-01 00:00:00'" );
$DB->query( "ALTER TABLE T_items__item
ADD COLUMN post_metadesc VARCHAR(255) NULL DEFAULT NULL AFTER post_titletag,
ADD COLUMN post_metakeywords VARCHAR(255) NULL DEFAULT NULL AFTER post_metadesc,
ADD COLUMN post_editor_code VARCHAR(32) NULL COMMENT 'Plugin code of the editor used to edit this post' AFTER post_varchar3" );
task_begin( 'Forcing AutoP posts to html editor...' );
$DB->query( 'UPDATE T_items__item
SET post_editor_code = "html"
WHERE post_renderers = "default"
OR post_renderers LIKE "%b2WPAutP%"' );
if( $old_db_version <
9960 )
echo
"Renaming tables...";
$DB->halt_on_error =
false;
$DB->show_errors =
false;
$DB->query( "ALTER TABLE {$tableprefix}users_fields RENAME TO T_users__fields" );
$DB->restore_error_state();
// fp> The following is more tricky to do with CHARACTER SET. During upgrade, we don't know what the admin actually wants.
task_begin( 'Making sure all tables use desired storage ENGINE...' );
foreach( $schema_queries as $table_name=>
$table_def )
if( $DB->query( 'SHOW TABLES LIKE \''.
$table_name.
'\'' )
&&
preg_match( '/\sENGINE\s*=\s*([a-z]+)/is', $table_def[1], $matches ) )
{ // If the table exists and has an ENGINE definition:
echo
$table_name.
':'.
$matches[1].
'<br />';
$DB->query( "ALTER TABLE $table_name ENGINE = ".
$matches[1] );
if( $old_db_version <
9970 )
// For create_default_currencies() and create_default_countries():
require_once dirname(__FILE__
).
'/_functions_create.php';
task_begin( 'Creating table for default currencies... ' );
$DB->query( "CREATE TABLE T_currency (
curr_ID int(10) unsigned NOT NULL auto_increment,
curr_code char(3) NOT NULL,
curr_shortcut varchar(30) NOT NULL,
curr_name varchar(40) NOT NULL,
PRIMARY KEY curr_ID (curr_ID),
UNIQUE curr_code (curr_code)
task_begin( 'Creating table for default countries... ' );
$DB->query( "CREATE TABLE T_country (
ctry_ID int(10) unsigned NOT NULL auto_increment,
ctry_code char(2) NOT NULL,
ctry_name varchar(40) NOT NULL,
ctry_curr_ID int(10) unsigned,
PRIMARY KEY ctry_ID (ctry_ID),
UNIQUE ctry_code (ctry_code)
task_begin( 'Upgrading user permissions table... ' );
$DB->query( "ALTER TABLE T_coll_user_perms
ADD COLUMN bloguser_perm_page tinyint NOT NULL default 0 AFTER bloguser_perm_media_change,
ADD COLUMN bloguser_perm_intro tinyint NOT NULL default 0 AFTER bloguser_perm_page,
ADD COLUMN bloguser_perm_podcast tinyint NOT NULL default 0 AFTER bloguser_perm_intro,
ADD COLUMN bloguser_perm_sidebar tinyint NOT NULL default 0 AFTER bloguser_perm_podcast" );
task_begin( 'Upgrading group permissions table... ' );
$DB->query( "ALTER TABLE T_coll_group_perms
ADD COLUMN bloggroup_perm_page tinyint NOT NULL default 0 AFTER bloggroup_perm_media_change,
ADD COLUMN bloggroup_perm_intro tinyint NOT NULL default 0 AFTER bloggroup_perm_page,
ADD COLUMN bloggroup_perm_podcast tinyint NOT NULL default 0 AFTER bloggroup_perm_intro,
ADD COLUMN bloggroup_perm_sidebar tinyint NOT NULL default 0 AFTER bloggroup_perm_podcast" );
$DB->query( "ALTER TABLE T_users
ADD COLUMN user_ctry_ID int(10) unsigned NULL AFTER user_avatar_file_ID" );
// Creating tables for messaging module
task_begin( 'Creating table for message threads... ' );
$DB->query( "CREATE TABLE T_messaging__thread (
thrd_ID int(10) unsigned NOT NULL auto_increment,
thrd_title varchar(255) NOT NULL,
thrd_datemodified datetime NOT NULL,
PRIMARY KEY thrd_ID (thrd_ID)
$DB->query( "CREATE TABLE T_messaging__message (
msg_ID int(10) unsigned NOT NULL auto_increment,
msg_author_user_ID int(10) unsigned NOT NULL,
msg_datetime datetime NOT NULL,
msg_thread_ID int(10) unsigned NOT NULL,
PRIMARY KEY msg_ID (msg_ID)
task_begin( 'Creating table for message thread statuses... ' );
$DB->query( "CREATE TABLE T_messaging__threadstatus (
tsta_thread_ID int(10) unsigned NOT NULL,
tsta_user_ID int(10) unsigned NOT NULL,
tsta_first_unread_msg_ID int(10) unsigned NULL,
task_begin( 'Creating table for messaging contacts... ' );
$DB->query( "CREATE TABLE T_messaging__contact (
mct_from_user_ID int(10) unsigned NOT NULL,
mct_to_user_ID int(10) unsigned NOT NULL,
mct_blocked tinyint(1) default 0,
mct_last_contact_datetime datetime NOT NULL,
PRIMARY KEY mct_PK (mct_from_user_ID, mct_to_user_ID)
$DB->query( "ALTER TABLE T_skins__skin
MODIFY skin_type enum('normal','feed','sitemap') NOT NULL default 'normal'" );
task_begin( 'Setting skin type of sitemap skin to "sitemap"... ' );
$DB->query( "UPDATE T_skins__skin
SET skin_type = 'sitemap'
WHERE skin_folder = '_sitemap'" );
// Creating table for pluggable permissions
task_begin( 'Creating table for Group Settings... ' );
$DB->query( "CREATE TABLE T_groups__groupsettings (
gset_grp_ID INT(11) UNSIGNED NOT NULL,
gset_name VARCHAR(30) NOT NULL,
gset_value VARCHAR(255) NULL,
PRIMARY KEY (gset_grp_ID, gset_name)
// Rename T_usersettings table to T_users__usersettings
task_begin( 'Rename T_usersettings table to T_users__usersettings... ' );
$DB->query( 'RENAME TABLE '.
$tableprefix.
'usersettings TO T_users__usersettings' );
if( $old_db_version <
9980 )
SET post_datestart = FROM_UNIXTIME( FLOOR(UNIX_TIMESTAMP(post_datestart)/60)*60 )
WHERE post_datestart > NOW()' );
db_add_col( 'T_items__item', 'post_excerpt_autogenerated', 'TINYINT NULL DEFAULT NULL AFTER post_excerpt' );
db_add_col( 'T_items__item', 'post_dateset', 'tinyint(1) NOT NULL DEFAULT 1 AFTER post_assigned_user_ID' );
db_add_col( 'T_country', 'ctry_enabled', 'tinyint(1) NOT NULL DEFAULT 1 AFTER ctry_curr_ID' );
// Add link_position. Temporary allow NULL, set compatibility default, then do not allow NULL.
// TODO: dh> actually, using "teaser" for the first link and "aftermore" for the rest would make more sense (and "aftermore" should get displayed with "no-more" posts anyway).
// Opinions? Could be heavy to transform this though..
// fp> no, don't change past posts unexpectedly.
db_add_col( 'T_links', 'link_position', "varchar(10) NULL AFTER link_title" );
$DB->query( "UPDATE T_links SET link_position = 'teaser' WHERE link_position IS NULL" );
db_add_col( 'T_links', 'link_position', "varchar(10) NOT NULL AFTER link_title" ); // change to NOT NULL
// Add link_order. Temporary allow NULL, use order from ID, then do not allow NULL and add UNIQUE index.
db_add_col( 'T_links', 'link_order', 'int(11) unsigned NULL AFTER link_position' );
$DB->query( "UPDATE T_links SET link_order = link_ID WHERE link_order IS NULL" );
db_add_col( 'T_links', 'link_order', 'int(11) unsigned NOT NULL AFTER link_position' ); // change to NOT NULL
db_add_index( 'T_links', 'link_itm_ID_order', 'link_itm_ID, link_order', 'UNIQUE' );
$DB->query( "ALTER TABLE T_sessions CHANGE COLUMN sess_ipaddress sess_ipaddress VARCHAR(39) NOT NULL DEFAULT ''" );
if( $old_db_version <
9990 )
db_add_col( 'T_hitlog', 'hit_agent_type', "ENUM('rss','robot','browser','unknown') DEFAULT 'unknown' NOT NULL AFTER hit_remote_addr" );
$DB->query( 'UPDATE T_hitlog, '.
$tableprefix.
'useragents
SET hit_agent_type = agnt_type
WHERE hit_agnt_ID = agnt_ID
AND agnt_type <> "unknown"' ); // We already have the unknown as default
$DB->query( 'DROP TABLE IF EXISTS '.
$tableprefix.
'useragents' );
// set_upgrade_checkpoint( '9990' );
// Integrate comment_secret
db_add_col( 'T_comments', 'comment_secret', 'varchar(32) NULL default NULL' );
* ALL DB CHANGES MUST BE EXPLICITELY CARRIED OUT. DO NOT RELY ON SCHEMA UPDATES!
* Schema updates do not survive after several incremental changes.
* NOTE: every change that gets done here, should bump {@link $new_db_version} (by 100).
/* Wait until we're sure and no longer experimental for that one...
task_begin( 'Moving user data to fields' );
$DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
SELECT user_ID, 10300, user_icq
WHERE user_msn IS NOT NULL AND TRIM(user_icq) <> ''" );
$DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
SELECT user_ID, 100000, user_url
WHERE user_msn IS NOT NULL AND TRIM(user_url) <> ''" );
$DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
SELECT user_ID, 10200, user_aim
WHERE user_msn IS NOT NULL AND TRIM(user_aim) <> ''" );
$DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
SELECT user_ID, 10000, user_msn
WHERE user_msn IS NOT NULL AND TRIM(user_msn) <> ''" );
$DB->query( "INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
SELECT user_ID, 10100, user_yim
WHERE user_msn IS NOT NULL AND TRIM(user_yim) <> ''" );
// Just in case, make sure the db schema version is upto date at the end.
if( $old_db_version !=
$new_db_version )
{ // Update DB schema version to $new_db_version
// This has to be at the end because plugin install may fail if the DB schema is not current (matching Plugins class).
// Only new default plugins will be installed, based on $old_db_version.
// dh> NOTE: if this fails (e.g. fatal error in one of the plugins), it will not get repeated
* -----------------------------------------------
* Check to make sure the DB schema is up to date:
* -----------------------------------------------
$upgrade_db_deltas =
array(); // This holds changes to make, if any (just all queries)
foreach( $schema_queries as $table =>
$query_info )
{ // For each table in the schema, check diffs...
echo
'<br />Checking table: '.
$table.
': ';
$updates =
db_delta( $query_info[1], array('drop_column', 'drop_index'), false, true );
if( $debug ) echo
'NEEDS UPDATE!';
foreach( $updates as $table =>
$queries )
foreach( $queries as $qinfo )
foreach( $qinfo['queries'] as $query )
{ // subqueries for this query (usually one, but may include required other queries)
$upgrade_db_deltas[] =
$query;
if( empty($upgrade_db_deltas) )
echo
'<p>'.
T_('The database schema is up to date.').
'</p>';
{ // Upgrades are needed:
$confirmed_db_upgrade =
param('confirmed', 'integer', 0); // force confirmation
$upgrade_db_deltas_confirm_md5 =
param( 'upgrade_db_deltas_confirm_md5', 'string', '' );
if( ! $confirmed_db_upgrade )
if( ! empty($upgrade_db_deltas_confirm_md5) )
{ // received confirmation from form
if( $upgrade_db_deltas_confirm_md5 !=
md5( implode('', $upgrade_db_deltas) ) )
.
T_('The DB schema has been changed since confirmation.')
$confirmed_db_upgrade =
true;
if( ! $confirmed_db_upgrade )
global $action, $locale, $form_action;
load_class( '_core/ui/forms/_form.class.php', 'Form' );
if( !empty( $form_action ) )
$Form =
new Form( $form_action, '', 'post' );
$Form =
new Form( NULL, '', 'post' );
$Form->begin_form( 'fform', T_('Upgrade database') );
$Form->hidden( 'upgrade_db_deltas_confirm_md5', md5(implode( '', $upgrade_db_deltas )) );
$Form->hidden( 'action', $action );
$Form->hidden( 'locale', $locale );
echo
'<p>'.
T_('The version number is correct, but we have detected changes in the database schema. This can happen with CVS versions...').
'</p>';
echo
'<p>'.
T_('The following database changes will be carried out. If you are not sure what this means, it will probably be alright.').
'</p>';
foreach( $upgrade_db_deltas as $l_delta )
#echo '<li><code>'.nl2br($l_delta).'</code></li>';
echo
'<li><pre>'.
str_replace( "\t", ' ', $l_delta ).
'</pre></li>';
$Form->submit( array( '', T_('Upgrade database!'), 'ActionButton' ) );
// Alter DB to match DB schema:
* $Log: _functions_evoupgrade.php,v $
* Revision 1.357 2010/03/04 15:55:17 efy-asimo
* integrate comment_secret into the upgrade procedure
* Revision 1.356 2010/02/26 22:15:50 fplanque
* Revision 1.355 2010/02/12 18:22:05 efy-yury
* add atnispam query obfuscating
* Revision 1.354 2010/02/08 17:55:33 efy-yury
* Revision 1.353 2010/01/09 18:19:06 blueyed
* Upgrade: make upgrade of hitlog more robust in regard to already done changes.
* Revision 1.352 2010/01/03 13:45:37 fplanque
* set some crumbs (needs checking)
* Revision 1.351 2009/12/22 08:45:44 fplanque
* Revision 1.350 2009/12/22 02:55:06 blueyed
* Revision 1.349 2009/12/09 22:57:46 blueyed
* Revision 1.348 2009/12/09 17:36:45 blueyed
* Revision 1.347 2009/12/08 22:38:13 fplanque
* User agent type is now saved directly into the hits table instead of a costly lookup in user agents table
* Revision 1.346 2009/12/01 21:35:56 blueyed
* Merge from whissip: use get_row to not fetch all rows. Use proper category urlnames on upgrade.
* Revision 1.345 2009/11/30 01:22:23 fplanque
* fix wrong version status message rigth after upgrade
* Revision 1.344 2009/11/19 10:24:48 efy-maxim
* maintenance module - 'Upgrade Database' button support.
* Revision 1.343 2009/10/27 23:06:43 fplanque
* Revision 1.342 2009/10/27 21:57:43 fplanque
* Revision 1.341 2009/10/17 16:31:33 efy-maxim
* Renamed: T_groupsettings to T_groups__groupsettings, T_usersettings to T_users__usersettings
* Revision 1.340 2009/10/17 14:49:46 fplanque
* Revision 1.339 2009/10/11 03:31:55 blueyed
* Revision 1.338 2009/10/11 03:00:11 blueyed
* Add "position" and "order" properties to attachments.
* Position can be "teaser" or "aftermore" for now.
* Order defines the sorting of attachments.
* Needs testing and refinement. Upgrade might work already, be careful!
* Revision 1.337 2009/10/10 20:17:33 tblue246
* Minor debug output layout fix
* Revision 1.336 2009/10/10 16:34:44 blueyed
* Revision 1.335 2009/10/08 20:05:52 efy-maxim
* Modular/Pluggable Permissions
* Revision 1.334 2009/10/07 23:43:25 fplanque
* Revision 1.333 2009/10/04 18:26:48 blueyed
* Add missing DB transformations, need to get added to blocks.
* Revision 1.332 2009/09/29 13:32:30 tblue246
* OK, no DB changes for 3.3.2, moved to 4.0
* Revision 1.331 2009/09/29 03:47:07 fplanque
* Revision 1.330 2009/09/26 13:41:54 tblue246
* If XML feeds are disabled for a blog, still allow accessing "sitemap" skins.
* Revision 1.329 2009/09/25 20:26:26 fplanque
* Revision 1.328 2009/09/25 14:18:22 tblue246
* Reverting accidental commits
* Revision 1.326 2009/09/21 03:31:23 fplanque
* made autoupgrade more verbose in debug mode
* Revision 1.325 2009/09/20 19:52:21 blueyed
* Make ENGINE match more lax.
* Revision 1.324 2009/09/20 19:47:07 blueyed
* Add post_excerpt_autogenerated field.
* "text" params get unified newlines now and "excerpt" is a text param.
* This is required for detecting if it has been changed really.
* If something is wrong about this, please make sure that an unchanged
* excerpt won't update the one in DB (when posting the item form).
* Revision 1.323 2009/09/19 13:27:15 blueyed
* Revision 1.322 2009/09/18 16:01:50 fplanque
* Revision 1.321 2009/09/18 14:22:11 efy-maxim
* 1. 'reply' permission in group form
* 2. functionality to store and update contacts
* 3. fix in misc functions
* Revision 1.320 2009/09/17 11:34:33 efy-maxim
* reply permission in create and upgrade functionality
* Revision 1.319 2009/09/14 18:37:07 fplanque
* Revision 1.318 2009/09/14 14:55:19 tblue246
* Revision 1.317 2009/09/14 14:10:14 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.316 2009/09/13 21:29:22 blueyed
* MySQL query cache optimization: remove information about seconds from post_datestart and item_issue_date.
* Revision 1.315 2009/09/13 21:26:50 blueyed
* SQL_NO_CACHE for SELECT queries using T_hitlog
* Revision 1.314 2009/09/13 15:56:11 fplanque
* Revision 1.313 2009/09/13 12:25:34 efy-maxim
* Messaging permissions have been added to:
* Revision 1.312 2009/09/12 18:44:11 efy-maxim
* Messaging module improvements
* Revision 1.311 2009/09/10 18:24:07 fplanque
* Revision 1.310 2009/09/10 13:44:57 tblue246
* Translation fixes/update
* Revision 1.309 2009/09/10 13:10:37 efy-maxim
* int(11) has been changed to int(10) for PKs of T_country, T_currency tables
* Revision 1.308 2009/09/10 12:13:33 efy-maxim
* Revision 1.307 2009/09/07 23:35:51 fplanque
* Revision 1.306 2009/09/07 14:42:35 efy-maxim
* Create user_ctry_ID column in T_users table in evoupgrade module
* Revision 1.305 2009/09/05 18:49:29 tblue246
* Bad idea was a good idea: Use function call instead of duplicate INSERT statements. Meh.
* Revision 1.302 2009/09/05 12:27:20 tblue246
* - Use create_default_currencies() and create_default_countries() instead of duplicated queries.
* Revision 1.301 2009/09/05 11:29:28 efy-maxim
* Create default currencies and countries. Upgrade currencies and countries.
* Revision 1.300 2009/08/30 00:30:52 fplanque
* Revision 1.299 2009/07/13 00:14:07 fplanque
* Revision 1.298 2009/07/12 23:54:10 fplanque
* Revision 1.297 2009/07/12 23:18:22 fplanque
* upgrading tables to innodb
* Revision 1.296 2009/07/11 17:18:03 waltercruz
* Revision 1.295 2009/07/10 20:02:10 fplanque
* using innodb by default for most tables now.
* enabled transactions by default.
* Revision 1.294 2009/07/07 00:34:42 fplanque
* Remember whether or not the TinyMCE editor was last used on a per post and per blog basis.
* Revision 1.293 2009/06/20 17:19:33 leeturner2701
* meta desc and meta keywords per blog post
* Revision 1.292 2009/06/01 16:23:32 sam2kb
* new_db_version updated to 9950
* Revision 1.291 2009/05/31 17:04:42 sam2kb
* blog_shortname field extended to 255 characters
* Please change the new_db_version
* Revision 1.290 2009/05/28 12:49:48 fplanque
* Revision 1.289 2009/05/10 00:28:51 fplanque
* Revision 1.288 2009/03/21 22:55:15 fplanque
* Adding TinyMCE -- lowfat version
* Revision 1.287 2009/03/13 00:57:35 fplanque
* calling it "sidebar links"
* Revision 1.285 2009/03/08 23:57:47 fplanque
* Revision 1.284 2009/03/03 20:23:46 blueyed
* Move extract_keyphrase_from_referer to Hit class. Otherwise it should get moved to hit.funcs.
* Revision 1.283 2009/02/26 22:33:22 blueyed
* Fix messup in last commit.
* Revision 1.282 2009/02/26 22:16:54 blueyed
* Use load_class for classes (.class.php), and load_funcs for funcs (.funcs.php)
* Revision 1.281 2009/02/25 22:03:19 blueyed
* Upgrade: rename ptyp_ID 3000 to 'Linkroll item'
* Revision 1.280 2009/02/25 20:54:47 blueyed
* - db_add_col: if the column exist already, execute an ALTER statement
* - Add db_add_index, which will drop any existing index, and create the
* - Use db_add_col/db_add_index for latest changes, to prevent errors on
* Revision 1.279 2009/02/25 01:31:16 fplanque
* Revision 1.278 2009/02/09 19:20:32 blueyed
* Fix E_FATAL during upgrade (bpost_count_words not defined)
* Revision 1.277 2009/02/05 21:33:34 tblue246
* Allow the user to enable/disable widgets.
* * Fix CSS for the widget state bullet @ JS widget UI.
* * Maybe find a better solution than modifying get_Cache() to get only enabled widgets... :/
* * Buffer JS requests when toggling the state of a widget??
* Revision 1.276 2009/01/28 21:23:22 fplanque
* Manual ordering of categories
* Revision 1.275 2009/01/28 00:59:19 blueyed
* Fixing doc for a block that gets skipped on installs tracking CVS HEAD, again (probably)
* Revision 1.274 2009/01/27 16:48:31 fplanque
* quick fix for NULL ptyp_IDs
* Revision 1.273 2009/01/25 19:09:32 blueyed
* Revision 1.272 2009/01/23 18:32:15 fplanque
* Revision 1.271 2009/01/21 18:52:15 fplanque
* Revision 1.270 2009/01/21 18:23:26 fplanque
* Featured posts and Intro posts
* Revision 1.268 2009/01/13 23:45:59 fplanque
* User fields proof of concept
* Revision 1.267 2009/01/13 22:51:29 fplanque
* rollback / normalized / MFB
* Revision 1.266 2008/12/28 17:35:51 fplanque
* increase blog name max length to 255 chars
* Revision 1.265 2008/10/06 03:36:48 fplanque
* Revision 1.264 2008/10/06 01:55:06 fplanque
* User fields proof of concept.
* Needs UserFieldDef and UserFieldDefCache + editing of fields.
* Does anyone want to take if from there?
* Revision 1.263 2008/09/27 00:05:54 fplanque
* Revision 1.262 2008/09/24 09:28:36 fplanque
* Revision 1.261 2008/09/23 06:18:39 fplanque
* File manager now supports a shared directory (/media/shared/global/)
* Revision 1.260 2008/09/07 07:57:58 fplanque
* Revision 1.259 2008/07/03 09:53:37 yabs
* Revision 1.258 2008/05/27 23:36:40 blueyed
* Fix indent. Add TODOs about checkpoints.
* Revision 1.257 2008/05/26 19:30:32 fplanque
* Revision 1.256 2008/05/10 23:41:04 fplanque
* Revision 1.255 2008/04/06 19:19:30 fplanque
* Started moving some intelligence to the Modules.
* 1) Moved menu structure out of the AdminUI class.
* It is part of the app structure, not the UI. Up to this point at least.
* Note: individual Admin skins can still override the whole menu.
* 2) Moved DB schema to the modules. This will be reused outside
* of install for integrity checks and backup.
* 3) cleaned up config files
* Revision 1.254 2008/03/23 23:40:42 fplanque
* Revision 1.253 2008/03/22 19:39:28 fplanque
* Revision 1.252 2008/03/21 16:07:03 fplanque
* Revision 1.251 2008/03/16 19:40:52 blueyed
* Fix renaming of tables, which failed when done in one query (User only has perms on his DB; MySQL 5.0.38-Ubuntu_0ubuntu1.1) (LP: #195612)
* Revision 1.250 2008/03/16 14:19:39 fplanque
* Revision 1.248 2008/03/07 02:00:42 blueyed
* doc; indent; use db_drop_col
* Revision 1.247 2008/02/19 11:11:20 fplanque
* Revision 1.246 2008/02/10 00:58:57 fplanque
* Revision 1.245 2008/02/09 20:14:14 fplanque
* custom fields management
* Revision 1.244 2008/02/09 17:36:15 fplanque
* better handling of order, including approximative comparisons
* Revision 1.243 2008/02/09 02:56:00 fplanque
* explicit order by field
* Revision 1.242 2008/02/07 00:35:52 fplanque
* Revision 1.241 2008/01/23 16:44:27 fplanque
* Revision 1.240 2008/01/22 16:57:08 fplanque
* Revision 1.239 2008/01/21 09:35:38 fplanque
* Revision 1.238 2008/01/19 10:57:10 fplanque
* Splitting XHTML checking by group and interface
* Revision 1.237 2008/01/14 07:33:32 fplanque
* Daniel, stop putting the comments in the log! They're more useful in the code!
* Revision 1.236 2008/01/12 19:25:58 blueyed
* - Fix install from < 0.8: Make function "cleanup_post_quotes" inline and fix table name
* - Only check max_execution_time when > 0 (not disabled)
* Revision 1.235 2008/01/08 03:31:50 fplanque
* Revision 1.234 2008/01/05 00:24:35 blueyed
* Create same filetypes when upgrading as when installing (DRY anyone?)
* Revision 1.233 2007/11/30 01:46:12 fplanque
* Revision 1.232 2007/11/02 01:53:34 fplanque
* Revision 1.231 2007/10/11 14:02:48 fplanque
* Revision 1.230 2007/09/19 02:54:16 fplanque
* Revision 1.229 2007/07/03 23:21:32 blueyed
* Fixed includes/requires in/for tests
* Revision 1.228 2007/06/25 11:02:30 fplanque
* MODULES (refactored MVC)
* Revision 1.227 2007/06/13 19:06:17 fplanque
* Revision 1.226 2007/06/03 02:54:18 fplanque
* Stuff for permission maniacs (admin part only, actual perms checks to be implemented)
* Newbies will not see this complexity since advanced perms are now disabled by default.
* Revision 1.225 2007/05/31 03:02:23 fplanque
* Advanced perms now disabled by default (simpler interface).
* Enable advanced perms in blog settings -> features
* Revision 1.224 2007/05/29 01:17:20 fplanque
* advanced admin blog settings are now restricted by a special permission
* Revision 1.223 2007/05/17 20:44:19 fplanque
* Revision 1.222 2007/05/14 02:47:23 fplanque
* (not so) basic Tags framework
* Revision 1.221 2007/05/13 22:04:48 fplanque
* Revision 1.220 2007/05/13 20:44:52 fplanque
* Revision 1.219 2007/05/02 18:28:19 fplanque
* Revision 1.218 2007/04/27 09:34:45 fplanque
* Revision 1.217 2007/04/27 09:11:37 fplanque
* saving "spam" referers again (instead of buggy empty referers)
* Revision 1.216 2007/04/26 00:11:09 fplanque
* Revision 1.215 2007/04/19 01:51:53 fplanque
* Revision 1.214 2007/03/26 12:59:18 fplanque
* Revision 1.213 2007/03/25 15:18:57 fplanque
* Revision 1.212 2007/03/25 15:07:38 fplanque
* Revision 1.211 2007/03/12 14:10:10 waltercruz
* Changing the WHERE 1 queries to boolean (WHERE 1=1) queries to satisfy the standarts
* Revision 1.210 2007/02/21 21:33:43 fplanque
* allow jpeg extension on new installs/upgrades
* Revision 1.209 2007/02/13 00:38:11 blueyed
* Changed DB fields for 1.10.0: sess_data to MEDIUMTEXT (serialize() does not completely convert the binary data to text); post_content and itpr_content_prerendered to MEDIUMTEXT
* Revision 1.208 2007/02/05 00:35:44 fplanque
* Revision 1.207 2007/02/03 19:00:49 fplanque
* Revision 1.205 2007/01/23 04:19:50 fplanque
* handling of blog owners
* Revision 1.204 2007/01/15 20:54:57 fplanque
* Revision 1.203 2007/01/15 03:53:24 fplanque
* refactoring / simplified installer
* Revision 1.202 2007/01/12 02:40:26 fplanque
* widget default params proof of concept
* (param customization to be done)
* Revision 1.201 2007/01/08 23:45:48 fplanque
* A little less rough widget manager...
* (can handle multiple instances of same widget and remembers order)
* Revision 1.200 2007/01/08 21:53:51 fplanque
* Revision 1.199 2007/01/08 02:11:56 fplanque
* Blogs now make use of installed skins
* next step: make use of widgets inside of skins
* Revision 1.198 2006/12/20 23:07:24 blueyed
* Moved list of available plugins to separate sub-screen/form
* Revision 1.197 2006/12/15 23:31:22 fplanque
* reauthorized _ in urltitles.
* No breaking of legacy permalinks.
* - remains the default placeholder though.
* Revision 1.196 2006/12/07 20:31:29 fplanque
* Revision 1.195 2006/12/07 20:03:33 fplanque
* Woohoo! File editing... means all skin editing.
* Revision 1.194 2006/12/07 16:06:24 fplanque
* prepared new file editing permission
* Revision 1.193 2006/12/04 22:24:51 blueyed
* Revision 1.192 2006/12/04 21:25:18 fplanque
* removed user skin switching
* Revision 1.191 2006/12/04 19:41:11 fplanque
* Each blog can now have its own "archive mode" settings
* Revision 1.190 2006/12/04 18:16:51 fplanque
* Each blog can now have its own "number of page/days to display" settings
* Revision 1.189 2006/11/18 16:34:24 blueyed
* Revision 1.188 2006/11/18 03:58:21 fplanque
* removed duplicate indexes on T_links
* Revision 1.187 2006/11/14 23:17:00 fplanque
* adding stuff into the 9010 block weeks later was really evil. why do we have blocks for?
* Revision 1.186 2006/11/01 00:24:07 blueyed
* Revision 1.185 2006/10/14 21:11:48 blueyed
* Actually insert the transformed/generated ping plugins setting(s).
* Revision 1.184 2006/10/14 20:53:13 blueyed
* Transform blog ping settings to new Plugin structure.
* Revision 1.183 2006/10/11 17:21:09 blueyed
* Revision 1.182 2006/10/10 23:00:41 blueyed
* Fixed some table names to alias; fixed plugin install procedure; installed ping plugins; moved some upgrade code to 1.9
* Revision 1.181 2006/10/06 21:03:07 blueyed
* Removed deprecated/unused "upload_allowedext" Setting, which restricted file extensions during upload though!
* Revision 1.180 2006/10/05 02:58:44 blueyed
* Support for skipping index dropping, if it does not exist anymore. Should not bark out then! Also do not add the last checkpoint possibly twice.
* Revision 1.179 2006/10/05 02:42:22 blueyed
* Remove index hit_datetime, because its slow on INSERT (e.g. 1s)
* Revision 1.178 2006/10/02 19:07:32 blueyed
* Finished upgrade for 1.9-beta
* Revision 1.177 2006/10/01 22:11:43 blueyed
* Ping services as plugins.
* Revision 1.176 2006/10/01 00:14:58 blueyed
* plug_classpath should not have get merged already