From 926c9719e07f627f8d5139deeb0d26f8db55f449 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 11 May 2018 15:27:19 +0000 Subject: [PATCH] Avoid SQL error with empty "bd" field --- src/Protocol/Diaspora.php | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 08ce31528..e8cfbf511 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -2349,21 +2349,17 @@ class Diaspora $birthday = $contact["bd"]; } - $r = q( - "UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `bd` = '%s', - `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d", - dbesc($name), - dbesc($nick), - dbesc($author), - dbesc(DateTimeFormat::utcNow()), - dbesc($birthday), - dbesc($location), - dbesc($about), - dbesc($keywords), - dbesc($gender), - intval($contact["id"]), - intval($importer["uid"]) - ); + $fields = ['name' => $name, 'location' => $location, + 'name-date' => DateTimeFormat::utcNow(), + 'about' => $about, 'gender' => $gender, + 'addr' => $author, 'nick' => $nick, + 'keywords' => $keywords]; + + if (!empty($birthday)) { + $fields['bd'] = $birthday; + } + + dba::update('contact', $fields, ['id' => $contact['id']]); $gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2, "photo" => $image_url, "name" => $name, "location" => $location,