]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Merge branch 'develop' into utf8mb4
[friendica.git] / update.php
index 8f581559d9c199c97189281849084ac0d6000f5f..ea0c57535349b902995ff7f186d93db9b8d6e9b6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1215);
+define('UPDATE_VERSION' , 1219);
 
 /**
  *
@@ -37,7 +37,7 @@ define('UPDATE_VERSION' , 1215);
  */
 
 
-/// @TODO These old updates need to have UPDATE_SUCCESS returned on success?
+
 function update_1000() {
 
        q("ALTER TABLE `item` DROP `like`, DROP `dislike` ");
@@ -48,8 +48,8 @@ function update_1000() {
 
        q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` ");
        q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` ");
-       q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
-       q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`");
+       q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXTCHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
+       q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `avatar-date`");
 }
 
 function update_1001() {
@@ -148,7 +148,7 @@ function update_1014() {
        if (dbm::is_result($r)) {
                foreach ($r as $rr) {
                        $ph = new Photo($rr['data']);
-                       if($ph->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));
                        }
@@ -242,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() {
@@ -310,7 +310,7 @@ function update_1031() {
        $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
        if (dbm::is_result($r)) {
                foreach ($r as $rr) {
-                       if(strstr($rr['object'],'type=&quot;http')) {
+                       if (strstr($rr['object'],'type=&quot;http')) {
                                q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
                                        dbesc(str_replace('type=&quot;http','href=&quot;http',$rr['object'])),
                                        intval($rr['id'])
@@ -326,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");
 
 }
@@ -349,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` ");
 
 }
 
@@ -368,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() {
@@ -441,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 ");
 }
 
@@ -452,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 ,
@@ -529,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");
 }
@@ -595,7 +596,7 @@ 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'])
                        );
@@ -614,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",
@@ -674,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() {
@@ -685,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'])
                        );
@@ -734,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)) {
@@ -742,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() {
@@ -857,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'])
                        );
@@ -894,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` ) ");
@@ -941,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` ) ");
 }
@@ -1040,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`) ");
 
@@ -1078,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() {
@@ -1123,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() {
@@ -1149,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() {
@@ -1178,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;
                        }
                }
@@ -1221,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() {
@@ -1383,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() {
@@ -1416,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;
 }
@@ -1427,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,
@@ -1444,11 +1382,8 @@ function update_1157() {
          ) ENGINE=MyISAM DEFAULT CHARSET=utf8"
        );
 
-       if ($r) {
+       if($r)
                return UPDATE_SUCCESS;
-       }
-
-       return UPDATE_FAILED;
 }
 
 function update_1158() {
@@ -1461,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;
 }
@@ -1474,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() {
@@ -1491,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() {
@@ -1521,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);
 
@@ -1584,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() {
@@ -1610,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() {
@@ -1643,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',
@@ -1673,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");
 
@@ -1754,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);