<?php
-define('UPDATE_VERSION' , 1228);
+define('UPDATE_VERSION' , 1236);
+
+use Friendica\Core\Config;
+use Friendica\Core\PConfig;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Model\Photo;
+use Friendica\Object\Image;
/**
*
// 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 = '';
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'])),
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()) {
- $ph->scaleImage(48);
- $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
+ $Image = new Image($rr['data']);
+ if ($Image->isValid()) {
+ $Image->scaleDown(48);
+ Photo::store($Image, $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",
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="http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
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'])),
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'])
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)
);
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'",
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'])
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'])),
// 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;
}
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() {
// 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) {
$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) {
}
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;
}
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;
}
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);
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
NETWORK_DFRN, NETWORK_DFRN);
- $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
- NETWORK_ZOT, NETWORK_ZOT);
-
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
NETWORK_OSTATUS, NETWORK_OSTATUS);
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
NETWORK_MAIL, NETWORK_MAIL);
- $r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
- NETWORK_MAIL2, NETWORK_MAIL2);
-
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
NETWORK_FACEBOOK, NETWORK_FACEBOOK);
$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;
}
if (!$r)
return UPDATE_FAILED;
- proc_run(PRIORITY_LOW, "include/threadupdate.php");
+ Worker::add(PRIORITY_LOW, "ThreadUpdate");
return UPDATE_SUCCESS;
}
}
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;
}
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;
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) {
// 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));
}
}
}
);
// 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'];
$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;