From 7db0b850cb80af8a60768fb7f78f15acd5c5635d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 14 Mar 2018 19:47:14 +0000 Subject: [PATCH 1/2] Avoid an error in OnePoll when the contact was "null". --- src/Worker/OnePoll.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 42b0d9f8c..6475cc82b 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -582,11 +582,15 @@ class OnePoll logger("Consume feed of contact ".$contact['id']); - consume_feed($xml, $importer, $contact, $hub, 1, 1); + // Use a copy of the contact to avoid problems. + // The contact parameter is called by reference. + $contact2 = $contact; + consume_feed($xml, $importer, $contact2, $hub, 1, 1); // do it twice. Ensures that children of parents which may be later in the stream aren't tossed - consume_feed($xml, $importer, $contact, $hub, 1, 2); + $contact2 = $contact; + consume_feed($xml, $importer, $contact2, $hub, 1, 2); $hubmode = 'subscribe'; if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly']) { From d98c6819e7f8f9e028ac7b9c3a875a569ce7e8ee Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 14 Mar 2018 20:53:03 +0000 Subject: [PATCH 2/2] $contact isn't called by reference anymore --- include/items.php | 2 +- src/Worker/OnePoll.php | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/items.php b/include/items.php index 31c8aaa79..b46e0d6a6 100644 --- a/include/items.php +++ b/include/items.php @@ -228,7 +228,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) { * * @TODO find proper type-hints */ -function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0) { +function consume_feed($xml, $importer, $contact, &$hub, $datedir = 0, $pass = 0) { if ($contact['network'] === NETWORK_OSTATUS) { if ($pass < 2) { // Test - remove before flight diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 6475cc82b..c1c6fdd1a 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -582,15 +582,12 @@ class OnePoll logger("Consume feed of contact ".$contact['id']); - // Use a copy of the contact to avoid problems. - // The contact parameter is called by reference. - $contact2 = $contact; - consume_feed($xml, $importer, $contact2, $hub, 1, 1); + consume_feed($xml, $importer, $contact, $hub); - // do it twice. Ensures that children of parents which may be later in the stream aren't tossed - - $contact2 = $contact; - consume_feed($xml, $importer, $contact2, $hub, 1, 2); + // do it a second time for DFRN so that any children find their parents. + if ($contact['network'] === NETWORK_DFRN) { + consume_feed($xml, $importer, $contact, $hub); + } $hubmode = 'subscribe'; if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly']) {