From df932f7fea35c4da66bfd3113a8ade1f05a483f8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 24 Jul 2024 20:32:32 +0200 Subject: [PATCH] FIX to avoid error during upgrade with pgsql (#30443) --- htdocs/core/modules/modSociete.class.php | 40 ++++++++++++++---------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index e4f34e432ec..39c02faec08 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -523,10 +523,12 @@ class modSociete extends DolibarrModules if (isModEnabled('socialnetworks')) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel; + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } } } // Add extra fields @@ -695,10 +697,12 @@ class modSociete extends DolibarrModules if (isModEnabled('socialnetworks')) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; + } } } // Add profids as criteria to search duplicates @@ -759,10 +763,12 @@ class modSociete extends DolibarrModules if (isModEnabled('socialnetworks')) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname] = $fieldlabel; + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel; + } } } // Add extra fields @@ -837,10 +843,12 @@ class modSociete extends DolibarrModules if (isModEnabled('socialnetworks')) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_socialnetworks WHERE active = 1"; $resql = $this->db->query($sql); - while ($obj = $this->db->fetch_object($resql)) { - $fieldname = 's.socialnetworks_'.$obj->code; - $fieldlabel = ucfirst($obj->label); - $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 's.socialnetworks_'.$obj->code; + $fieldlabel = ucfirst($obj->label); + $this->import_updatekeys_array[$r][$fieldname] = $fieldlabel; + } } }