From 30ad2f1609fb5a07ac21cc191e53810da654bba0 Mon Sep 17 00:00:00 2001 From: fhenry Date: Fri, 26 Apr 2013 10:51:17 +0200 Subject: [PATCH] Fix bug in fetch_optionals --- htdocs/core/class/commonobject.class.php | 5 ++++- htdocs/core/class/extrafields.class.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3dd183a5b13..7aac8234b5f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2023,6 +2023,7 @@ abstract class CommonObject $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); } + // Request to get complementary values if (count($optionsArray) > 0) { @@ -2044,13 +2045,15 @@ abstract class CommonObject foreach ($tab as $key => $value) { - if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member') + //Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) + if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { // we can add this attribute to adherent object $this->array_options["options_$key"]=$value; } } } + $this->db->free($resql); } else diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 6f82520c230..17226e7d461 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -543,7 +543,6 @@ class ExtraFields { while ($tab = $this->db->fetch_object($resql)) { - // we can add this attribute to adherent object if ($tab->type != 'separate') { @@ -560,6 +559,7 @@ class ExtraFields $this->attribute_pos[$tab->name]=$tab->pos; } } + return $array_name_label; } else @@ -882,7 +882,7 @@ class ExtraFields function setOptionalsFromPost($extralabels,&$object) { global $_POST; - + if (is_array($extralabels)) { // Get extra fields