Fix warning

This commit is contained in:
Laurent Destailleur 2020-12-02 14:05:17 +01:00
parent c8274f13eb
commit 49be354c3e

View File

@ -5417,26 +5417,20 @@ abstract class CommonObject
$sql .= ",".$attributeKey; $sql .= ",".$attributeKey;
} }
// We must insert a default value for fields for other entities that are mandatory to avoid not null error // We must insert a default value for fields for other entities that are mandatory to avoid not null error
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) if (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) {
{ foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) {
foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { // If field not already added previously
{
if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
$sql .= ",".$tmpkey; $sql .= ",".$tmpkey;
} }
} }
} }
$sql .= ") VALUES (".$this->id; $sql .= ") VALUES (".$this->id;
foreach ($new_array_options as $key => $value) foreach ($new_array_options as $key => $value) {
{
$attributeKey = substr($key, 8); // Remove 'options_' prefix $attributeKey = substr($key, 8); // Remove 'options_' prefix
// Add field of attribute // Add field of attribute
if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { // Only for other type than separator)
{ if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') {
if ($new_array_options[$key] != '' || $new_array_options[$key] == '0')
{
$sql .= ",'".$this->db->escape($new_array_options[$key])."'"; $sql .= ",'".$this->db->escape($new_array_options[$key])."'";
} else { } else {
$sql .= ",null"; $sql .= ",null";
@ -5444,12 +5438,9 @@ abstract class CommonObject
} }
} }
// We must insert a default value for fields for other entities that are mandatory to avoid not null error // We must insert a default value for fields for other entities that are mandatory to avoid not null error
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) if (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) {
{ foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) {
foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { // If field not already added previously
{
if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0";
else $sql .= ", ''"; else $sql .= ", ''";
} }