]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Merge branch 'develop' into task/admin-block-list
[friendica.git] / update.php
index 76620a48a4629eb4b26ac5169798714bac0064b1..ba0867d3a8ca3cfd7c423c25c4486b2df41ecbcd 100644 (file)
@@ -1,6 +1,12 @@
 <?php
 
-define('UPDATE_VERSION' , 1228);
+define('UPDATE_VERSION' , 1235);
+
+use Friendica\Core\Config;
+use Friendica\Core\PConfig;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Object\Photo;
 
 /**
  *
@@ -85,7 +91,7 @@ function update_1006() {
        // create 's' keys for everybody that does not have one
 
        $r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $sres=openssl_pkey_new(array('encrypt_key' => false ));
                        $sprvkey = '';
@@ -122,7 +128,7 @@ function update_1010() {
 function update_1011() {
        q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
        $r = q("SELECT * FROM `contact` WHERE 1");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                                q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
                                        dbesc(basename($rr['url'])),
@@ -141,21 +147,21 @@ function update_1013() {
                AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`");
 }
 
-function update_1014() {
-       require_once('include/Photo.php');
+function update_1014()
+{
        q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
        $r = q("SELECT * FROM `photo` WHERE `scale` = 4");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $ph = new Photo($rr['data']);
-                       if ($ph->is_valid()) {
+                       if ($ph->isValid()) {
                                $ph->scaleImage(48);
                                $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
                        }
                }
        }
        $r = q("SELECT * FROM `contact` WHERE 1");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        if(stristr($rr['thumb'],'avatar'))
                                q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
@@ -308,7 +314,7 @@ function update_1030() {
 function update_1031() {
        // Repair any bad links that slipped into the item table
        $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        if (strstr($rr['object'],'type=&quot;http')) {
                                q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
@@ -356,8 +362,8 @@ function update_1035() {
 
 function update_1036() {
 
-       $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
-       if (dbm::is_result($r)) {
+       $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' AND `photo` LIKE '%include/photo%' ");
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
                                dbesc(str_replace('include/photo','photo',$rr['photo'])),
@@ -595,7 +601,7 @@ function update_1073() {
 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)) {
+       if (DBM::is_result($r)) {
                foreach($r as $rr)
                        q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
                                intval($rr['uid'])
@@ -607,11 +613,11 @@ function update_1074() {
 function update_1075() {
        q("ALTER TABLE `user` ADD `guid` CHAR( 16 ) NOT NULL AFTER `uid` ");
        $r = q("SELECT `uid` FROM `user` WHERE 1");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $found = true;
                        do {
-                               $guid = substr(random_string(),0,16);
+                               $guid = random_string(16);
                                $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
                                        dbesc($guid)
                                );
@@ -686,10 +692,10 @@ function update_1082() {
                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))
+       if (DBM::is_result($r))
                return;
        $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $guid = get_guid();
                        q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
@@ -732,7 +738,7 @@ function update_1087() {
        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)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $x = q("SELECT max(`created`) AS `cdate` FROM `item` WHERE `parent` = %d LIMIT 1",
                                intval($rr['id'])
@@ -855,7 +861,7 @@ function update_1100() {
        require_once('include/text.php');
 
        $r = q("select id, url from contact where url != '' and nurl = '' ");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        q("update contact set nurl = '%s' where id = %d",
                                dbesc(normalise_link($rr['url'])),
@@ -1031,7 +1037,7 @@ function update_1120() {
        // might be missing on new installs. We'll check.
 
        $r = q("describe item");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach($r as $rr)
                        if($rr['Field'] == 'spam')
                                return;
@@ -1073,7 +1079,7 @@ ADD INDEX ( `hash` ) ");
 }
 
 function update_1123() {
-set_config('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr');
+Config::set('system','allowed_themes','dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr');
 }
 
 function update_1124() {
@@ -1169,7 +1175,7 @@ function update_1136() {
        // order in reverse so that we save the newest entry
 
        $r = q("select * from config where 1 order by id desc");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
@@ -1188,7 +1194,7 @@ function update_1136() {
 
        $arr = array();
        $r = q("select * from pconfig where 1 order by id desc");
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $found = false;
                        foreach($arr as $x) {
@@ -1387,14 +1393,14 @@ function update_1157() {
 }
 
 function update_1158() {
-       set_config('system', 'maintenance', 1);
+       Config::set('system', 'maintenance', 1);
 
        // Wait for 15 seconds for current requests to
        // clear before locking up the database
        sleep(15);
 
        $r = q("CREATE INDEX event_id ON item(`event-id`)");
-       set_config('system', 'maintenance', 0);
+       Config::set('system', 'maintenance', 0);
 
        if($r)
                return UPDATE_SUCCESS;
@@ -1415,14 +1421,14 @@ function update_1159() {
 }
 
 function update_1160() {
-       set_config('system', 'maintenance', 1);
+       Config::set('system', 'maintenance', 1);
 
        // Wait for 15 seconds for current requests to
        // clear before locking up the database
        sleep(15);
 
        $r = q("ALTER TABLE `item` ADD `mention` TINYINT(1) NOT NULL DEFAULT '0', ADD INDEX (`mention`)");
-       set_config('system', 'maintenance', 0);
+       Config::set('system', 'maintenance', 0);
 
        if(!$r)
                return UPDATE_FAILED;
@@ -1447,18 +1453,18 @@ function update_1162() {
 }
 
 function update_1163() {
-       set_config('system', 'maintenance', 1);
+       Config::set('system', 'maintenance', 1);
 
        $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL");
 
-       set_config('system', 'maintenance', 0);
+       Config::set('system', 'maintenance', 0);
        if(!$r)
                return UPDATE_FAILED;
 
        return UPDATE_SUCCESS;
 }
 function update_1164() {
-       set_config('system', 'maintenance', 1);
+       Config::set('system', 'maintenance', 1);
 
        $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '' AND `contact`.`uid` = `item`.`uid`)",
                NETWORK_DFRN);
@@ -1505,7 +1511,7 @@ function update_1164() {
        $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
                NETWORK_TWITTER, NETWORK_TWITTER);
 
-       set_config('system', 'maintenance', 0);
+       Config::set('system', 'maintenance', 0);
 
        return UPDATE_SUCCESS;
 }
@@ -1596,7 +1602,7 @@ function update_1169() {
        if (!$r)
                return UPDATE_FAILED;
 
-       proc_run(PRIORITY_LOW, "include/threadupdate.php");
+       Worker::add(PRIORITY_LOW, "ThreadUpdate");
 
        return UPDATE_SUCCESS;
 }
@@ -1633,11 +1639,11 @@ function update_1177() {
 }
 
 function update_1178() {
-       if (get_config('system','no_community_page'))
-               set_config('system','community_page_style', CP_NO_COMMUNITY_PAGE);
+       if (Config::get('system','no_community_page'))
+               Config::set('system','community_page_style', CP_NO_COMMUNITY_PAGE);
 
        // Update the central item storage with uid=0
-       proc_run(PRIORITY_LOW, "include/threadupdate.php");
+       Worker::add(PRIORITY_LOW, "threadupdate");
 
        return UPDATE_SUCCESS;
 }
@@ -1645,17 +1651,17 @@ function update_1178() {
 function update_1180() {
 
        // Fill the new fields in the term table.
-       proc_run(PRIORITY_LOW, "include/tagupdate.php");
+       Worker::add(PRIORITY_LOW, "TagUpdate");
 
        return UPDATE_SUCCESS;
 }
 
 function update_1188() {
 
-       if (strlen(get_config('system','directory_submit_url')) AND
-               !strlen(get_config('system','directory'))) {
-               set_config('system','directory', dirname(get_config('system','directory_submit_url')));
-               del_config('system','directory_submit_url');
+       if (strlen(Config::get('system','directory_submit_url')) &&
+               !strlen(Config::get('system','directory'))) {
+               Config::set('system','directory', dirname(Config::get('system','directory_submit_url')));
+               Config::delete('system','directory_submit_url');
        }
 
        return UPDATE_SUCCESS;
@@ -1665,11 +1671,11 @@ function update_1190() {
 
        require_once('include/plugin.php');
 
-       set_config('system', 'maintenance', 1);
+       Config::set('system', 'maintenance', 1);
 
        if (plugin_enabled('forumlist')) {
                $plugin = 'forumlist';
-               $plugins = get_config('system','addon');
+               $plugins = Config::get('system','addon');
                $plugins_arr = array();
 
                if ($plugins) {
@@ -1682,7 +1688,7 @@ function update_1190() {
                                // since uninstall_plugin() don't work here
                                q("DELETE FROM `addon` WHERE `name` = 'forumlist' ");
                                q("DELETE FROM `hook` WHERE `file` = 'addon/forumlist/forumlist.php' ");
-                               set_config('system','addon', implode(", ",$plugins_arr));
+                               Config::set('system','addon', implode(", ",$plugins_arr));
                        }
                }
        }
@@ -1693,7 +1699,7 @@ function update_1190() {
        );
 
        // convert old forumlist addon entries in new config entries
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                foreach ($r as $rr) {
                        $uid = $rr['uid'];
                        $family = $rr['cat'];
@@ -1701,25 +1707,25 @@ function update_1190() {
                        $value = $rr['v'];
 
                        if ($key === 'randomise')
-                               del_pconfig($uid,$family,$key);
+                               PConfig::delete($uid,$family,$key);
 
                        if ($key === 'show_on_profile') {
                                if ($value)
-                                       set_pconfig($uid,feature,forumlist_profile,$value);
+                                       PConfig::set($uid,feature,forumlist_profile,$value);
 
-                               del_pconfig($uid,$family,$key);
+                               PConfig::delete($uid,$family,$key);
                        }
 
                        if ($key === 'show_on_network') {
                                if ($value)
-                                       set_pconfig($uid,feature,forumlist_widget,$value);
+                                       PConfig::set($uid,feature,forumlist_widget,$value);
 
-                               del_pconfig($uid,$family,$key);
+                               PConfig::delete($uid,$family,$key);
                        }
                }
        }
 
-       set_config('system', 'maintenance', 0);
+       Config::set('system', 'maintenance', 0);
 
        return UPDATE_SUCCESS;