Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
"allow-plugins": {
"composer/package-versions-deprecated": true,
"*": false
},
"audit": {
"ignore": ["PKSA-w9tt-7782-78jx"]
}
},
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recipesEndpoint": "",
"packages": [
{
"requirement": "dev-IBX-12204-siteaccessservice-scope-stack as 6.0.x-dev",
"repositoryUrl": "https://github.com/ibexa/behat.git",
"package": "ibexa/behat",
"shouldBeAddedAsVCS": false
}
]
}
66 changes: 0 additions & 66 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1596,18 +1596,6 @@ parameters:
count: 1
path: src/bundle/Core/EventListener/ConfigScopeListener.php

-
message: '#^Cannot access property \$matchingType on Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#'
identifier: property.nonObject
count: 2
path: src/bundle/Core/EventListener/ConsoleCommandListener.php

-
message: '#^Cannot access property \$name on Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#'
identifier: property.nonObject
count: 3
path: src/bundle/Core/EventListener/ConsoleCommandListener.php

-
message: '#^Method Ibexa\\Bundle\\Core\\EventListener\\ConsoleCommandListener\:\:onConsoleCommand\(\) has no return type specified\.$#'
identifier: missingType.return
Expand All @@ -1626,18 +1614,6 @@ parameters:
count: 1
path: src/bundle/Core/EventListener/ConsoleCommandListener.php

-
message: '#^Method Ibexa\\Bundle\\Core\\EventListener\\ConsoleCommandListener\:\:setSiteAccess\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/bundle/Core/EventListener/ConsoleCommandListener.php

-
message: '#^Parameter \#1 \$siteAccess of class Ibexa\\Core\\MVC\\Symfony\\Event\\ScopeChangeEvent constructor expects Ibexa\\Core\\MVC\\Symfony\\SiteAccess, Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null given\.$#'
identifier: argument.type
count: 1
path: src/bundle/Core/EventListener/ConsoleCommandListener.php

-
message: '#^Method Ibexa\\Bundle\\Core\\EventListener\\ContentDownloadRouteReferenceListener\:\:configureOptions\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down Expand Up @@ -2316,12 +2292,6 @@ parameters:
count: 1
path: src/bundle/Core/Fragment/InlineFragmentRenderer.php

-
message: '#^Property Ibexa\\Bundle\\Core\\Fragment\\InlineFragmentRenderer\:\:\$siteAccess is never read, only written\.$#'
identifier: property.onlyWritten
count: 1
path: src/bundle/Core/Fragment/InlineFragmentRenderer.php

-
message: '#^Trait Ibexa\\Bundle\\Core\\Fragment\\SiteAccessSerializationTrait is used zero times and is not analysed\.$#'
identifier: trait.unused
Expand Down Expand Up @@ -2370,24 +2340,6 @@ parameters:
count: 1
path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php

-
message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:setSiteAccess\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php

-
message: '#^Property Ibexa\\Bundle\\Core\\Imagine\\Cache\\AliasGeneratorDecorator\:\:\$siteAccess \(Ibexa\\Core\\MVC\\Symfony\\SiteAccess\) does not accept Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#'
identifier: assign.propertyType
count: 1
path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php

-
message: '#^Property Ibexa\\Core\\MVC\\Symfony\\SiteAccess\:\:\$name \(string\) on left side of \?\? is not nullable\.$#'
identifier: nullCoalesce.property
count: 2
path: src/bundle/Core/Imagine/Cache/AliasGeneratorDecorator.php

-
message: '#^Method Ibexa\\Bundle\\Core\\Imagine\\Cache\\Resolver\\RelativeResolver\:\:rewriteUrl\(\) has parameter \$url with no type specified\.$#'
identifier: missingType.parameter
Expand Down Expand Up @@ -2736,12 +2688,6 @@ parameters:
count: 1
path: src/bundle/Core/Matcher/ServiceAwareMatcherFactory.php

-
message: '#^Cannot access property \$name on Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#'
identifier: property.nonObject
count: 2
path: src/bundle/Core/SiteAccess/Config/ComplexConfigProcessor.php

-
message: '#^Method Ibexa\\Bundle\\Core\\SiteAccess\\Matcher\:\:setMatchingConfiguration\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down Expand Up @@ -6636,18 +6582,6 @@ parameters:
count: 1
path: src/lib/Helper/ContentPreviewHelper.php

-
message: '#^Method Ibexa\\Core\\Helper\\ContentPreviewHelper\:\:setSiteAccess\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Helper/ContentPreviewHelper.php

-
message: '#^Property Ibexa\\Core\\Helper\\ContentPreviewHelper\:\:\$originalSiteAccess \(Ibexa\\Core\\MVC\\Symfony\\SiteAccess\) does not accept Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#'
identifier: assign.propertyType
count: 1
path: src/lib/Helper/ContentPreviewHelper.php

-
message: '#^Cannot access property \$fieldTypeIdentifier on Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\FieldDefinition\|null\.$#'
identifier: property.nonObject
Expand Down
2 changes: 2 additions & 0 deletions phpunit.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<issue><![CDATA[Since ibexa/core 5.0: The "ibexa.content.download.field_id" route (/content/download/{contentId}/{fieldId}) is deprecated and will be removed in 6.0. Use the "ibexa.content.download.field_id.filename" route (/content/download/{contentId}/{fieldId}/{filename}) instead.]]></issue>
<issue><![CDATA[Since ibexa/core 5.0: The signature of method "Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest::__construct()" now requires explicit arguments: "string $scheme, string $host, string $port, string $pathinfo, array $queryParams, array $languages, array $headers", using ValueObject array constructor is deprecated.]]></issue>
<issue><![CDATA[Since ibexa/core 4.6: Passing Ibexa\Contracts\Core\Persistence\Content\Type instead of Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType as 2nd argument of Ibexa\Core\Repository\Mapper\ContentDomainMapper::buildDomainFields() method is deprecated and will cause a fatal error in 5.0. Build Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType using Ibexa\Core\Repository\Mapper\ContentTypeDomainMapper::buildContentTypeDomainObject prior passing it to the method]]></issue>
<issue><![CDATA[Since ibexa/core 6.0: Dispatching Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent manually under MVCEvents::CONFIG_SCOPE_CHANGE is deprecated and will no longer be reflected by Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessService::getCurrent() in 7.0. Call Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface::changeSiteAccess() instead.]]></issue>
<issue><![CDATA[Since ibexa/core 6.0: Dispatching Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent manually under MVCEvents::CONFIG_SCOPE_RESTORE is deprecated and will no longer be reflected by Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessService::getCurrent() in 7.0. Call Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface::restoreSiteAccess() instead.]]></issue>
</line>
</file>
<file path="tests/lib/MVC/Symfony/Security/UserWrappedTest.php">
Expand Down
12 changes: 6 additions & 6 deletions src/bundle/Core/Command/DebugConfigResolverCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Ibexa\Bundle\Core\Command;

use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -28,15 +28,14 @@ class DebugConfigResolverCommand extends Command
/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
private $configResolver;

/** @var \Ibexa\Core\MVC\Symfony\SiteAccess */
private $siteAccess;
private SiteAccessServiceInterface $siteAccessService;

public function __construct(
ConfigResolverInterface $configResolver,
SiteAccess $siteAccess
SiteAccessServiceInterface $siteAccessService
) {
$this->configResolver = $configResolver;
$this->siteAccess = $siteAccess;
$this->siteAccessService = $siteAccessService;

parent::__construct();
}
Expand Down Expand Up @@ -102,7 +101,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::SUCCESS;
}

$output->writeln('<comment>SiteAccess name:</comment> ' . $this->siteAccess->name);
$siteAccess = $this->siteAccessService->getCurrent();
$output->writeln('<comment>SiteAccess name:</comment> ' . ($siteAccess !== null ? $siteAccess->name : 'none'));

$output->writeln('<comment>Parameter:</comment>');
$cloner = new VarCloner();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Ibexa\Bundle\Core\Fragment\FragmentListenerFactory;
use Ibexa\Bundle\Core\Fragment\InlineFragmentRenderer;
use Ibexa\Bundle\Core\Fragment\SiteAccessSerializerInterface;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -49,7 +50,11 @@ public function process(ContainerBuilder $container): void
$container->setDefinition($renamedId, $definition);

$decoratedDef = new ChildDefinition(DecoratedFragmentRenderer::class);
$decoratedDef->setArguments([new Reference($renamedId), new Reference(SiteAccessSerializerInterface::class)]);
$decoratedDef->setArguments([
new Reference($renamedId),
new Reference(SiteAccessSerializerInterface::class),
new Reference(SiteAccessServiceInterface::class),
]);
$decoratedDef->setPublic($public);
$decoratedDef->setTags($tags);
// Special treatment for inline fragment renderer, to fit ESI renderer constructor type hinting (forced to InlineFragmentRenderer)
Expand Down
7 changes: 2 additions & 5 deletions src/bundle/Core/DependencyInjection/Compiler/SecurityPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Ibexa\Core\MVC\Symfony\Security\Authentication\AnonymousUserAccessListener;
use Ibexa\Core\MVC\Symfony\Security\Authentication\DefaultAuthenticationSuccessHandler;
use Ibexa\Core\MVC\Symfony\Security\HttpUtils;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
Expand All @@ -39,10 +39,7 @@ private function registerHttpUtils(ContainerBuilder $container): void

$httpUtilsDef = $container->findDefinition('security.http_utils');
$httpUtilsDef->setClass(HttpUtils::class);
$httpUtilsDef->addMethodCall(
'setSiteAccess',
[new Reference(SiteAccess::class)]
);
$httpUtilsDef->setArgument('$siteAccessService', new Reference(SiteAccessServiceInterface::class));
}

private function registerSecurityAuthenticationSuccessHandler(ContainerBuilder $container): void
Expand Down
34 changes: 11 additions & 23 deletions src/bundle/Core/EventListener/ConsoleCommandListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,34 @@
namespace Ibexa\Bundle\Core\EventListener;

use Ibexa\Core\MVC\Exception\InvalidSiteAccessException;
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
use Ibexa\Core\MVC\Symfony\MVCEvents;
use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ConsoleCommandListener implements EventSubscriberInterface, SiteAccessAware
class ConsoleCommandListener implements EventSubscriberInterface
{
/** @var string */
private $defaultSiteAccessName;

/** @var \Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessProviderInterface */
private $siteAccessProvider;

/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface */
private $eventDispatcher;

/** @var \Ibexa\Core\MVC\Symfony\SiteAccess|null */
private $siteAccess;
private SiteAccessServiceInterface $siteAccessService;

/** @var bool */
private $debug;

public function __construct(
string $defaultSiteAccessName,
SiteAccess\SiteAccessProviderInterface $siteAccessProvider,
EventDispatcherInterface $eventDispatcher,
SiteAccessServiceInterface $siteAccessService,
bool $debug = false
) {
$this->defaultSiteAccessName = $defaultSiteAccessName;
$this->siteAccessProvider = $siteAccessProvider;
$this->eventDispatcher = $eventDispatcher;
$this->siteAccessService = $siteAccessService;
$this->debug = $debug;
}

Expand All @@ -57,24 +50,19 @@ public static function getSubscribedEvents(): array

public function onConsoleCommand(ConsoleCommandEvent $event)
{
$this->siteAccess->name = $event->getInput()->getParameterOption('--siteaccess', $this->defaultSiteAccessName);
$this->siteAccess->matchingType = 'cli';
$siteAccessName = $event->getInput()->getParameterOption('--siteaccess', $this->defaultSiteAccessName);
$siteAccess = new SiteAccess($siteAccessName, 'cli');

if (!$this->siteAccessProvider->isDefined($this->siteAccess->name)) {
if (!$this->siteAccessProvider->isDefined($siteAccess->name)) {
throw new InvalidSiteAccessException(
$this->siteAccess->name,
$siteAccess->name,
$this->siteAccessProvider,
$this->siteAccess->matchingType,
$siteAccess->matchingType,
$this->debug
);
}

$this->eventDispatcher->dispatch(new ScopeChangeEvent($this->siteAccess), MVCEvents::CONFIG_SCOPE_CHANGE);
}

public function setSiteAccess(?SiteAccess $siteAccess = null)
{
$this->siteAccess = $siteAccess;
$this->siteAccessService->changeSiteAccess($siteAccess);
}

public function setDebug($debug = false)
Expand Down
19 changes: 8 additions & 11 deletions src/bundle/Core/Fragment/DecoratedFragmentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,29 @@
namespace Ibexa\Bundle\Core\Fragment;

use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
use Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer;

class DecoratedFragmentRenderer implements FragmentRendererInterface, SiteAccessAware
class DecoratedFragmentRenderer implements FragmentRendererInterface
{
private FragmentRendererInterface $innerRenderer;

private ?SiteAccess $siteAccess = null;

private SiteAccessSerializerInterface $siteAccessSerializer;

private SiteAccessServiceInterface $siteAccessService;

public function __construct(
FragmentRendererInterface $innerRenderer,
SiteAccessSerializerInterface $siteAccessSerializer
SiteAccessSerializerInterface $siteAccessSerializer,
SiteAccessServiceInterface $siteAccessService
) {
$this->innerRenderer = $innerRenderer;
$this->siteAccessSerializer = $siteAccessSerializer;
}

public function setSiteAccess(?SiteAccess $siteAccess = null): void
{
$this->siteAccess = $siteAccess;
$this->siteAccessService = $siteAccessService;
}

public function setFragmentPath(string $path): void
Expand All @@ -42,7 +39,7 @@ public function setFragmentPath(string $path): void
return;
}

$matcher = $this->siteAccess?->matcher;
$matcher = $this->siteAccessService->getCurrent()?->matcher;
if ($matcher instanceof SiteAccess\URILexer) {
$path = $matcher->analyseLink($path);
}
Expand Down
11 changes: 1 addition & 10 deletions src/bundle/Core/Fragment/InlineFragmentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@

namespace Ibexa\Bundle\Core\Fragment;

use Ibexa\Core\MVC\Symfony\SiteAccess;
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer as BaseRenderer;
use Symfony\Component\HttpKernel\Fragment\RoutableFragmentRenderer;

class InlineFragmentRenderer extends BaseRenderer implements SiteAccessAware, FragmentRendererInterface
class InlineFragmentRenderer extends BaseRenderer implements FragmentRendererInterface
{
protected FragmentRendererInterface $innerRenderer;

private ?SiteAccess $siteAccess = null;

private SiteAccessSerializerInterface $siteAccessSerializer;

public function __construct(
Expand All @@ -39,11 +35,6 @@ public function setFragmentPath($path): void
}
}

public function setSiteAccess(?SiteAccess $siteAccess = null): void
{
$this->siteAccess = $siteAccess;
}

/**
* @param array<string, mixed> $options
*/
Expand Down
Loading
Loading