From b92e1f08e7a67c4009dfa343ae697a1f63ca9d33 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 27 Jan 2024 08:40:30 +0000 Subject: [PATCH] continue with optimizations --- DataStorage/Database/Mapper/DataMapperAbstract.php | 2 +- DataStorage/Database/Mapper/ReadMapper.php | 14 +++----------- Module/StatusAbstract.php | 12 ++++++------ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/DataStorage/Database/Mapper/DataMapperAbstract.php b/DataStorage/Database/Mapper/DataMapperAbstract.php index ebcafb184..8a13b847f 100755 --- a/DataStorage/Database/Mapper/DataMapperAbstract.php +++ b/DataStorage/Database/Mapper/DataMapperAbstract.php @@ -62,7 +62,7 @@ abstract class DataMapperAbstract * @var array * @since 1.0.0 */ - protected array $with = []; + public array $with = []; /** * Sort order diff --git a/DataStorage/Database/Mapper/ReadMapper.php b/DataStorage/Database/Mapper/ReadMapper.php index acb0ca819..22fc24ae6 100755 --- a/DataStorage/Database/Mapper/ReadMapper.php +++ b/DataStorage/Database/Mapper/ReadMapper.php @@ -854,13 +854,10 @@ final class ReadMapper extends DataMapperAbstract $value = $this->populateOwnsOne($def['internal'], $result, $default); - // loads hasMany relations. other relations are loaded in the populateOwnsOne - if (\is_object($value) && isset($this->mapper::OWNS_ONE[$def['internal']]['mapper'])) { - $this->mapper::OWNS_ONE[$def['internal']]['mapper']::reader(db: $this->db)->loadHasManyRelationsTest([$value]); - } - if (empty($value)) { - // @todo find better solution. this was because of a bug with the sales billing list query depth = 4. The address was set (from the client, referral or creator) but then somehow there was a second address element which was all null and null cannot be assigned to a string variable (e.g. country). The problem with this solution is that if the model expects an initialization (e.g. at lest set the elements to null, '', 0 etc.) this is now not done. + // @todo find better solution. this was because of a bug with the sales billing list query depth = 4. + // The address was set (from the client, referral or creator) but then somehow there was a second address element which was all null and null cannot be assigned to a string variable (e.g. country). + // The problem with this solution is that if the model expects an initialization (e.g. at lest set the elements to null, '', 0 etc.) this is now not done. $value = $isPrivate ? $refProp->getValue($obj) : $obj->{$member}; } } elseif (isset($this->mapper::BELONGS_TO[$def['internal']])) { @@ -872,11 +869,6 @@ final class ReadMapper extends DataMapperAbstract } $value = $this->populateBelongsTo($def['internal'], $result, $default); - - // loads hasMany relations. other relations are loaded in the populateBelongsTo - if (\is_object($value) && isset($this->mapper::BELONGS_TO[$def['internal']]['mapper'])) { - $this->mapper::BELONGS_TO[$def['internal']]['mapper']::reader(db: $this->db)->loadHasManyRelationsTest([$value]); - } } elseif (\in_array($def['type'], ['string', 'compress', 'int', 'float', 'bool'])) { if ($value !== null && $def['type'] === 'compress') { $def['type'] = 'string'; diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index fc385bf76..7ec93d6ee 100755 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -71,7 +71,7 @@ abstract class StatusAbstract */ public static function activateRoutes(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { - self::activateRoutesHooks($info, $appInfo, 'Routes'); + self::activateRoutesHooks($info, 'Routes', $appInfo); } /** @@ -127,7 +127,7 @@ abstract class StatusAbstract */ public static function activateHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { - self::activateRoutesHooks($info, $appInfo, 'Hooks'); + self::activateRoutesHooks($info, 'Hooks', $appInfo); } /** @@ -140,7 +140,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function activateRoutesHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null, string $type) : void + public static function activateRoutesHooks(ModuleInfo $info, string $type, ?ApplicationInfo $appInfo = null) : void { $directories = new Directory(static::PATH . '/' . $type); @@ -197,7 +197,7 @@ abstract class StatusAbstract */ public static function deactivateRoutes(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { - self::deactivateRoutesHooks($info, $appInfo, 'Routes'); + self::deactivateRoutesHooks($info, 'Routes', $appInfo); } /** @@ -210,7 +210,7 @@ abstract class StatusAbstract * * @since 1.0.0 */ - public static function deactivateRoutesHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null, string $type) : void + public static function deactivateRoutesHooks(ModuleInfo $info, string $type, ?ApplicationInfo $appInfo = null) : void { $directories = new Directory(static::PATH . '/'. $type); @@ -285,6 +285,6 @@ abstract class StatusAbstract */ public static function deactivateHooks(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { - self::deactivateRoutesHooks($info, $appInfo, 'Hooks'); + self::deactivateRoutesHooks($info, 'Hooks', $appInfo); } }