From 4b0506879a29e4d2bd966aced2a14625592fd079 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 3 Apr 2016 16:36:05 +0200 Subject: [PATCH] Post update ist now done. --- boot.php | 2 +- include/dbstructure.php | 1 - include/items.php | 4 ++-- include/post_update.php | 40 ++++++++++++++++++++++++++-------------- mod/search.php | 5 ++--- update.php | 2 +- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/boot.php b/boot.php index 108d8d0ed..3ed88422e 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1195 ); +define ( 'DB_UPDATE_VERSION', 1194 ); /** * @brief Constant with a HTML line break. diff --git a/include/dbstructure.php b/include/dbstructure.php index 33e0c7dc8..e34e40902 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -783,7 +783,6 @@ function db_definition() { "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), - "shadow" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), diff --git a/include/items.php b/include/items.php index 233d72d13..4627b10ca 100644 --- a/include/items.php +++ b/include/items.php @@ -707,9 +707,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa if ($arr["uid"] == 0) { $arr["global"] = true; - q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($arr["guid"])); + q("UPDATE `item` SET `global` = 1 WHERE `uri` = '%s'", dbesc($arr["uri"])); } else { - $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `guid` = '%s'", dbesc($arr["guid"])); + $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"])); $arr["global"] = (count($isglobal) > 0); } diff --git a/include/post_update.php b/include/post_update.php index 2143ac3d6..2bdfe1f6f 100644 --- a/include/post_update.php +++ b/include/post_update.php @@ -1,4 +1,8 @@ = 1195) + if (get_config("system", "post_update_version") >= 1194) return true; - $end_id = get_config("system", "post_update_1195_end"); + logger("Start", LOGGER_DEBUG); + + $end_id = get_config("system", "post_update_1194_end"); if (!$end_id) { $r = q("SELECT `id` FROM `item` WHERE `uid` != 0 ORDER BY `id` DESC LIMIT 1"); if ($r) { - set_config("system", "post_update_1195_end", $r[0]["id"]); - $end_id = get_config("system", "post_update_1195_end"); + set_config("system", "post_update_1194_end", $r[0]["id"]); + $end_id = get_config("system", "post_update_1194_end"); } } - $start_id = get_config("system", "post_update_1195_start"); + logger("End ID: ".$end_id, LOGGER_DEBUG); + + $start_id = get_config("system", "post_update_1194_start"); $query1 = "SELECT `item`.`id` FROM `item` "; @@ -98,21 +106,23 @@ function post_update_1195() { AND `item`.`network` IN ('%s', '%s', '%s', '') AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' - AND `item`.`shadow` = 0"; + AND NOT `item`.`global`"; $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1", intval($start_id), intval($end_id), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if (!$r) { - set_config("system", "post_update_version", 1195); + set_config("system", "post_update_version", 1194); + logger("Update is done", LOGGER_DEBUG); return true; } else { - set_config("system", "post_update_1195_start", $r[0]["id"]); - $start_id = get_config("system", "post_update_1195_start"); + set_config("system", "post_update_1194_start", $r[0]["id"]); + $start_id = get_config("system", "post_update_1194_start"); } + logger("Start ID: ".$start_id, LOGGER_DEBUG); - $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 10000,1", + $r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1", intval($start_id), intval($end_id), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if ($r) @@ -122,8 +132,10 @@ function post_update_1195() { logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG); - $r = q("UPDATE `item` ".$query2." SET `item`.`shadow` = `shadow`.`id` ".$query3, + $r = q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3, intval($start_id), intval($pos_id), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); + + logger("Done", LOGGER_DEBUG); } ?> diff --git a/mod/search.php b/mod/search.php index 1776a9255..790f577ba 100644 --- a/mod/search.php +++ b/mod/search.php @@ -217,11 +217,10 @@ function search_content(&$a) { FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` - AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND (`item`.`private` OR NOT `item`.`network` IN ('%s', '%s', '%s')))) + AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`)) $sql_extra GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d ", - intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), - intval($a->pager['start']), intval($a->pager['itemspage'])); + intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage'])); } if(! count($r)) { diff --git a/update.php b/update.php index dad94f271..0689aa19b 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@