From 21c03cc450004106b78dac63a1ad2a1990b24183 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 26 Nov 2024 09:08:27 +0100 Subject: [PATCH] Fix issue with none existing webspace in requestAnalyzer in asnyc processes --- Document/Structure/ContentProxyFactory.php | 19 +++++++++---------- phpstan-baseline.neon | 5 ----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Document/Structure/ContentProxyFactory.php b/Document/Structure/ContentProxyFactory.php index 1fe27b1c..8c2d2e83 100644 --- a/Document/Structure/ContentProxyFactory.php +++ b/Document/Structure/ContentProxyFactory.php @@ -43,7 +43,7 @@ class ContentProxyFactory public function __construct( ContentTypeManagerInterface $contentTypeManager, LazyLoadingValueHolderFactory $proxyFactory, - RequestStack $requestStack, + RequestStack $requestStack ) { $this->contentTypeManager = $contentTypeManager; $this->proxyFactory = $proxyFactory; @@ -150,17 +150,16 @@ private function getWebspaceKey(): ?string return null; } - if ($attributes->hasAttribute('webspaceKey')) { - return $attributes->getAttribute('webspaceKey'); + $webspaceKey = $attributes->getAttribute('webspaceKey'); + if (\is_string($webspaceKey) && '' !== $webspaceKey) { + return $webspaceKey; } - if ($attributes->hasAttribute('webspace')) { - $webspace = $attributes->getAttribute('webspace'); - if ($webspace instanceof Webspace) { - return $webspace->getKey(); - } elseif (\is_string($webspace) && '' !== $webspace) { - return $webspace; - } + $webspace = $attributes->getAttribute('webspace'); + if ($webspace instanceof Webspace) { + return $webspace->getKey(); + } elseif (\is_string($webspace) && '' !== $webspace) { + return $webspace; } return null; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3faf98b4..6a939762 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1460,11 +1460,6 @@ parameters: count: 1 path: Document/Structure/ContentProxyFactory.php - - - message: "#^Negated boolean expression is always false\\.$#" - count: 1 - path: Document/Structure/ContentProxyFactory.php - - message: "#^Parameter \\#1 \\$webspace of method Sulu\\\\Component\\\\Content\\\\Compat\\\\StructureInterface\\:\\:setWebspaceKey\\(\\) expects string, string\\|null given\\.$#" count: 2