X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=update.php;h=e3b1c31b33a5fee9cc01c8c97eb11b6877ef7a3c;hb=02faf424037e7f3569c5c0a2f8c2d8a1286c218b;hp=bc0e17b8b0bdf78f642ebd0d312b5c44451fe0d7;hpb=3849e7c9ff8d3cbe097714e4811ed4c92a780f8d;p=friendica.git diff --git a/update.php b/update.php index bc0e17b8b0..e3b1c31b33 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ is_valid()) { + if ($ph->is_valid()) { $ph->scaleImage(48); $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0)); } @@ -157,15 +157,14 @@ function update_1014() { $r = q("SELECT * FROM `contact` WHERE 1"); if (dbm::is_result($r)) { foreach ($r as $rr) { - if (stristr($rr['thumb'],'avatar')) { + if(stristr($rr['thumb'],'avatar')) q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d", dbesc(str_replace('avatar','micro',$rr['thumb'])), intval($rr['id'])); - } else { + else q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d", dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])), intval($rr['id'])); - } } } } @@ -243,8 +242,8 @@ function update_1022() { } function update_1023() { - q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `timezone` , - ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` "); + q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `timezone` , + ADD `login_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `register_date` "); } function update_1024() { @@ -327,22 +326,23 @@ function update_1032() { function update_1033() { q("CREATE TABLE IF NOT EXISTS `cache` ( - `k` CHAR( 255 ) NOT NULL PRIMARY KEY , - `v` TEXT NOT NULL, - `updated` DATETIME NOT NULL - ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); + `k` CHAR( 255 ) NOT NULL PRIMARY KEY , + `v` TEXT NOT NULL, + `updated` DATETIME NOT NULL + ) DEFAULT CHARSET=utf8 "); } function update_1034() { - // If you have any of these parent-less posts they can cause problems, and - // we need to delete them. You can't see them anyway. - // Legitimate items will usually get re-created on the next - // pull from the hub. - // But don't get rid of a post that may have just come in - // and may not yet have the parent id set. - + /* + * If you have any of these parent-less posts they can cause problems, and + * we need to delete them. You can't see them anyway. + * Legitimate items will usually get re-created on the next + * pull from the hub. + * But don't get rid of a post that may have just come in + * and may not yet have the parent id set. + */ q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE"); } @@ -350,7 +350,7 @@ function update_1034() { function update_1035() { - q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` "); + q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `last-update` "); } @@ -369,11 +369,13 @@ function update_1036() { } function update_1037() { + q("ALTER TABLE `contact` CHANGE `lrdd` `alias` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL "); + } function update_1038() { - q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` "); + q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` "); } function update_1039() { @@ -442,7 +444,7 @@ function update_1049() { `user` CHAR( 255 ) NOT NULL , `pass` CHAR( 255 ) NOT NULL , `reply_to` CHAR( 255 ) NOT NULL , - `last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' + `last_check` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ) ENGINE = MYISAM "); } @@ -453,8 +455,8 @@ function update_1050() { `filetype` CHAR( 64 ) NOT NULL , `filesize` INT NOT NULL , `data` LONGBLOB NOT NULL , - `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', `allow_cid` MEDIUMTEXT NOT NULL , `allow_gid` MEDIUMTEXT NOT NULL , `deny_cid` MEDIUMTEXT NOT NULL , @@ -530,11 +532,9 @@ function update_1065() { } function update_1066() { - $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` "); - - if ($r) { + $r = q("ALTER TABLE `item` ADD `received` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` "); + if($r) q("ALTER TABLE `item` ADD INDEX ( `received` ) "); - } $r = q("UPDATE `item` SET `received` = `edited` WHERE 1"); } @@ -596,11 +596,10 @@ function update_1074() { q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` "); $r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1"); if (dbm::is_result($r)) { - foreach ($r as $rr) { + foreach($r as $rr) q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d", intval($rr['uid']) ); - } } q("ALTER TABLE `profile` DROP `hidewall`"); } @@ -616,9 +615,8 @@ function update_1075() { $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1", dbesc($guid) ); - if (!dbm::is_result($x)) { + if(! count($x)) $found = false; - } } while ($found == true ); q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d", @@ -676,7 +674,7 @@ function update_1079() { } function update_1080() { - q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'"); + q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00'"); } function update_1081() { @@ -687,19 +685,14 @@ function update_1082() { q("ALTER TABLE `photo` ADD `guid` CHAR( 64 ) NOT NULL AFTER `contact-id`, ADD INDEX ( `guid` ) "); // make certain the following code is only executed once - - $r = q("SELECT `id` FROM `photo` WHERE `guid` != '' LIMIT 1"); - - if (dbm::is_result($r)) { + $r = q("select `id` from `photo` where `guid` != '' limit 1"); + if (dbm::is_result($r)) return; - } - $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`"); - if (dbm::is_result($r)) { foreach ($r as $rr) { $guid = get_guid(); - q("UPDATE `photo` SET `guid` = '%s' WHERE `resource-id` = '%s'", + q("update `photo` set `guid` = '%s' where `resource-id` = '%s'", dbesc($guid), dbesc($rr['resource-id']) ); @@ -736,7 +729,7 @@ function update_1086() { } function update_1087() { - q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `edited` "); + q("ALTER TABLE `item` ADD `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` "); $r = q("SELECT `id` FROM `item` WHERE `parent` = `id` "); if (dbm::is_result($r)) { @@ -744,21 +737,19 @@ function update_1087() { $x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1", intval($rr['id']) ); - - if (dbm::is_result($x)) { + if(count($x)) q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d", dbesc($x[0]['cdate']), intval($rr['id']) ); - } } } } function update_1088() { q("ALTER TABLE `user` ADD `account_expired` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `expire` , - ADD `account_expires_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expired` , - ADD `expire_notification_sent` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `account_expires_on` "); + ADD `account_expires_on` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `account_expired` , + ADD `expire_notification_sent` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `account_expires_on` "); } function update_1089() { @@ -859,14 +850,14 @@ function update_1099() { function update_1100() { q("ALTER TABLE `contact` ADD `nurl` CHAR( 255 ) NOT NULL AFTER `url` "); - q("ALTER TABLE `contact` ADD INDEX (`nurl`) "); + q("alter table contact add index (`nurl`) "); require_once('include/text.php'); - $r = q("SELECT `id`, `url` FROM `contact` WHERE `url` != '' AND `nurl` = '' "); + $r = q("select id, url from contact where url != '' and nurl = '' "); if (dbm::is_result($r)) { foreach ($r as $rr) { - q("UPDATE `contact` SET `nurl` = '%s' WHERE `id` = %d", + q("update contact set nurl = '%s' where id = %d", dbesc(normalise_link($rr['url'])), intval($rr['id']) ); @@ -896,7 +887,6 @@ function update_1102() { function update_1103() { -/// @TODO Commented out: // q("ALTER TABLE `item` ADD INDEX ( `wall` ) "); q("ALTER TABLE `item` ADD FULLTEXT ( `tag` ) "); q("ALTER TABLE `contact` ADD INDEX ( `pending` ) "); @@ -943,8 +933,8 @@ ADD INDEX ( `hidden` ) "); function update_1109() { q("ALTER TABLE `conv` ADD `creator` CHAR( 255 ) NOT NULL , - ADD `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', - ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + ADD `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + ADD `updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD `subject` MEDIUMTEXT NOT NULL, ADD INDEX ( `created` ), ADD INDEX ( `updated` ) "); } @@ -1042,11 +1032,9 @@ function update_1120() { $r = q("describe item"); if (dbm::is_result($r)) { - foreach ($r as $rr) { - if ($rr['Field'] == 'spam') { + foreach($r as $rr) + if($rr['Field'] == 'spam') return; - } - } } q("ALTER TABLE `item` ADD `spam` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `visible` , ADD INDEX (`spam`) "); @@ -1080,16 +1068,16 @@ function update_1121() { } function update_1122() { - q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` , +q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` , ADD INDEX ( `hash` ) "); } function update_1123() { - set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr'); +set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr'); } function update_1124() { - q("ALTER TABLE `item` ADD INDEX (`author-name`) "); +q("alter table item add index (`author-name`) "); } function update_1125() { @@ -1125,7 +1113,7 @@ function update_1127() { function update_1128() { - q("ALTER TABLE `spam` ADD `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `term` "); + q("alter table spam add `date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `term` "); } function update_1129() { @@ -1151,9 +1139,9 @@ INDEX ( `username` ) } function update_1133() { - q("ALTER TABLE `user` ADD `unkmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocktags` , ADD INDEX ( `unkmail` ) "); - q("ALTER TABLE `user` ADD `cntunkmail` INT NOT NULL DEFAULT '10' AFTER `unkmail` , ADD INDEX ( `cntunkmail` ) "); - q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `replied` , ADD INDEX ( `unknown` ) "); +q("ALTER TABLE `user` ADD `unkmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocktags` , ADD INDEX ( `unkmail` ) "); +q("ALTER TABLE `user` ADD `cntunkmail` INT NOT NULL DEFAULT '10' AFTER `unkmail` , ADD INDEX ( `cntunkmail` ) "); +q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `replied` , ADD INDEX ( `unknown` ) "); } function update_1134() { @@ -1180,38 +1168,38 @@ function update_1136() { // order in reverse so that we save the newest entry - $r = q("SELECT * FROM `config` WHERE 1 ORDER BY `id` DESC"); + $r = q("select * from config where 1 order by id desc"); if (dbm::is_result($r)) { foreach ($r as $rr) { $found = false; - foreach ($arr as $x) { - if ($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { + foreach($arr as $x) { + if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { $found = true; - q("DELETE FROM `config` WHERE `id` = %d", + q("delete from config where id = %d", intval($rr['id']) ); } } - if (! $found) { + if(! $found) { $arr[] = $rr; } } } $arr = array(); - $r = q("SELECT * FROM `pconfig` WHERE 1 ORDER BY `id` DESC"); + $r = q("select * from pconfig where 1 order by id desc"); if (dbm::is_result($r)) { foreach ($r as $rr) { $found = false; - foreach ($arr as $x) { - if ($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { + foreach($arr as $x) { + if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { $found = true; - q("DELETE FROM `pconfig` WHERE `id` = %d", + q("delete from pconfig where id = %d", intval($rr['id']) ); } } - if (! $found) { + if(! $found) { $arr[] = $rr; } } @@ -1223,153 +1211,114 @@ function update_1136() { function update_1137() { - q("ALTER TABLE `item_id` DROP `face` , DROP `dspr` , DROP `twit` , DROP `stat` "); - q("ALTER TABLE `item_id` ADD `sid` CHAR( 255 ) NOT NULL AFTER `uid` , ADD `service` CHAR( 255 ) NOT NULL AFTER `sid` , ADD INDEX (`sid`), ADD INDEX ( `service`) "); + q("alter table item_id DROP `face` , DROP `dspr` , DROP `twit` , DROP `stat` "); + q("ALTER TABLE `item_id` ADD `sid` CHAR( 255 ) NOT NULL AFTER `uid` , ADD `service` CHAR( 255 ) NOT NULL AFTER `sid` , add index (`sid`), add index ( `service`) "); } function update_1138() { - q("ALTER TABLE `contact` ADD `archive` TINYINT(1) NOT NULL DEFAULT '0' AFTER `hidden`, ADD INDEX (`archive`)"); + q("alter table contact add archive tinyint(1) not null default '0' after hidden, add index (archive)"); } function update_1139() { - $r = q("ALTER TABLE `user` ADD `account_removed` TINYINT(1) NOT NULL DEFAULT '0' AFTER `expire`, ADD INDEX(`account_removed`)"); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table user add account_removed tinyint(1) not null default '0' after expire, add index(account_removed) "); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1140() { - $r = q("ALTER TABLE `addon` ADD `hidden` TINYINT(1) NOT NULL DEFAULT '0' AFTER `installed`, ADD INDEX(`hidden`) "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table addon add hidden tinyint(1) not null default '0' after installed, add index(hidden) "); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1141() { - $r = q("ALTER TABLE `glink` ADD `zcid` INT(11) NOT NULL AFTER `gcid`, ADD INDEX(`zcid`) "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table glink add zcid int(11) not null after gcid, add index(zcid) "); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1142() { - $r = q("ALTER TABLE `user` ADD `service_class` CHAR(32) NOT NULL AFTER `expire_notification_sent`, ADD INDEX(`service_class`) "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table user add service_class char(32) not null after expire_notification_sent, add index(service_class) "); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1143() { - $r = q("ALTER TABLE `user` ADD `def_gid` INT(11) NOT NULL DEFAULT '0' AFTER `service_class`"); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table user add def_gid int(11) not null default '0' after service_class"); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1144() { - $r = q("ALTER TABLE `contact` ADD `prv` TINYINT(1) NOT NULL DEFAULT '0' AFTER `forum`"); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table contact add prv tinyint(1) not null default '0' after forum"); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1145() { - $r = q("ALTER TABLE `profile` ADD `howlong` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `with`"); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table profile add howlong datetime not null default '0001-01-01 00:00:00' after `with`"); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1146() { - $r = q("ALTER TABLE `profile` ADD `hometown` CHAR(255) NOT NULL AFTER `country-name`, ADD INDEX ( `hometown` ) "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("alter table profile add hometown char(255) not null after `country-name`, add index ( `hometown` ) "); + if(! $r) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1147() { $r1 = q("ALTER TABLE `sign` ALTER `iid` SET DEFAULT '0'"); $r2 = q("ALTER TABLE `sign` ADD `retract_iid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `iid`"); $r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )"); - - if ($r1 && $r2 && $r3) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + if((! $r1) || (! $r2) || (! $r3)) + return UPDATE_FAILED ; + return UPDATE_SUCCESS ; } function update_1148() { - $r = q("ALTER TABLE `photo` ADD `type` CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER `filename`"); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("ALTER TABLE photo ADD type CHAR(128) NOT NULL DEFAULT 'image/jpeg' AFTER filename"); + if (!$r) + return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1149() { - $r1 = q("ALTER TABLE `profile` ADD `likes` TEXT NOT NULL AFTER `prv_keywords`"); - $r2 = q("ALTER TABLE `profile` ADD `dislikes` TEXT NOT NULL AFTER `likes`"); - - if ($r1 && $r2) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + $r1 = q("ALTER TABLE profile ADD likes text NOT NULL after prv_keywords"); + $r2 = q("ALTER TABLE profile ADD dislikes text NOT NULL after likes"); + if (! ($r1 && $r2)) + return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1150() { - $r = q("ALTER TABLE `event` ADD `summary` TEXT NOT NULL AFTER `finish`, ADD INDEX ( `uid` ), ADD INDEX ( `cid` ), ADD INDEX ( `uri` ), ADD INDEX ( `start` ), ADD INDEX ( `finish` ), ADD INDEX ( `type` ), ADD INDEX ( `adjust` ) "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + $r = q("ALTER TABLE event ADD summary text NOT NULL after finish, add index ( uid ), add index ( cid ), add index ( uri ), add index ( `start` ), add index ( finish ), add index ( `type` ), add index ( adjust ) "); + if(! $r) + return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1151() { - $r = q("CREATE TABLE IF NOT EXISTS `locks` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `name` CHAR( 128 ) NOT NULL , - `locked` TINYINT( 1 ) NOT NULL DEFAULT '0' + $r = q("CREATE TABLE IF NOT EXISTS locks ( + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , + name CHAR( 128 ) NOT NULL , + locked TINYINT( 1 ) NOT NULL DEFAULT '0' ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); - - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + if (!$r) + return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1152() { @@ -1385,32 +1334,23 @@ function update_1152() { KEY `type` ( `type` ), KEY `term` ( `term` ) ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); - - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + if (!$r) + return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1153() { $r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'"); - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + if(!$r) return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1154() { $r = q("ALTER TABLE `event` ADD `ignore` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `adjust` , ADD INDEX ( `ignore` )"); - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + if(!$r) return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1155() { @@ -1418,9 +1358,8 @@ function update_1155() { $r2 = q("ALTER TABLE `item_id` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); $r3 = q("ALTER TABLE `item_id` ADD INDEX ( `iid` ) "); - if ($r1 && $r2 && $r3) { + if($r1 && $r2 && $r3) return UPDATE_SUCCESS; - } return UPDATE_FAILED; } @@ -1429,15 +1368,12 @@ function update_1156() { $r = q("ALTER TABLE `photo` ADD `datasize` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `width` , ADD INDEX ( `datasize` ) "); - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + if(!$r) return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1157() { - $r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` ( + $r = q("CREATE TABLE IF NOT EXISTS `dsprphotoq` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, `msg` mediumtext NOT NULL, @@ -1446,11 +1382,8 @@ function update_1157() { ) ENGINE=MyISAM DEFAULT CHARSET=utf8" ); - if ($r) { + if($r) return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; } function update_1158() { @@ -1463,9 +1396,8 @@ function update_1158() { $r = q("CREATE INDEX event_id ON item(`event-id`)"); set_config('system', 'maintenance', 0); - if ($r) { + if($r) return UPDATE_SUCCESS; - } return UPDATE_FAILED; } @@ -1476,11 +1408,10 @@ function update_1159() { ADD INDEX (`uid`), ADD INDEX (`aid`)"); - if ($r) { - return UPDATE_SUCCESS; - } + if(!$r) + return UPDATE_FAILED; - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1160() { @@ -1493,21 +1424,19 @@ function update_1160() { $r = q("ALTER TABLE `item` ADD `mention` TINYINT(1) NOT NULL DEFAULT '0', ADD INDEX (`mention`)"); set_config('system', 'maintenance', 0); - if ($r) { - return UPDATE_SUCCESS; - } + if(!$r) + return UPDATE_FAILED; - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1161() { $r = q("ALTER TABLE `pconfig` ADD INDEX (`cat`)"); - if ($r) { - return UPDATE_SUCCESS; - } + if(!$r) + return UPDATE_FAILED; - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1162() { @@ -1523,17 +1452,14 @@ function update_1163() { $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL"); set_config('system', 'maintenance', 0); + if(!$r) + return UPDATE_FAILED; - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1164() { set_config('system', 'maintenance', 1); - /// @TODO If one update fails, should it continue? $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '' AND `contact`.`uid` = `item`.`uid`)", NETWORK_DFRN); @@ -1586,21 +1512,19 @@ function update_1164() { function update_1165() { $r = q("CREATE TABLE IF NOT EXISTS `push_subscriber` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `uid` INT NOT NULL, - `callback_url` CHAR( 255 ) NOT NULL, - `topic` CHAR( 255 ) NOT NULL, - `nickname` CHAR( 255 ) NOT NULL, - `push` INT NOT NULL, - `last_update` DATETIME NOT NULL, - `secret` CHAR( 255 ) NOT NULL - ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); - - if ($r) { - return UPDATE_SUCCESS; - } + `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `uid` INT NOT NULL, + `callback_url` CHAR( 255 ) NOT NULL, + `topic` CHAR( 255 ) NOT NULL, + `nickname` CHAR( 255 ) NOT NULL, + `push` INT NOT NULL, + `last_update` DATETIME NOT NULL, + `secret` CHAR( 255 ) NOT NULL + ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); + if (!$r) + return UPDATE_FAILED; - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1166() { @@ -1612,32 +1536,26 @@ function update_1166() { `avatar` CHAR(255) NOT NULL, INDEX (`url`) ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); + if (!$r) + return UPDATE_FAILED; - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1167() { $r = q("ALTER TABLE `contact` ADD `notify_new_posts` TINYINT(1) NOT NULL DEFAULT '0'"); + if (!$r) + return UPDATE_FAILED; - if ($r) { - return UPDATE_SUCCESS; - } - - return UPDATE_FAILED; + return UPDATE_SUCCESS; } function update_1168() { $r = q("ALTER TABLE `contact` ADD `fetch_further_information` TINYINT(1) NOT NULL DEFAULT '0'"); + if (!$r) + return UPDATE_FAILED; - if ($r) { - return UPDATE_SUCCESS ; - } - - return UPDATE_FAILED ; + return UPDATE_SUCCESS; } function update_1169() { @@ -1645,11 +1563,11 @@ function update_1169() { `iid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0', `contact-id` int(11) unsigned NOT NULL DEFAULT '0', - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `wall` tinyint(1) NOT NULL DEFAULT '0', `private` tinyint(1) NOT NULL DEFAULT '0', `pubmail` tinyint(1) NOT NULL DEFAULT '0', @@ -1675,10 +1593,8 @@ function update_1169() { KEY `uid_created` (`uid`,`created`), KEY `uid_commented` (`uid`,`commented`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - - if (!$r) { + if (!$r) return UPDATE_FAILED; - } proc_run(PRIORITY_LOW, "include/threadupdate.php"); @@ -1756,7 +1672,7 @@ function update_1190() { $plugins = get_config('system','addon'); $plugins_arr = array(); - if($plugins) { + if ($plugins) { $plugins_arr = explode(",",str_replace(" ", "",$plugins)); $idx = array_search($plugin, $plugins_arr); @@ -1784,22 +1700,19 @@ function update_1190() { $key = $rr['k']; $value = $rr['v']; - if ($key === 'randomise') { + if ($key === 'randomise') del_pconfig($uid,$family,$key); - } if ($key === 'show_on_profile') { - if ($value) { + if ($value) set_pconfig($uid,feature,forumlist_profile,$value); - } del_pconfig($uid,$family,$key); } if ($key === 'show_on_network') { - if ($value) { + if ($value) set_pconfig($uid,feature,forumlist_widget,$value); - } del_pconfig($uid,$family,$key); }