From 35da40c2cb57b443e96f27a5c19090d86d8719d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 Oct 2018 03:01:34 +0000 Subject: [PATCH 1/2] Avoid endless loop when trying to fetch contact id --- src/Model/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 4588bb7129..24e9be0424 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1138,7 +1138,7 @@ class Contact extends BaseObject } } - if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url)) { + if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url) && !$no_update) { $contact_id = self::getIdForURL($data["alias"], $uid, true); } From 92816dc7258d47df6bff3c1575af08aa5708454b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 Oct 2018 03:33:08 +0000 Subject: [PATCH 2/2] Improved loop detection --- src/Model/Contact.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 24e9be0424..472875a80b 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1021,10 +1021,11 @@ class Contact extends BaseObject * @param integer $uid The user id for the contact (0 = public contact) * @param boolean $no_update Don't update the contact * @param array $default Default value for creating the contact when every else fails + * @param boolean $in_loop Internally used variable to prevent an endless loop * * @return integer Contact ID */ - public static function getIdForURL($url, $uid = 0, $no_update = false, $default = []) + public static function getIdForURL($url, $uid = 0, $no_update = false, $default = [], $in_loop = false) { logger("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG); @@ -1138,8 +1139,8 @@ class Contact extends BaseObject } } - if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url) && !$no_update) { - $contact_id = self::getIdForURL($data["alias"], $uid, true); + if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url) && !$in_loop) { + $contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true); } $url = $data["url"];