Skip to content

Commit

Permalink
Update Adapter_EntityMapper.php
Browse files Browse the repository at this point in the history
Fix for PHP7.4
  • Loading branch information
wdammak committed Sep 29, 2020
1 parent 3e3dc9f commit 40cd423
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Adapter/Adapter_EntityMapper.php
Expand Up @@ -59,6 +59,7 @@ public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cac
}

if ($object_datas = Db::getInstance()->getRow($sql)) {
$objectVars = get_object_vars($entity);
if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
$sql = 'SELECT *
FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang`
Expand All @@ -68,7 +69,7 @@ public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cac
if ($object_datas_lang = Db::getInstance()->executeS($sql)) {
foreach ($object_datas_lang as $row) {
foreach ($row as $key => $value) {
if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) {
if ($key != $entity_defs['primary'] && array_key_exists($key, $objectVars)) {
if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) {
$object_datas[$key] = array();
}
Expand All @@ -81,7 +82,9 @@ public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cac
}
$entity->id = (int)$id;
foreach ($object_datas as $key => $value) {
if (array_key_exists($key, $entity)) {
//if (array_key_exists($key, $entity)) {
if (array_key_exists($key, $entity_defs['fields'])
|| array_key_exists($key, $objectVars)) {
$entity->{$key} = $value;
} else {
unset($object_datas[$key]);
Expand Down

0 comments on commit 40cd423

Please sign in to comment.