Update ObjectModel.php

Fix PHP7.4
This commit is contained in:
wdammak
2020-09-29 18:15:08 +02:00
committed by GitHub
parent 3e3dc9fbaa
commit 6f3baf9fe6

View File

@@ -628,7 +628,7 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
$this->clearCache();
// Automatically fill dates
if (array_key_exists('date_upd', $this)) {
if (property_exists($this, 'date_upd')) {
$this->date_upd = date('Y-m-d H:i:s');
if (isset($this->update_fields) && is_array($this->update_fields) && count($this->update_fields)) {
$this->update_fields['date_upd'] = true;
@@ -636,7 +636,7 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
}
// Automatically fill dates
if (array_key_exists('date_add', $this) && $this->date_add == null) {
if (property_exists($this, 'date_add') && $this->date_add == null) {
$this->date_add = date('Y-m-d H:i:s');
if (isset($this->update_fields) && is_array($this->update_fields) && count($this->update_fields)) {
$this->update_fields['date_add'] = true;
@@ -682,7 +682,7 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
if ($shop_exists) {
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
foreach ($fields as $key => $val) {
if (!array_key_exists($key, (array)$this->update_fields)) {
if (!property_exists((array)$this->update_fields, $key)) {
unset($fields[$key]);
}
}
@@ -818,7 +818,7 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
public function toggleStatus()
{
// Object must have a variable called 'active'
if (!array_key_exists('active', $this)) {
if (!property_exists($this, 'active')) {
throw new PrestaShopException('property "active" is missing in object '.get_class($this));
}
@@ -1104,7 +1104,7 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
}
$key = $class.'_'.md5($field);
return ((is_array($_FIELDS) && array_key_exists($key, $_FIELDS)) ? ($htmlentities ? htmlentities($_FIELDS[$key], ENT_QUOTES, 'utf-8') : $_FIELDS[$key]) : $field);
return ((is_array($_FIELDS) && property_exists($_FIELDS, $key)) ? ($htmlentities ? htmlentities($_FIELDS[$key], ENT_QUOTES, 'utf-8') : $_FIELDS[$key]) : $field);
}
/**
@@ -1221,10 +1221,10 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
if (isset($this->{$ws_params_attribute_name}['associations'])) {
foreach ($this->{$ws_params_attribute_name}['associations'] as $assoc_name => &$association) {
if (!array_key_exists('setter', $association) || (isset($association['setter']) && !$association['setter'])) {
if (!property_exists($association, 'setter') || (isset($association['setter']) && !$association['setter'])) {
$association['setter'] = Tools::toCamelCase('set_ws_'.$assoc_name);
}
if (!array_key_exists('getter', $association)) {
if (!property_exists($association, 'getter')) {
$association['getter'] = Tools::toCamelCase('get_ws_'.$assoc_name);
}
}