Uploaded image for project: 'Ibexa IBX'
  1. Ibexa IBX
  2. IBX-7851

[PHP API] URLAliasService::listLocationAliases returns first translation of URL alias instead of the requested one when prioritized list is empty

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • 4.6.0, 3.3.37, 4.5.6
    • Open Source
    • Ibexa Open Source

    Description

      Reproducible probably on PHP API level only (but see if it affects IBX-4753 and similar - unlikely since the prioritized languages list is present there but it's not full in these cases - worth to check anyway).

      Steps to reproduce

      1. Create content item with 2 separate translations
      2. Try loading auto-generated entries via URLAliasService::listLocationAliases(custom:false) for a second language // double check that SA layer doesn't inject prioritized list when testing via CMD

      Actual result

      1. See that even while persistence URL alias object contains all the information (meaning all translations), only the first one is loaded
      2. See that if $prioritizedLanguagesList is given, the entry is loaded correctly

      Expected result

      If an entry exists, it should be returned correctly for an empty prioritized languages list. If an entry doesn't exist in a given language, the first one should be returned (as-is now).

      Seems this diff might resolve the issue: (ezplatform-kernel:1.3)

      diff --git a/eZ/Publish/Core/Repository/URLAliasService.php b/eZ/Publish/Core/Repository/URLAliasService.php
      index 8a7b11ad53..46bad50c33 100644
      --- a/eZ/Publish/Core/Repository/URLAliasService.php
      +++ b/eZ/Publish/Core/Repository/URLAliasService.php
      @@ -299,9 +299,10 @@ class URLAliasService implements URLAliasServiceInterface
       
               if ($spiUrlAlias->alwaysAvailable || $showAllTranslations) {
                   $lastLevelData = end($spiUrlAlias->pathData);
      -            reset($lastLevelData['translations']);
      --- a/eZ/Publish/Core/Repository/URLAliasService.php
      +++ b/eZ/Publish/Core/Repository/URLAliasService.php
      @@ -299,9 +299,10 @@ class URLAliasService implements URLAliasServiceInterface
       
               if ($spiUrlAlias->alwaysAvailable || $showAllTranslations) {
                   $lastLevelData = end($spiUrlAlias->pathData);
      -            reset($lastLevelData['translations']);
       
      -            return key($lastLevelData['translations']);
      +            return isset($lastLevelData['translations'][$languageCode])
       
      -            return key($lastLevelData['translations']);
      +            return isset($lastLevelData['translations'][$languageCode])
      +                ? $languageCode
      +                : (key($lastLevelData['translations']) ?? false);
               }
       
               return false;
      

      Designs

        Attachments

          Activity

            People

              Unassigned Unassigned
              andrew.longosz@ibexa.co Andrew Longosz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: