Skip to content

Commit

Permalink
Fix issue with none existing webspace in requestAnalyzer in asnyc pro…
Browse files Browse the repository at this point in the history
…cesses
  • Loading branch information
alexander-schranz committed Nov 26, 2024
1 parent ef1f0dc commit cc5e7ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
23 changes: 11 additions & 12 deletions Document/Structure/ContentProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ContentProxyFactory
public function __construct(
ContentTypeManagerInterface $contentTypeManager,
LazyLoadingValueHolderFactory $proxyFactory,
RequestStack $requestStack,
RequestStack $requestStack
) {
$this->contentTypeManager = $contentTypeManager;
$this->proxyFactory = $proxyFactory;
Expand All @@ -64,7 +64,7 @@ function(
LazyLoadingInterface $proxy,
$method,
array $parameters,
&$initializer,
&$initializer
) use ($structure, $data) {
$initializer = null;
$wrappedObject = new \ArrayObject($this->resolveContent($structure, $data));
Expand Down Expand Up @@ -108,7 +108,7 @@ function(
LazyLoadingInterface $proxy,
$method,
array $parameters,
&$initializer,
&$initializer
) use ($structure, $data) {
$initializer = null;
$wrappedObject = new \ArrayObject($this->resolveView($structure, $data));
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc5e7ec

Please # to comment.