Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix issue with none existing webspace in requestAnalyzer in asnyc processes #710

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Document/Structure/ContentProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sulu\Component\Content\Compat\StructureInterface;
use Sulu\Component\Content\ContentTypeManagerInterface;
use Sulu\Component\Webspace\Analyzer\Attributes\RequestAttributes;
use Sulu\Component\Webspace\Webspace;
use Symfony\Component\HttpFoundation\RequestStack;

/**
Expand Down Expand Up @@ -144,12 +145,23 @@ private function getWebspaceKey(): ?string
return null;
}

/** @var RequestAttributes $attributes */
$attributes = $request->attributes->get('_sulu');
if (!$attributes) {
if (!$attributes instanceof RequestAttributes) {
return null;
}

return $attributes->getAttribute('webspaceKey') ?? $attributes->getAttribute('webspace')->getKey();
$webspaceKey = $attributes->getAttribute('webspaceKey');
if (\is_string($webspaceKey) && '' !== $webspaceKey) {
return $webspaceKey;
}

$webspace = $attributes->getAttribute('webspace');
if ($webspace instanceof Webspace) {
return $webspace->getKey();
} elseif (\is_string($webspace) && '' !== $webspace) {
return $webspace;
}

return null;
}
}
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
Loading