From a38a5019d05e95add3375c52f8f509b99e92cd72 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Nov 2016 21:44:04 +0000 Subject: [PATCH 1/3] Issue 2518: Remove contact data in the background --- include/Contact.php | 22 +++------------- include/remove_contact.php | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 include/remove_contact.php diff --git a/include/Contact.php b/include/Contact.php index 949feb3564..d0f4023447 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -22,6 +22,7 @@ function user_remove($uid) { $r[0]['nickname'] ); + /// @todo Should be done in a background job since this likely will run into a time out // don't delete yet, will be done later when contacts have deleted my stuff // q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `gcign` WHERE `uid` = %d", intval($uid)); @@ -74,25 +75,10 @@ function contact_remove($id) { return; } - q("DELETE FROM `contact` WHERE `id` = %d", - intval($id) - ); - q("DELETE FROM `item` WHERE `contact-id` = %d ", - intval($id) - ); - q("DELETE FROM `photo` WHERE `contact-id` = %d ", - intval($id) - ); - q("DELETE FROM `mail` WHERE `contact-id` = %d ", - intval($id) - ); - q("DELETE FROM `event` WHERE `cid` = %d ", - intval($id) - ); - q("DELETE FROM `queue` WHERE `cid` = %d ", - intval($id) - ); + q("DELETE FROM `contact` WHERE `id` = %d", intval($id)); + // Delete the rest in the background + proc_run(PRIORITY_LOW, 'include/remove_contact.php', $id); } diff --git a/include/remove_contact.php b/include/remove_contact.php new file mode 100644 index 0000000000..153b98805a --- /dev/null +++ b/include/remove_contact.php @@ -0,0 +1,52 @@ + From e7ef34298a47ce5a8d7b85f93aa138662e3dc146 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Nov 2016 21:48:06 +0000 Subject: [PATCH 2/3] remove "blubb" --- include/remove_contact.php | 1 - 1 file changed, 1 deletion(-) diff --git a/include/remove_contact.php b/include/remove_contact.php index 153b98805a..dcf917322b 100644 --- a/include/remove_contact.php +++ b/include/remove_contact.php @@ -33,7 +33,6 @@ function remove_contact_run($argv, $argc) { return; } -die("Blubb ".$id); q("DELETE FROM `item` WHERE `contact-id` = %d", intval($id)); q("DELETE FROM `photo` WHERE `contact-id` = %d", intval($id)); From eede89f53792bdebbddd6cb95ef558ced68afee2 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 28 Nov 2016 22:18:37 +0000 Subject: [PATCH 3/3] Some brackets added --- include/remove_contact.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/remove_contact.php b/include/remove_contact.php index dcf917322b..ec8b83eab9 100644 --- a/include/remove_contact.php +++ b/include/remove_contact.php @@ -8,8 +8,9 @@ require_once("boot.php"); function remove_contact_run($argv, $argc) { global $a, $db; - if (is_null($a)) + if (is_null($a)) { $a = new App; + } if (is_null($db)) { @include(".htconfig.php");