From aa9bf012034fb99d5ddffa6620006cc728b6a5bc Mon Sep 17 00:00:00 2001 From: pawelpawlik Date: Fri, 27 Nov 2026 16:21:01 +0100 Subject: [PATCH 1/3] IBX-11423: Fixed deleting URL alias in a non-prioritized language via REST --- src/lib/Server/Controller/URLAlias.php | 2 +- tests/integration/IbexaTestKernel.php | 2 + .../Server/Controller/URLAliasTest.php | 111 ++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 tests/integration/Server/Controller/URLAliasTest.php diff --git a/src/lib/Server/Controller/URLAlias.php b/src/lib/Server/Controller/URLAlias.php index 1b2f8385..c45ec590 100644 --- a/src/lib/Server/Controller/URLAlias.php +++ b/src/lib/Server/Controller/URLAlias.php @@ -175,7 +175,7 @@ public function deleteURLAlias($urlAliasId) { $this->urlAliasService->removeAliases( [ - $this->urlAliasService->load($urlAliasId), + $this->urlAliasService->load($urlAliasId, true), ] ); diff --git a/tests/integration/IbexaTestKernel.php b/tests/integration/IbexaTestKernel.php index 41d2b1b8..9c6ae83d 100644 --- a/tests/integration/IbexaTestKernel.php +++ b/tests/integration/IbexaTestKernel.php @@ -14,6 +14,7 @@ use Ibexa\Contracts\Rest\UriParser\UriParserInterface; use Ibexa\Contracts\Test\Core\IbexaTestKernel as CoreIbexaTestKernel; use Ibexa\Rest\Server\Controller\Root as RestRootController; +use Ibexa\Rest\Server\Controller\URLAlias as URLAliasController; use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -45,6 +46,7 @@ protected static function getExposedServicesByClass(): iterable { yield from parent::getExposedServicesByClass(); yield RestRootController::class; + yield URLAliasController::class; yield UriParserInterface::class; } diff --git a/tests/integration/Server/Controller/URLAliasTest.php b/tests/integration/Server/Controller/URLAliasTest.php new file mode 100644 index 00000000..ba900a12 --- /dev/null +++ b/tests/integration/Server/Controller/URLAliasTest.php @@ -0,0 +1,111 @@ +getIbexaTestCore(); + $ibexaTestCore->loadSchema(); + $ibexaTestCore->loadFixtures(); + $ibexaTestCore->setAdministratorUser(); + } + + /** + * Regression test for IBX-11423: a custom URL alias created in a language which is not + * in the prioritized languages list must be removable via DELETE /content/urlaliases/{id}. + */ + public function testDeleteCustomUrlAliasInNonPrioritizedLanguage(): void + { + $this->ensureLanguageExists(self::NON_PRIORITIZED_LANGUAGE_CODE, 'Norwegian'); + + $location = $this->getIbexaTestCore()->getLocationService()->loadLocation(self::LOCATION_ID); + $urlAlias = $this->getURLAliasService()->createUrlAlias( + $location, + '/ibx-11423/norwegian-custom-alias', + self::NON_PRIORITIZED_LANGUAGE_CODE, + false, + false + ); + + self::assertContains( + $urlAlias->id, + $this->getCustomAliasIds($location), + 'Sanity check: the custom URL alias should exist before removal.' + ); + + $controller = $this->getIbexaTestCore()->getServiceByClassName(URLAliasController::class); + $result = $controller->deleteURLAlias($urlAlias->id); + + self::assertInstanceOf(NoContent::class, $result); + self::assertNotContains( + $urlAlias->id, + $this->getCustomAliasIds($location), + 'The custom URL alias in a non-prioritized language should have been removed.' + ); + } + + /** + * Lists custom aliases in all languages, regardless of the prioritized languages. + * + * @return list + */ + private function getCustomAliasIds(Location $location): array + { + $aliases = $this->getURLAliasService()->listLocationAliases($location, true, null, true); + + return array_values(array_map( + static fn (URLAlias $alias): string => $alias->id, + is_array($aliases) ? $aliases : iterator_to_array($aliases) + )); + } + + private function ensureLanguageExists( + string $languageCode, + string $name + ): void { + $languageService = $this->getIbexaTestCore()->getLanguageService(); + + try { + $languageService->loadLanguage($languageCode); + } catch (NotFoundException $e) { + $languageCreateStruct = $languageService->newLanguageCreateStruct(); + $languageCreateStruct->languageCode = $languageCode; + $languageCreateStruct->name = $name; + + $languageService->createLanguage($languageCreateStruct); + } + } + + private function getURLAliasService(): URLAliasService + { + return $this->getIbexaTestCore()->getServiceByClassName(URLAliasService::class); + } +} From f3e5ba8940b0590c5744aa455e982617c30c1e13 Mon Sep 17 00:00:00 2001 From: pawelpawlik Date: Fri, 27 Nov 2026 16:21:01 +0100 Subject: [PATCH 2/3] TEMPORARY: Added dependencies.json to test against ibexa/core#740 Points CI at the branch adding the $showAllTranslations argument to URLAliasService::load(). Must be removed before merging. --- dependencies.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dependencies.json diff --git a/dependencies.json b/dependencies.json new file mode 100644 index 00000000..3ac6a616 --- /dev/null +++ b/dependencies.json @@ -0,0 +1,11 @@ +{ + "recipesEndpoint": "", + "packages": [ + { + "requirement": "dev-IBX-11423_cant-delete-product-urlalias-for-translations as 4.6.x-dev", + "repositoryUrl": "https://github.com/ibexa/core", + "package": "ibexa/core", + "shouldBeAddedAsVCS": false + } + ] +} From b8861100c3a565ae30fd079cffc09744e1c8ba6a Mon Sep 17 00:00:00 2001 From: pawelpawlik Date: Tue, 1 Dec 2026 12:50:30 +0100 Subject: [PATCH 3/3] IBX-11423: Fixed loading URL alias in a non-prioritized language via REST --- src/lib/Server/Controller/URLAlias.php | 2 +- .../Server/Controller/URLAliasTest.php | 40 ++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/lib/Server/Controller/URLAlias.php b/src/lib/Server/Controller/URLAlias.php index c45ec590..6fb33760 100644 --- a/src/lib/Server/Controller/URLAlias.php +++ b/src/lib/Server/Controller/URLAlias.php @@ -62,7 +62,7 @@ public function __construct( */ public function loadURLAlias($urlAliasId) { - return $this->urlAliasService->load($urlAliasId); + return $this->urlAliasService->load($urlAliasId, true); } /** diff --git a/tests/integration/Server/Controller/URLAliasTest.php b/tests/integration/Server/Controller/URLAliasTest.php index ba900a12..288e6063 100644 --- a/tests/integration/Server/Controller/URLAliasTest.php +++ b/tests/integration/Server/Controller/URLAliasTest.php @@ -18,6 +18,7 @@ /** * @covers \Ibexa\Rest\Server\Controller\URLAlias::deleteURLAlias + * @covers \Ibexa\Rest\Server\Controller\URLAlias::loadURLAlias */ final class URLAliasTest extends IbexaKernelTestCase { @@ -44,16 +45,8 @@ protected function setUp(): void */ public function testDeleteCustomUrlAliasInNonPrioritizedLanguage(): void { - $this->ensureLanguageExists(self::NON_PRIORITIZED_LANGUAGE_CODE, 'Norwegian'); - $location = $this->getIbexaTestCore()->getLocationService()->loadLocation(self::LOCATION_ID); - $urlAlias = $this->getURLAliasService()->createUrlAlias( - $location, - '/ibx-11423/norwegian-custom-alias', - self::NON_PRIORITIZED_LANGUAGE_CODE, - false, - false - ); + $urlAlias = $this->createCustomUrlAliasInNonPrioritizedLanguage($location); self::assertContains( $urlAlias->id, @@ -72,6 +65,35 @@ public function testDeleteCustomUrlAliasInNonPrioritizedLanguage(): void ); } + /** + * Regression test for IBX-11423: a custom URL alias created in a language which is not + * in the prioritized languages list must be loadable via GET /content/urlaliases/{id}. + */ + public function testLoadCustomUrlAliasInNonPrioritizedLanguage(): void + { + $location = $this->getIbexaTestCore()->getLocationService()->loadLocation(self::LOCATION_ID); + $urlAlias = $this->createCustomUrlAliasInNonPrioritizedLanguage($location); + + $controller = $this->getIbexaTestCore()->getServiceByClassName(URLAliasController::class); + $loadedUrlAlias = $controller->loadURLAlias($urlAlias->id); + + self::assertSame($urlAlias->id, $loadedUrlAlias->id); + self::assertSame([self::NON_PRIORITIZED_LANGUAGE_CODE], $loadedUrlAlias->languageCodes); + } + + private function createCustomUrlAliasInNonPrioritizedLanguage(Location $location): URLAlias + { + $this->ensureLanguageExists(self::NON_PRIORITIZED_LANGUAGE_CODE, 'Norwegian'); + + return $this->getURLAliasService()->createUrlAlias( + $location, + '/ibx-11423/norwegian-custom-alias', + self::NON_PRIORITIZED_LANGUAGE_CODE, + false, + false + ); + } + /** * Lists custom aliases in all languages, regardless of the prioritized languages. *