From: Hypolite Petovan <hypolite@mrpetovan.com>
Date: Sat, 21 Jan 2023 03:09:51 +0000 (-0500)
Subject: Apply changes to user-contact table first in Contact::update
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5519b50900b2c3341afe01d833c6677de29b0f92;p=friendica.git

Apply changes to user-contact table first in Contact::update

- The truncateFieldsForTable call in the same method was potentially restricting the fields that could be updated in the user-contact table
---

diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index e847ce0346..0f953a0b33 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -243,15 +243,13 @@ class Contact
 	 * @throws \Exception
 	 * @todo Let's get rid of boolean type of $old_fields
 	 */
-	public static function update(array $fields, array $condition, $old_fields = [])
+	public static function update(array $fields, array $condition, $old_fields = []): bool
 	{
-		$fields = DI::dbaDefinition()->truncateFieldsForTable('contact', $fields);
-		$ret = DBA::update('contact', $fields, $condition, $old_fields);
-
 		// Apply changes to the "user-contact" table on dedicated fields
 		Contact\User::updateByContactUpdate($fields, $condition);
 
-		return $ret;
+		$fields = DI::dbaDefinition()->truncateFieldsForTable('contact', $fields);
+		return DBA::update('contact', $fields, $condition, $old_fields);
 	}
 
 	/**