Newer
Older
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql('ALTER TABLE {profile_fields} ADD page varchar(255) default NULL');
}
else {
$ret[] = update_sql('ALTER TABLE {profile_fields} ADD page varchar(255)');
$ret[] = update_sql('ALTER TABLE {profile_fields} ALTER COLUMN page SET default NULL');
}

Dries Buytaert
committed
$ret[] = update_sql("UPDATE {profile_fields} SET type = 'url' WHERE name = 'homepage'");

Dries Buytaert
committed
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {profile_fields} ADD required tinyint(1) DEFAULT '0' NOT NULL");
}
else {
$ret[] = update_sql("ALTER TABLE {profile_fields} ADD required smallint");
$ret[] = update_sql("ALTER TABLE {profile_fields} ALTER COLUMN required SET DEFAULT '0'");
$ret[] = update_sql("UPDATE {profile_fields} SET required = '0'");
$ret[] = update_sql("ALTER TABLE {profile_fields} ALTER COLUMN required SET NOT NULL");
}
function update_83() {
$ret = array();
if ($GLOBALS["db_type"] == "mysql") {
$ret[] = update_sql("CREATE TABLE {menu} (
mid int(10) unsigned NOT NULL default '0',
pid int(10) unsigned NOT NULL default '0',
path varchar(255) NOT NULL default '',
title varchar(255) NOT NULL default '',
weight tinyint(4) NOT NULL default '0',
visibility int(1) unsigned NOT NULL default '0',
status int(1) unsigned NOT NULL default '0',
PRIMARY KEY (mid)
);");
}
else {
$ret[] = update_sql("CREATE TABLE {menu} (
pid integer NOT NULL default '0',
path varchar(255) NOT NULL default '',
title varchar(255) NOT NULL default '',
weight smallint NOT NULL default '0',
visibility smallint NOT NULL default '0',
status smallint NOT NULL default '0',
PRIMARY KEY (mid)
);");
}

Steven Wittens
committed
db_next_id('{menu}_mid');
return $ret;
}

Dries Buytaert
committed
function update_84() {
$ret = array();
if ($GLOBALS["db_type"] == "mysql") {
$ret[] = update_sql("ALTER TABLE {vocabulary} ADD help VARCHAR(255) NOT NULL DEFAULT '' AFTER description;");

Dries Buytaert
committed
}
else {
$ret[] = update_sql("ALTER TABLE {vocabulary} ADD help VARCHAR(255)");
$ret[] = update_sql("ALTER TABLE {vocabulary} ALTER help SET DEFAULT ''");
$ret[] = update_sql("UPDATE {vocabulary} SET help = ''");
$ret[] = update_sql("ALTER TABLE {vocabulary} ALTER help SET NOT NULL");

Dries Buytaert
committed
}
return $ret;
}
function update_85() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {bundle} RENAME TO {aggregator_category}");
$ret[] = update_sql("ALTER TABLE {aggregator_category} DROP attributes");
$ret[] = update_sql("ALTER TABLE {aggregator_category} CHANGE bid cid int(10) NOT NULL auto_increment");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ADD description longtext NOT NULL");
$ret[] = update_sql("UPDATE {sequences} SET name = '{aggregator_category}_cid' WHERE name = '{bundle}_bid'");
$ret[] = update_sql("ALTER TABLE {feed} RENAME TO {aggregator_feed}");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} DROP attributes");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} ADD block tinyint(2) NOT NULL");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ADD block tinyint(2) NOT NULL");
$ret[] = update_sql("UPDATE {sequences} SET name = '{aggregator_feed}_fid' WHERE name = '{feed}_fid'");
$ret[] = update_sql("ALTER TABLE {item} RENAME TO {aggregator_item}");
$ret[] = update_sql("ALTER TABLE {aggregator_item} DROP attributes");
$max = db_result(db_query_range("SELECT iid FROM {aggregator_item} ORDER BY iid DESC", 0, 1));
if ($max) {
$ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{aggregator_item}_iid', $max)");
}
$ret[] = update_sql("CREATE TABLE {aggregator_category_feed} (
fid int(10) NOT NULL,
cid int(10) NOT NULL,
PRIMARY KEY (fid, cid)
)");
$ret[] = update_sql("CREATE TABLE {aggregator_category_item} (
iid int(10) NOT NULL,
cid int(10) NOT NULL,
PRIMARY KEY (iid, cid)
)");
$ret[] = update_sql("ALTER TABLE {aggregator_category} MODIFY description longtext NULL");
$ret[] = update_sql("ALTER TABLE {aggregator_item} MODIFY description longtext NULL");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} MODIFY description longtext NULL");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} MODIFY image longtext NULL");
$ret[] = update_sql("ALTER TABLE {bundle} RENAME TO {aggregator_category}");
$ret[] = update_sql("ALTER TABLE {aggregator_category} DROP attributes");
$ret[] = update_sql("ALTER TABLE {aggregator_category} RENAME bid TO cid");
$lastvalue = db_result(db_query('SELECT last_value from {bundle}_bid_seq'));
$ret[] = update_sql("CREATE SEQUENCE {aggregator_category}_cid_seq START $lastvalue MINVALUE 0");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER cid SET DEFAULT nextval('public.{aggregator_category}_cid_seq'::text)");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ADD description text");
$ret[] = update_sql("UPDATE {aggregator_category} SET description = ''");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER COLUMN description SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {feed} RENAME TO {aggregator_feed}");
$lastvalue = db_result(db_query('SELECT last_value from {feed}_fid_seq'));
$ret[] = update_sql("CREATE SEQUENCE {aggregator_feed}_fid_seq START $lastvalue MINVALUE 0");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} ALTER fid SET DEFAULT nextval('public.{aggregator_feed}_fid_seq'::text)");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} DROP attributes");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} ADD block smallint");
$ret[] = update_sql("UPDATE {aggregator_feed} SET block = 0");
$ret[] = update_sql("ALTER TABLE {aggregator_feed} ALTER COLUMN block SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ADD block smallint");
$ret[] = update_sql("UPDATE {aggregator_category} SET block = 0");
$ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER COLUMN block SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {item} RENAME TO {aggregator_item}");
$lastvalue = db_result(db_query('SELECT last_value from {item}_iid_seq'));
$ret[] = update_sql("CREATE SEQUENCE {aggregator_item}_iid_seq START $lastvalue MINVALUE 0");
$ret[] = update_sql("ALTER TABLE {aggregator_item} ALTER iid SET DEFAULT nextval('public.{aggregator_item}_iid_seq'::text)");
$ret[] = update_sql("ALTER TABLE {aggregator_item} DROP attributes");
$ret[] = update_sql("CREATE TABLE {aggregator_category_feed} (
fid integer NOT NULL default '0',
cid integer NOT NULL default '0',
PRIMARY KEY (fid,cid)
);");
$ret[] = update_sql("CREATE TABLE {aggregator_category_item} (
iid integer NOT NULL default '0',
cid integer NOT NULL default '0',
PRIMARY KEY (iid,cid)
)");
function update_86() {
$ret = array();
$ret[] = update_sql("INSERT INTO {users_roles} (uid, rid) SELECT uid, rid FROM {users}");
// TODO: should we verify the insert above worked before dropping rid?
if ($GLOBALS['db_type'] == 'mysql') {
//only the most recent versions of postgres support dropping columns
$ret[] = update_sql("ALTER TABLE {users} DROP rid");
}
// Works for both postgres and mysql
$ret = array();
$ret[] = update_sql("ALTER TABLE {comments} ADD name varchar(60) DEFAULT NULL");
$ret[] = update_sql("ALTER TABLE {comments} ADD mail varchar(64) DEFAULT NULL");
$ret[] = update_sql("ALTER TABLE {comments} ADD homepage varchar(255) DEFAULT NULL");
return $ret;
}
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {menu} DROP status");
$ret[] = update_sql("ALTER TABLE {menu} DROP visibility");
$ret[] = update_sql("ALTER TABLE {menu} ADD type INT(2) UNSIGNED DEFAULT '0' NOT NULL");
else {
$ret[] = update_sql("ALTER TABLE {menu} ADD type smallint");
$ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET DEFAULT '0'");
$ret[] = update_sql("UPDATE {menu} SET type = '0'");
$ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET NOT NULL");
}
$ret[] = update_sql("DELETE FROM {menu}");
return $ret;
}
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {node} CHANGE static sticky INT(2) DEFAULT '0' NOT NULL");
}
else {
$ret[] = update_sql("ALTER TABLE {node} RENAME static TO sticky;");
}
// Change the node settings, so that it uses node_sticky_$type instead of node_static_$type
$result = db_query("SELECT * FROM {variable} WHERE name LIKE 'node_static_%'");
while ($variable = db_fetch_object($result)) {
//get the node type name, place it into $name_arr. The name can be found with $name_arr[2]

Steven Wittens
committed
$name_arr = explode("_", $variable->name, 3);
$ret[] = update_sql("INSERT INTO {variable} (name,value) VALUES ('node_sticky_". $name_arr[2] ."','". $variable->value. "')");
}
$ret[] = db_query("DELETE FROM {variable} WHERE name LIKE 'node_static_%'");
return $ret;
}
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {profile_fields} CHANGE overview visibility INT(1) UNSIGNED DEFAULT '0' NOT NULL");
}
else {
$ret[] = update_sql("ALTER TABLE {profile_fields} RENAME overview TO visibility");
}
$ret[] = update_sql("UPDATE {profile_fields} SET visibility = 2 WHERE visibility = 1");
$ret[] = update_sql("UPDATE {profile_fields} SET visibility = 1 WHERE visibility = 0");
return $ret;
}

Dries Buytaert
committed
function update_91() {
$ret = array();
if ($GLOBALS["db_type"] == "pgsql") {
// node_created was created implicitly somewhere else

Dries Buytaert
committed
$ret[] = update_sql("CREATE INDEX node_changed ON {node} (changed)");
}
else {
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_created (created)");
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_changed (changed)");
}
return $ret;
}
function update_93() {
$ret = array();
if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('DROP INDEX url_alias_src_idx');
}
else {
$ret[] = update_sql('ALTER TABLE {url_alias} DROP INDEX src');
}
$ret[] = update_sql("INSERT INTO {url_alias} (src, dst) VALUES ('node/feed', 'rss.xml')");

Steven Wittens
committed
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
function update_94() {
/**
* Postgres only update
*/
$ret = array();
if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('DROP FUNCTION "greatest"(integer, integer)');
$ret[] = update_sql("
CREATE FUNCTION greatest(integer, integer) RETURNS integer AS '
BEGIN
IF $2 IS NULL THEN
RETURN $1;
END IF;
IF $1 > $2 THEN
RETURN $1;
END IF;
RETURN $2;
END;
' LANGUAGE 'plpgsql';
");
}
return $ret;
}
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("CREATE TABLE {node_access} (
nid int(10) unsigned NOT NULL default '0',
gid int(10) unsigned NOT NULL default '0',
realm varchar(255) NOT NULL default '',
grant_view tinyint(1) unsigned NOT NULL default '0',
grant_update tinyint(1) unsigned NOT NULL default '0',
grant_delete tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (nid,gid,realm)
)");
}
else {
$ret[] = update_sql("CREATE TABLE {node_access} (
nid SERIAL,
gid integer NOT NULL default '0',
realm text NOT NULL default '',
grant_view smallint NOT NULL default '0',
grant_update smallint NOT NULL default '0',
grant_delete smallint NOT NULL default '0',
PRIMARY KEY (nid,gid,realm)
)");
$ret[] = update_sql("CREATE FUNCTION \"concat\"(text, text) RETURNS text AS '
BEGIN
RETURN $1 || $2;
END;
' LANGUAGE 'plpgsql';");
}
$ret[] = update_sql("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0);");
$ret[] = update_sql('ALTER TABLE {accesslog} ADD path VARCHAR(255) DEFAULT NULL');

Dries Buytaert
committed
$ret[] = update_sql('UPDATE {accesslog} SET path = CONCAT("node/", nid) WHERE nid != 0');
$ret[] = update_sql('ALTER TABLE {accesslog} ADD title VARCHAR(255) DEFAULT NULL');
/* Only supported by MySQL 4.0.4 and up
$ret[] = update_sql('UPDATE {accesslog} a, {node} n SET a.title = n.title WHERE a.nid = n.nid');*/
$ret[] = update_sql('ALTER TABLE {accesslog} DROP nid');
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {menu} ADD description varchar(255) DEFAULT '' NOT NULL");
}
else {
$ret[] = update_sql("ALTER TABLE {menu} ADD description smallint");
$ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET DEFAULT '0'");
$ret[] = update_sql("UPDATE {menu} SET description = '0'");
$ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET NOT NULL");
}
function update_97() {
$convert = array('node/view/' => 'node/', 'book/view/' => 'book/', 'user/view/' => 'user/');
foreach ($convert as $from => $to) {
$result = db_query("SELECT pid, src FROM {url_alias} WHERE src LIKE '%s%%'", $from);
while ($alias = db_fetch_object($result)) {
db_query("UPDATE {url_alias} SET src = '%s' WHERE pid = '%s'", str_replace($from, $to, $alias->src), $alias->pid);
}
}
return array();
}
function update_98() {
$result = db_query("SELECT pid, src FROM {url_alias} WHERE src LIKE 'taxonomy/%%'");
while ($alias = db_fetch_object($result)) {
list(, $page, $op, $terms) = explode('/', $alias->src);
if ($page == 'feed' || $page == 'page') {
switch ($op) {
case 'or':
$new = 'taxonomy/term/'. str_replace(',', '+', $terms);
break;
case 'and':
$new = 'taxonomy/term/'. $terms;
break;
}
if ($new) {
if ($page == 'feed') {
$new .= '/0/feed';
}
db_query("UPDATE {url_alias} SET src = '%s' WHERE pid = '%s'", $new, $alias->pid);
}
}
}
return array();
}

Steven Wittens
committed
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
function update_99() {
// Filter patch - Multiple input formats
$ret = array();
/*
** Load the list of PHP book and page nodes.
*/
$php_nodes = array();
$res = db_query("SELECT nid FROM {book} WHERE format = 1");
while ($book = db_fetch_object($res)) {
$php_nodes[] = $book->nid;
}
$res = db_query("SELECT nid FROM {page} WHERE format = 1");
while ($page = db_fetch_object($res)) {
$php_nodes[] = $page->nid;
}
/*
** Apply database changes
*/
if ($GLOBALS['db_type'] == 'mysql') {
// Filters table
$ret[] = update_sql("ALTER TABLE {filters} ADD format int(4) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {filters} ADD delta tinyint(2) NOT NULL default '0'");
// Filter_formats table
$ret[] = update_sql("CREATE TABLE {filter_formats} (
format int(4) NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
roles varchar(255) NOT NULL default '',
cache tinyint(2) NOT NULL default '1',
PRIMARY KEY (format)
)");
// Store formats in nodes, comments and boxes
$ret[] = update_sql("ALTER TABLE {boxes} CHANGE type format int(4) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {comments} ADD format int(4) NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {node} ADD format int(4) NOT NULL default '0'");
// Get rid of the old book/page type info
$ret[] = update_sql("ALTER TABLE {book} DROP format");
$ret[] = update_sql("ALTER TABLE {page} DROP format");
}
else if ($GLOBALS['db_type'] == 'pgsql') {
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
$result = db_query("SELECT * FROM {filters}");
if ($result) {
while ($obj = db_fetch_object($result)) {
$filters[] = $obj;
}
}
$ret[] = update_sql("DROP TABLE {filters}");
$ret[] = update_sql("CREATE TABLE {filters} (
format integer NOT NULL DEFAULT '0',
module varchar(64) NOT NULL DEFAULT '',
delta smallint NOT NULL DEFAULT 1,
weight smallint DEFAULT '0' NOT NULL
)");
$ret[] = update_sql("CREATE INDEX filters_module_idx ON filters(module)");
if (is_array($filters)) {
foreach ($filters as $filter) {
db_query("INSERT INTO {filters} VALUES (%d, '%s', %d, %d)", $filter->format ? $filter->format : 0, $filter->module, $filter->delta ? $filter->delta : 1, $filter->weight);
}
}
$ret[] = update_sql("CREATE TABLE {filter_formats} (
format SERIAL,
name varchar(255) NOT NULL default '',
roles varchar(255) NOT NULL default '',
cache smallint NOT NULL default '0',
PRIMARY KEY (format)
)");
$ret[] = update_sql("ALTER TABLE {boxes} RENAME type TO format");
$ret[] = update_sql("ALTER TABLE {comments} ADD format smallint");
$ret[] = update_sql("ALTER TABLE {comments} ALTER COLUMN format SET DEFAULT '0'");
$ret[] = update_sql("UPDATE {comments} SET format = '0'");
$ret[] = update_sql("ALTER TABLE {comments} ALTER COLUMN format SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {node} ADD format smallint");
$ret[] = update_sql("ALTER TABLE {node} ALTER COLUMN format SET DEFAULT '0'");
$ret[] = update_sql("UPDATE {node} SET format = '0'");
$ret[] = update_sql("ALTER TABLE {node} ALTER COLUMN format SET NOT NULL");
/* Postgres usually can't drop columns
$ret[] = update_sql("ALTER TABLE {book} DROP format");
$ret[] = update_sql("ALTER TABLE {page} DROP format");
*/

Steven Wittens
committed
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
}
// Initialize all nodes and comments to the legacy format (see below)
$ret[] = update_sql("UPDATE {node} SET format = 1");
$ret[] = update_sql("UPDATE {comments} SET format = 1");
// Set format to PHP for the old PHP book/page nodes.
if (count($php_nodes)) {
$ret[] = update_sql("UPDATE {node} SET format = 2 WHERE nid IN (". implode(',', $php_nodes) .")");
}
// Boxes now use the filtering system as well.
// Type 0 (HTML) maps to Format 3 (Full HTML).
// Type 1 (PHP) maps to Format 2 (PHP).
$ret[] = update_sql("UPDATE {boxes} SET format = 3 - format");
/*
** Update PHP content to use <?php ?> tags.
*/
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("UPDATE {node} SET teaser = CONCAT('<?php ', teaser) WHERE format = 2");
$ret[] = update_sql("UPDATE {node} SET body = CONCAT('<?php ', body) WHERE format = 2");
$ret[] = update_sql("UPDATE {boxes} SET body = CONCAT('<?php ', body) WHERE format = 2");
}
else if ($GLOBALS['db_type'] == 'pgsql') {
// TODO: someone needs to verify if this works.
$ret[] = update_sql("UPDATE {node} SET teaser = '<?php ' || teaser WHERE format = 2");
$ret[] = update_sql("UPDATE {node} SET body = '<?php ' || body WHERE format = 2");
$ret[] = update_sql("UPDATE {boxes} SET body = '<?php ' || body WHERE format = 2");
}
/*
** We now set up some input formats. One of these is a 'legacy' format which
** tries to preserve as much settings as possible from before the patch.
** The other two are 'PHP code' and 'Full HTML'.
*/
// We pick an appropriate name for the legacy format.
$old_html_filter = variable_get('filter_html', 0);
if ($old_html_filter == FILTER_HTML_ESCAPE) {
$default = 'Plain text';
}
else {
$default = 'Filtered HTML';
}
// Make sure the legacy format is accessible to all roles
$all_roles = array_keys(user_roles());
$ret[] = update_sql("INSERT INTO {filter_formats} VALUES (". db_next_id("{filter_formats}_format") .",'$default',',". implode(',', $all_roles) .",',1)");

Steven Wittens
committed
// Determine which roles have the old 'create php content' permission.
$res = db_query("SELECT rid FROM {permission} WHERE perm LIKE '%create php content%'");
$php_roles = array();
while ($role = db_fetch_object($res)) {
$php_roles[] = $role->rid;
}
$ret[] = update_sql("INSERT INTO {filter_formats} VALUES (". db_next_id("{filter_formats}_format") .",'PHP code','". implode(',', $php_roles) .",',0)");

Steven Wittens
committed
// This is a 'Full HTML' format which allows all HTML without restrictions.
$ret[] = update_sql("INSERT INTO {filter_formats} VALUES (". db_next_id("{filter_formats}_format") .",'Full HTML','',1)");

Steven Wittens
committed
// Set the default format to the legacy format
variable_set('filter_default_format', 1);
// Put the old filters into the legacy format
$ret[] = update_sql("UPDATE {filters} SET format = 1");
// Add filter.module's standard filters (these used to be hardcoded).
if (!variable_get('rewrite_old_urls', 0)) {
$ret[] = update_sql("DELETE FROM {filters} WHERE module = 'filter'");
}
else {
$ret[] = update_sql("UPDATE {filters} SET delta = 2 WHERE module ='filter'");
}
if ($old_html_filter != 0) {
$ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (1,'filter',0,0)"); // HTML tag/style filter
}

Steven Wittens
committed
$ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (1,'filter',2,1)"); // Linebreak filter

Steven Wittens
committed
$ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (2,'filter',1,0)"); // PHP evaluator

Steven Wittens
committed
$ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (3,'filter',2,0)"); // Linebreak filter

Steven Wittens
committed
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
// Migrate the settings for all core/contrib filtering modules into the legacy
// format.
$migrate = array('filter_html', // filter.module
'allowed_html',
'filter_style',
'anyfilter_regexps', // anyfilter.module
'htmlcorrector_smartclose', // htmlcorrector.module
'htmlcorrector_xhtmlify',
'htmlcorrector_valueentities',
'project_filter', // project.module
'latex_filter_link' // latex.module
);
foreach ($migrate as $variable) {
$value = variable_get($variable, NULL);
if ($value != NULL) {
variable_set($variable .'_1', $value);
variable_del($variable);
}
}
return $ret;
}
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
function update_100() {
$ret = array();
if ($GLOBALS["db_type"] == "mysql") {
$ret[] = update_sql("CREATE TABLE {locales_source} (
lid int(11) NOT NULL auto_increment,
location varchar(128) NOT NULL default '',
source blob NOT NULL,
PRIMARY KEY (lid)
)");
$ret[] = update_sql("CREATE TABLE {locales_target} (
lid int(11) NOT NULL default '0',
translation blob NOT NULL,
locale varchar(12) NOT NULL default '',
plid int(11) NOT NULL default '0',
plural int(1) NOT NULL default '0',
KEY lid (lid),
KEY lang (locale),
KEY plid (plid),
KEY plural (plural)
)");
$ret[] = update_sql("ALTER TABLE {users} CHANGE language language varchar(12) NOT NULL default ''");
}
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
else {
$ret[] = update_sql("CREATE TABLE {locales_target} (
lid int4 NOT NULL default '0',
translation text DEFAULT '' NOT NULL,
locale varchar(12) NOT NULL default '',
plid int4 NOT NULL default '0',
plural int4 NOT NULL default '0'
)");
$ret[] = update_sql("CREATE INDEX {locales_target}_lid ON {locales_target}(lid)");
$ret[] = update_sql("CREATE INDEX {locales_target}_locale ON {locales_target}(locale)");
$ret[] = update_sql("CREATE INDEX {locales_target}_plid ON {locales_target}(plid)");
$ret[] = update_sql("CREATE INDEX {locales_target}_plural ON {locales_target}(plural)");
$ret[] = update_sql("CREATE SEQUENCE {locales_source}_lid INCREMENT 1 START 0 MINVALUE 0");
$ret[] = update_sql("CREATE TABLE {locales_source} (
lid serial,
location varchar(128) NOT NULL default '',
source text NOT NULL,
PRIMARY KEY (lid)
)");
$ret[] = update_sql("ALTER TABLE {users} rename language to lang_archive");
$ret[] = update_sql("ALTER TABLE {users} add language varchar(12)");
$ret[] = update_sql("ALTER TABLE {users} ALTER language SET DEFAULT ''");
$ret[] = update_sql("UPDATE {users} SET language = ''");
$ret[] = update_sql("ALTER TABLE {users} ALTER language SET NOT NULL");
$ret[] = update_sql("update {users} set language = lang_archive");
$ret[] = update_sql("INSERT INTO {locales_meta} (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1')");
include_once 'includes/locale.inc';
// get the language columns
$result = db_query('SELECT * FROM {locales} LIMIT 1');
$fields = array();
if (db_num_rows($result)) {
$columns = array_keys(db_fetch_array($result));
foreach ($columns as $field) {
$fields[$field] = 1;
}
// but not the fixed fields
unset($fields['lid'], $fields['location'], $fields['string']);
// insert locales
$list = _locale_get_iso639_list();
foreach ($fields as $key => $value) {
if (db_result(db_query("SELECT COUNT(lid) FROM {locales} WHERE $key != ''"))) {
if (isset($list[$key])) {
$name = $list[$key][0];
if ($key == 'en') {
$key = 'en-local';
}
db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $name);
}
else {
db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $key);
}
}
}
// get all strings
$result = db_query('SELECT * FROM {locales}');

Steven Wittens
committed
while ($entry = db_fetch_object($result)) {
// insert string if at least one translation exists
$test = 'return $entry->'. implode(' == "" && $entry->', array_keys($fields)) .' == "";';
if (!eval($test)) {
db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $entry->location, $entry->string);
$lid = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE location = '%s' AND source = '%s'", $entry->location, $entry->string));
foreach ($fields as $key => $value) {
// insert translation if non-empty

Steven Wittens
committed
if ($key == 'en') {
$keynew = 'en-local';
}
else {
$keynew = $key;
}
db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid->lid, $entry->$key, $keynew);
}
}
}
}
$ret = array();
$ret[] = update_sql("DROP TABLE {locales}");
return $ret;
}

Steven Wittens
committed
function update_102() {
return array(update_sql("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap) VALUES ('modules/legacy.module', 'legacy', 'module', '', 1, 0, 0)"));
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("CREATE TABLE {files} (
fid int(10) unsigned NOT NULL default '0',
nid int(10) unsigned NOT NULL default '0',
filename varchar(255) NOT NULL default '',
filepath varchar(255) NOT NULL default '',
filemime varchar(255) NOT NULL default '',
filesize int(10) unsigned NOT NULL default '0',
list tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (fid)
)");
}
else {
$ret[] = update_sql("CREATE TABLE {files} (
fid serial,
nid integer NOT NULL default '0',
filename varchar(255) NOT NULL default '',
filepath varchar(255) NOT NULL default '',
filemime varchar(255) NOT NULL default '',
filesize integer NOT NULL default '0',
list smallint NOT NULL default '0',
PRIMARY KEY (fid)
)");
}
$ret = array();
if (variable_get('theme_default', 'xtemplate') == 'chameleon') {
$ret[] = update_sql("DELETE FROM {system} WHERE name = 'chameleon'");
$ret[] = update_sql("INSERT INTO {system} VALUES ('themes/chameleon/chameleon.theme','chameleon','theme','',1,0,0)");
$ret[] = update_sql("INSERT INTO {system} VALUES ('themes/chameleon/marvin/style.css','marvin','theme','themes/chameleon/chameleon.theme',1,0,0)");
if (variable_get("chameleon_stylesheet", "themes/chameleon/pure/chameleon.css") == "themes/chameleon/marvin/chameleon.css") {
variable_set('theme_default', 'chameleon/marvin');
}
else {
variable_set('theme_default', 'chameleon');
}
}
elseif (variable_get('theme_default', 'xtemplate') == 'xtemplate') {
$ret[] = update_sql("DELETE FROM {system} WHERE name = 'xtemplate'");
$ret[] = update_sql("INSERT INTO {system} VALUES ('themes/bluemarine/xtemplate.xtmpl','bluemarine','theme','themes/engines/xtemplate/xtemplate.engine',1,0,0)");
$ret[] = update_sql("INSERT INTO {system} VALUES ('themes/pushbutton/xtemplate.xtmpl','pushbutton','theme','themes/engines/xtemplate/xtemplate.engine',1,0,0)");
$ret[] = update_sql("INSERT INTO {system} VALUES ('themes/engines/xtemplate/xtemplate.engine','xtemplate','theme_engine','',1,0,0)");
if (variable_get('xtemplate_template', 'default') == 'pushbutton') {
variable_set('theme_default', 'pushbutton');
}
else {
variable_set('theme_default', 'bluemarine');
}

Steven Wittens
committed
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
// Convert old xtemplate settings to new theme system
$settings = array();
$convert = array('xtemplate_primary_links' => 'primary_links',
'xtemplate_secondary_links' => 'secondary_links',
'xtemplate_search_box' => 'toggle_search',
'xtemplate_avatar_node' => 'toggle_node_user_picture',
'xtemplate_avatar_comment' => 'toggle_comment_user_picture');
foreach ($convert as $from => $to) {
if (($value = variable_get($from, NULL)) != NULL) {
$settings[$to] = $value;
variable_del($from);
}
}
// Logo requires special treatment. Used to be an HTML tag, now it's a path to an image.
if (($logo = variable_get('xtemplate_logo', NULL)) != NULL) {
$match = array();
// If logo was of the form <img src="..">, convert it.
if (preg_match('@src=(?:["\']?)(.+?)(?:["\']?(?:>| ?/>))@i', $logo, $match)) {
$settings['default_logo'] = 0;
$settings['logo_path'] = $match[1];
}
variable_del('xtemplate_logo');
}
if (count($settings) > 0) {
variable_set('theme_settings', $settings);
}
// These are not part of 'theme_settings'
$convert = array('xtemplate_avatar_default' => 'user_picture_default',
'xtemplate_mission' => 'site_mission');
foreach ($convert as $from => $to) {
if (($value = variable_get($from, NULL)) != NULL) {
variable_set($to, $value);
variable_del($from);
}
}
function update_105() {
$ret = array();
$shadowupdates = db_query("SELECT nid,tid FROM {forum} WHERE shadow=0");
while ($shadowrecord = db_fetch_object($shadowupdates)) {
db_query("DELETE FROM {term_node} WHERE nid = %d AND tid <> %d", $shadowrecord->nid, $shadowrecord->tid);
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("ALTER TABLE {forum} DROP shadow");
$ret[] = update_sql('ALTER TABLE {node} ADD INDEX node_status_type (status, type, nid)');
}
else {
// PostgreSQL is incapable of dropping columns in all but the latest versions.
$ret[] = update_sql("CREATE INDEX {node}_status_type_idx ON {node} (status, type, nid)");
$ret[] = update_sql("CREATE FUNCTION \"if\"(integer, text, text) RETURNS text AS '
BEGIN
IF $1 THEN
RETURN $2;
END IF;
IF NOT $1 THEN
RETURN $3;
END IF;
END;
' LANGUAGE 'plpgsql'");
}
function update_106() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql('ALTER TABLE {cache} ADD INDEX expire (expire)');
}
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('CREATE INDEX {cache}_expire_idx ON {cache}(expire)');
}
$ret[] = update_sql('DELETE FROM {cache}');
return $ret;
}
function update_107() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql('ALTER TABLE {profile_fields} ADD register TINYINT(1) DEFAULT 0 NOT NULL AFTER required');
}
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql('ALTER TABLE {profile_fields} ADD register smallint');
}
return $ret;
}
function update_108() {

Dries Buytaert
committed
$ret = array();
// This update is needed for 4.5-RC sites, where profile data was not being
// wiped from the user->data column correctly because update_80() was faulty.
if (!variable_get('update_80_fix', false)) {
// The data field needs to be cleared of profile fields.
$result = db_query("SELECT uid FROM {users} WHERE data LIKE '%profile%'");
while ($uid = db_fetch_object($result)) {
$user = user_load(array('uid' => $uid->uid));
$unset = array();
foreach ($user as $key => $value) {
if (substr($key, 0, 8) == 'profile_') {
// Fields with a NULL value are wiped from the data column.
$unset[$key] = NULL;
}
}
user_save($user, $unset);
}
}

Dries Buytaert
committed
return $ret;
}
function update_109() {
$ret = array();
// This is to fix the PostreSQL locales_source table.
if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql("ALTER TABLE {locales_source} RENAME location TO old_location");
$ret[] = update_sql("ALTER TABLE {locales_source} ADD COLUMN location text");
db_query("UPDATE {locales_source} SET location = old_location");
$ret[] = update_sql("ALTER TABLE {locales_source} ALTER COLUMN location SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {locales_source} ALTER COLUMN location SET DEFAULT ''");
$ret[] = update_sql("ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_locale_key ");
$ret[] = update_sql("ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_plid_key ");
$ret[] = update_sql("ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_plural_key ");
}
return $ret;
}
function update_110() {
$ret = array();
// TODO: needs PGSQL version
if ($GLOBALS['db_type'] == 'mysql') {
/*
** Search
*/
$ret[] = update_sql('DROP TABLE {search_index}');
$ret[] = update_sql("CREATE TABLE {search_index} (
word varchar(50) NOT NULL default '',
sid int(10) unsigned NOT NULL default '0',
type varchar(16) default NULL,
fromsid int(10) unsigned NOT NULL default '0',
fromtype varchar(16) default NULL,
score int(10) unsigned default NULL,
KEY sid (sid),
KEY fromsid (fromsid),
KEY word (word)
) TYPE=MyISAM");
$ret[] = update_sql("CREATE TABLE {search_total} (
word varchar(50) NOT NULL default '',
count int(10) unsigned default NULL,
) TYPE=MyISAM");
$ret[] = update_sql("DELETE FROM {variable} WHERE name = 'node_cron_last'");
/*
** Blocks
*/
$ret[] = update_sql('ALTER TABLE {blocks} DROP path');
$ret[] = update_sql('ALTER TABLE {blocks} ADD visibility tinyint(1) NOT NULL');
$ret[] = update_sql('ALTER TABLE {blocks} ADD pages text NOT NULL');
$ret[] = update_sql('UPDATE {blocks} SET status = 1, custom = 2 WHERE status = 0 AND custom = 1');
return $ret;
}

Dries Buytaert
committed
function update_111() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'throttle_%'");
$ret[] = update_sql('ALTER TABLE {sessions} ADD PRIMARY KEY sid (sid)');
}
return $ret;
}
event varchar(64) NOT NULL default '',
hostname varchar(128) NOT NULL default '',
timestamp int(11) NOT NULL default '0'
);");
return $ret;
}

Dries Buytaert
committed
function update_113() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql('ALTER TABLE {accesslog} ADD aid int(10) NOT NULL auto_increment, ADD PRIMARY KEY (aid)');

Dries Buytaert
committed
}
// Flush the menu cache:
cache_clear_all('menu:', TRUE);
return $ret;
}
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
function update_114() {
$ret = array();
if ($GLOBALS['db_type'] == 'mysql') {
$ret[] = update_sql("CREATE TABLE {queue} (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
vote int(3) NOT NULL default '0',
PRIMARY KEY (nid, uid)
)");
}
else if ($GLOBALS['db_type'] == 'pgsql') {
$ret[] = update_sql("CREATE TABLE {queue} (
nid integer NOT NULL default '0',
uid integer NOT NULL default '0',
vote integer NOT NULL default '0'
)");
$ret[] = update_sql("CREATE INDEX queue_nid_idx ON queue(nid)");
$ret[] = update_sql("CREATE INDEX queue_uid_idx ON queue(uid)");
}
$result = db_query("SELECT nid, votes, score, users FROM {node}");
while ($node = db_fetch_object($result)) {
if (isset($node->users)) {
$arr = explode(',', $node->users);
unset($node->users);