From 8700d2a8ad2412525523acdd970cd1724dab1193 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Mar 2018 13:09:21 +0000 Subject: [PATCH 1/3] Avoid storing "null" values --- src/Protocol/DFRN.php | 4 ++-- src/Protocol/PortableContact.php | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 5e7cc02a36..2d48fa602a 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2079,8 +2079,8 @@ class DFRN return false; } - $fields = ['title' => $item["title"], 'body' => $item["body"], - 'tag' => $item["tag"], 'changed' => DateTimeFormat::utcNow(), + $fields = ['title' => defaults($item["title"], ''), 'body' => defaults($item["body"], ''), + 'tag' => defaults($item["tag"], ''), 'changed' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utc($item["edited"])]; $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]]; diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 5b419e42ef..76413f58b8 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -1355,11 +1355,12 @@ class PortableContact $info = strip_tags($info); $platform = strip_tags($platform); - $fields = ['url' => $server_url, 'version' => $version, - 'site_name' => $site_name, 'info' => $info, 'register_policy' => $register_policy, - 'poco' => $poco, 'noscrape' => $noscrape, 'network' => $network, - 'platform' => $platform, 'registered-users' => $registered_users, - 'last_contact' => $last_contact, 'last_failure' => $last_failure]; + $fields = ['url' => $server_url, 'version' => defaults($version, ''), + 'site_name' => defaults($site_name, ''), 'info' => defaults($info, ''), + 'register_policy' => defaults($register_policy, 0), 'poco' => defaults($poco, ''), + 'noscrape' => defaults($noscrape, ''), 'network' => defaults($network, ''), + 'platform' => defaults($platform, ''), 'registered-users' => defaults($registered_users, 0), + 'last_contact' => defaults($last_contact, ''), 'last_failure' => defaults($last_failure, '')]; if ($found) { dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]); From c42c121e517a7925439a33006f1e355a0f1dc9cc Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Mar 2018 20:54:56 +0000 Subject: [PATCH 2/3] Fewer Defaults --- src/Protocol/PortableContact.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 76413f58b8..d10c4db320 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -1302,7 +1302,7 @@ class PortableContact if (isset($data->version)) { $network = NETWORK_DFRN; - $noscrape = $data->no_scrape_url; + $noscrape = defaults($data->no_scrape_url, ''); $version = $data->version; $site_name = $data->site_name; $info = $data->info; @@ -1355,12 +1355,11 @@ class PortableContact $info = strip_tags($info); $platform = strip_tags($platform); - $fields = ['url' => $server_url, 'version' => defaults($version, ''), - 'site_name' => defaults($site_name, ''), 'info' => defaults($info, ''), - 'register_policy' => defaults($register_policy, 0), 'poco' => defaults($poco, ''), - 'noscrape' => defaults($noscrape, ''), 'network' => defaults($network, ''), - 'platform' => defaults($platform, ''), 'registered-users' => defaults($registered_users, 0), - 'last_contact' => defaults($last_contact, ''), 'last_failure' => defaults($last_failure, '')]; + $fields = ['url' => $server_url, 'version' => $version, + 'site_name' => $site_name, 'info' => $info, 'register_policy' => $register_policy, + 'poco' => $poco, 'noscrape' => $noscrape, 'network' => $network, + 'platform' => $platform, 'registered-users' => $registered_users, + 'last_contact' => $last_contact, 'last_failure' => $last_failure]; if ($found) { dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]); From 9930c612634e3b95da98ecc783ac5d223cf22d07 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 17 Mar 2018 20:56:56 +0000 Subject: [PATCH 3/3] Same same but different --- src/Protocol/DFRN.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 2d48fa602a..2aa672ef6d 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2079,8 +2079,8 @@ class DFRN return false; } - $fields = ['title' => defaults($item["title"], ''), 'body' => defaults($item["body"], ''), - 'tag' => defaults($item["tag"], ''), 'changed' => DateTimeFormat::utcNow(), + $fields = ['title' => defaults($item, 'title', ''), 'body' => defaults($item, 'body', ''), + 'tag' => defaults($item, 'tag', ''), 'changed' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utc($item["edited"])]; $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];