From af516fcb9009064a7c4464f0f9ffe2441f48ba6e Mon Sep 17 00:00:00 2001 From: Divesh Pahuja Date: Tue, 7 Nov 2023 12:53:13 +0100 Subject: [PATCH 1/3] [Bug] Remove obsolete json encode decode that could cause memory exhaustion - resolves #793 (#813) --- src/Configuration.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index a10a057c..9b83cdd2 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -80,7 +80,7 @@ public function __construct($type, $path, $name = null, $configuration = null) $this->setType($type); $this->setPath($path); $this->setName($name); - $this->setConfiguration($configuration ?? []); + $this->setConfiguration($configuration); } public function getObjectVars(): array @@ -148,12 +148,10 @@ public function setType(string $type): void */ public function setConfiguration($configuration): void { - if (is_array($configuration)) { - $configuration = json_decode(json_encode($configuration), true); - } - if (empty($this->getName())) { + if ($configuration && empty($this->getName())) { $this->setName($configuration['configuration']['general']['name'] ?? null); } + $this->configuration = $configuration; } From ea10a0862c7b7c4314f1e83c9584f4936cbc930d Mon Sep 17 00:00:00 2001 From: Translations Bot Date: Thu, 9 Nov 2023 14:18:20 +0000 Subject: [PATCH 2/3] POEditor translations import --- src/Resources/translations/admin.ca.yml | 2 +- src/Resources/translations/admin.cs.yml | 2 +- src/Resources/translations/admin.es.yml | 2 +- src/Resources/translations/admin.hu.yml | 2 +- src/Resources/translations/admin.it.yml | 2 +- src/Resources/translations/admin.nl.yml | 2 +- src/Resources/translations/admin.pl.yml | 2 +- src/Resources/translations/admin.pt_br.yml | 2 +- src/Resources/translations/admin.ro.yml | 99 ++++++++++++++++++++ src/Resources/translations/admin.sk.yml | 2 +- src/Resources/translations/admin.sv.yml | 2 +- src/Resources/translations/admin.th.yml | 2 +- src/Resources/translations/admin.zh_Hans.yml | 2 +- 13 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 src/Resources/translations/admin.ro.yml diff --git a/src/Resources/translations/admin.ca.yml b/src/Resources/translations/admin.ca.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.ca.yml +++ b/src/Resources/translations/admin.ca.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.cs.yml b/src/Resources/translations/admin.cs.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.cs.yml +++ b/src/Resources/translations/admin.cs.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.es.yml b/src/Resources/translations/admin.es.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.es.yml +++ b/src/Resources/translations/admin.es.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.hu.yml b/src/Resources/translations/admin.hu.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.hu.yml +++ b/src/Resources/translations/admin.hu.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.it.yml b/src/Resources/translations/admin.it.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.it.yml +++ b/src/Resources/translations/admin.it.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.nl.yml b/src/Resources/translations/admin.nl.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.nl.yml +++ b/src/Resources/translations/admin.nl.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.pl.yml b/src/Resources/translations/admin.pl.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.pl.yml +++ b/src/Resources/translations/admin.pl.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.pt_br.yml b/src/Resources/translations/admin.pt_br.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.pt_br.yml +++ b/src/Resources/translations/admin.pt_br.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.ro.yml b/src/Resources/translations/admin.ro.yml new file mode 100644 index 00000000..3a3e1e3b --- /dev/null +++ b/src/Resources/translations/admin.ro.yml @@ -0,0 +1,99 @@ +--- +plugin_pimcore_datahub_toolbar: Datahub Config +plugin_pimcore_datahub_configpanel_add: Add Configuration +plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration +plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier +plugin_pimcore_datahub_configpanel_error_adding_config: Error adding configuration +plugin_pimcore_datahub_configpanel: Configuration +plugin_pimcore_datahub_configpanel_invalid_name: Invalid name +plugin_pimcore_datahub_configpanel_invalid_length: Exceeded maximum configuration + name length 80 of characters +plugin_pimcore_datahub_configpanel_error_cloning_config: Error cloning configuration +plugin_pimcore_datahub_configpanel_enterclonekey_title: Clone +plugin_pimcore_datahub_configpanel_enterclonekey_enterclonekey_prompt: Name of clone +plugin_pimcore_datahub_configpanel_item_save_success: Configuration saved +plugin_pimcore_datahub_configpanel_item_saveerror: Configuration could not be saved +plugin_pimcore_datahub_configpanel_item_saveerror_permissions: Configuration cannot + be saved because it would deprive your update permissions. Please check the permissions + tab. +plugin_pimcore_datahub_configpanel_item_general: General +plugin_pimcore_datahub_configpanel_sqlObjectCondition: SQL Condition +plugin_pimcore_datahub_configpanel_schema: Schema Definition +plugin_pimcore_datahub_configpanel_schema_fields: Schema Fields +plugin_pimcore_datahub_configpanel_security: Security Definition +plugin_pimcore_datahub_configpanel_security_method: Method +plugin_pimcore_datahub_configpanel_security_method_apikey: API Key +plugin_pimcore_datahub_configpanel_fields: Fields +plugin_pimcore_datahub_configpanel_entity: Entity +plugin_pimcore_datahub_configpanel_root: Root Node +plugin_pimcore_datahub_fieldName: Field Name +plugin_pimcore_datahub_configpanel_condition_hint: This is a global SQL condition + in addition to the workspace settings that will be added to all queries +plugin_pimcore_datahub_configpanel_available_fields: Available Fields +plugin_pimcore_datahub_operator_thumbnail_config: Configuration +plugin_pimcore_datahub_operator_select_entity: Select Entity +plugin_pimcore_datahub_security_datahub_apikey: Datahub API Keys +plugin_pimcore_datahub_security_definition: Security Definition +plugin_pimcore_datahub_security_apikey_description: API key required for web service + access. One API key per line allowed. At least one key with minimum 16 characters + needs to be provided. +plugin_pimcore_datahub_config: Datahub Config +plugin_datahub_config: Datahub Config +plugin_datahub_adapter_graphql: Datahub Adapter - GraphQL +plugin_datahub_admin: Datahub Admin +plugin_pimcore_datahub_type_graphql: GraphQL +plugin_pimcore_datahub_workspace_permission_create: Create +plugin_pimcore_datahub_workspace_permission_read: Read +plugin_pimcore_datahub_workspace_permission_update: Update +plugin_pimcore_datahub_workspace_permission_delete: Delete +plugin_pimcore_datahub_graphql_open_explorer_in_iframe: Open in Iframe +plugin_pimcore_datahub_graphql_open_explorer_in_tab: Open in Tab +plugin_pimcore_datahub_graphql_query_schema: Query Schema +plugin_pimcore_datahub_graphql_mutation_schema: Mutation Schema +plugin_pimcore_datahub_graphql_iexplorer: iExplorer +plugin_pimcore_datahub_datatype_not_supported_yet: datatype '%s' not supported yet +operator_alias: Alias +operator_concatenator: Operator Concatenator +operator_dateformatter: Date Formatter +operator_element_counter: Element Counter +operator_text: Operator Text +operator_merge: Merge (deprecated) +operator_substring: Substring +operator_thumbnail: Thumbnail +operator_thumbnail_html: Thumbnail HTML +operator_translate_value: Operator Translate Value +operator_trimmer: Trimmer +mutationoperator_locale_switcher: Locale Switcher +mutationoperator_ifempty: IfEmpty +mutationoperator_locale_collector: Locale Collector +mutationoperator_locale_switcher_description: Switches to different language other + than the default language. +mutationoperator_ifempty_description: Only sets the value if current one is empty. +mutationoperator_locale_collector_description: Allows editing all languages for a + single field. +plugin_pimcore_datahub_query: Query +plugin_pimcore_datahub_mutation: Mutation +plugin_pimcore_datahub_graphql_special_schema: Generic Types +plugin_pimcore_datahub_graphql_special_document: Document +plugin_pimcore_datahub_graphql_special_document_folder: Document Folder +plugin_pimcore_datahub_graphql_special_asset: Asset +plugin_pimcore_datahub_graphql_special_asset_folder: Asset Folder +plugin_pimcore_datahub_graphql_special_object_folder: Object Folder +plugin_pimcore_datahub_graphql_special_asset_listing: Asset Listing +plugin_pimcore_datahub_graphql_special_translation_listing: Translation Listing +plugin_pimcore_datahub_graphql_special_translation: Translation +read: Read +plugin_pimcore_datahub_skip_permission_check: Skip Permission Check +plugin_pimcore_datahub_configpanel_permissions: Permissions +plugin_pimcore_datahub_graphql_permissions_roles: Role Permissions +plugin_pimcore_datahub_graphql_permissions_users: User Permissions +plugin_pimcore_datahub_operator_select_user: Select User +plugin_pimcore_datahub_operator_select_role: Select Role +plugin_pimcore_datahub_configpanel_user: User +plugin_pimcore_datahub_configpanel_role: Role +plugin_pimcore_datahub_disable_introspection: Disable Introspection +plugin_pimcore_datahub_security_introspection_description: 'Please note: When introspection + is disabled, the autocomplete feature will not work.' +plugin_pimcore_datahub_import: Import +plugin_pimcore_datahub_export: Export +... diff --git a/src/Resources/translations/admin.sk.yml b/src/Resources/translations/admin.sk.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.sk.yml +++ b/src/Resources/translations/admin.sk.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.sv.yml b/src/Resources/translations/admin.sv.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.sv.yml +++ b/src/Resources/translations/admin.sv.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.th.yml b/src/Resources/translations/admin.th.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.th.yml +++ b/src/Resources/translations/admin.th.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier diff --git a/src/Resources/translations/admin.zh_Hans.yml b/src/Resources/translations/admin.zh_Hans.yml index 24bb548d..3a3e1e3b 100644 --- a/src/Resources/translations/admin.zh_Hans.yml +++ b/src/Resources/translations/admin.zh_Hans.yml @@ -1,5 +1,5 @@ --- -plugin_pimcore_datahub_toolbar: Datahub +plugin_pimcore_datahub_toolbar: Datahub Config plugin_pimcore_datahub_configpanel_add: Add Configuration plugin_pimcore_datahub_configpanel_enterkey_title: Add a new configuration plugin_pimcore_datahub_configpanel_enterkey_prompt: Unique Identifier From 2530a31aa3b0a867e44c60915dca2e2d9b58bffa Mon Sep 17 00:00:00 2001 From: robertSt7 <104770750+robertSt7@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:20:59 +0100 Subject: [PATCH 3/3] [Bug]: GraphQl - query for asset meta data returns an exception (#816) * Fix: Add preResolveAssetMetadataEvents * Apply php-cs-fixer changes * Update src/GraphQL/Resolver/AssetType.php Co-authored-by: JiaJia Ji --------- Co-authored-by: robertSt7 Co-authored-by: JiaJia Ji --- src/Event/GraphQL/AssetMetadataEvents.php | 26 +++++++++ src/GraphQL/Resolver/AssetType.php | 64 ++++++++++++++--------- 2 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 src/Event/GraphQL/AssetMetadataEvents.php diff --git a/src/Event/GraphQL/AssetMetadataEvents.php b/src/Event/GraphQL/AssetMetadataEvents.php new file mode 100644 index 00000000..d4b1e896 --- /dev/null +++ b/src/Event/GraphQL/AssetMetadataEvents.php @@ -0,0 +1,26 @@ +getAssetFromValue($value, $context); + $metadata = $asset?->getMetadata(raw: true); + if (!$metadata) { + return null; + } - if ($asset) { - $metadata = $asset->getObjectVar('metadata'); - if ($metadata) { - if (isset($args['ignore_language']) && $args['ignore_language']) { - return $metadata; - } + //Relational data would return as a comma separated list. each element type and id by `_`, eg. "object_154,asset_489" + $event = new AssetEvent($asset, [ + 'metadata' => $metadata, + 'context' => $context + ]); + /** @var EventDispatcher $eventDispatcher */ + $eventDispatcher = \Pimcore::getContainer()->get('event_dispatcher'); + $eventDispatcher->dispatch($event, AssetMetadataEvents::PRE_RESOLVE); + $metadata = $event->getArgument('metadata'); + + if (isset($args['ignore_language']) && $args['ignore_language']) { + return $metadata; + } - $map = []; - $keys = []; - $language = isset($args['language']) ? $args['language'] : $this->getGraphQlService()->getLocaleService()->findLocale(); + $map = []; + $keys = []; + $language = $args['language'] ?? $this->getGraphQlService()->getLocaleService()->findLocale(); - foreach ($metadata as $item) { - $keys[$item['name']] = 1; - $l = $item['language'] ? $item['language'] : 'default'; - $map[$l][$item['name']] = $item; - } - $result = []; - - foreach ($keys as $key => $found) { - if (isset($map[$language][$key])) { - $result[] = $map[$language][$key]; - } elseif (isset($map['default'][$key])) { - $result[] = $map['default'][$key]; - } - } + foreach ($metadata as $item) { + $keys[$item['name']] = 1; + $l = $item['language'] ?: 'default'; + $map[$l][$item['name']] = $item; + } + $result = []; - if ($result) { - return $result; - } + foreach ($keys as $key => $found) { + if (isset($map[$language][$key])) { + $result[] = $map[$language][$key]; + } elseif (isset($map['default'][$key])) { + $result[] = $map['default'][$key]; } } + if ($result) { + return $result; + } + return null; }