Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-18662

switchlanguage doesn't respect RemoveSiteAccessIfDefaultAccess (patch proposed)

    Details

      Description

      I have in my site.ini, among other settings:

      [SiteSettings]
      DefaultAccess=en

      [SiteAccessSettings]
      RemoveSiteAccessIfDefaultAccess=enabled

      As a result, as expected, the siteAccess is not included in the url when I surf on the default siteAccess

      However when I'm on a siteaccess that is not the default one, for example fr (for french, 'en' was for english), like:
      http://www.domain.com/fr/my-link

      when I use the switchlanguage link to go to default siteAccess, like: http://www.domain.com/fr/switchlanguage/to/en/my-link

      I'm redirected to: http://www.domain.com/en/my-link

      This link is correct, but as I have RemoveSiteAccessIfDefaultAccess=enabled, the link should be:
      http://www.domain.com/my-link

      In order to correct the problem, I've modified the file kernel/private/classes/ezplanguageswitcher.php around line 158:

      the following code:

              if ( $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI )
              {
                  $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
              }
              else
              {
                  $finalUrl = $this->baseDestinationUrl . '/' . $urlAlias;
              }
      

      is replaced by:

              $ini = eZINI::instance();
              if ( $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI &&
                   !($ini->variable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess' ) == "enabled" &&
                     $ini->variable( 'SiteSettings', 'DefaultAccess' ) == $this->destinationSiteAccess) )
              {
                  $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
              }
              else
              {
                  $finalUrl = $this->baseDestinationUrl . '/' . $urlAlias;
              }
      

      After this patch, all redirections from switchlanguage seem to work as expected

        Issue Links

          Activity

          Hide
          Jerome Despatis added a comment -

          Well it's duplicate with #017850, that exists for several months ago (patch also provided in that issue)

          Any idea when a patch could be included?

          For seach engines like google, it's an important issue!

          Show
          Jerome Despatis added a comment - Well it's duplicate with #017850, that exists for several months ago (patch also provided in that issue) Any idea when a patch could be included? For seach engines like google, it's an important issue!
          Hide
          Edi Modrić added a comment -

          I think both of these issues are related to http://issues.ez.no/IssueView.php?Id=18411

          That is a root issue here, I believe, and I proposed a patch for it over at github.

          https://github.com/ezsystems/ezpublish/pull/123

          Can you test if that patch resolves this?

          Show
          Edi Modrić added a comment - I think both of these issues are related to http://issues.ez.no/IssueView.php?Id=18411 That is a root issue here, I believe, and I proposed a patch for it over at github. https://github.com/ezsystems/ezpublish/pull/123 Can you test if that patch resolves this?
          Hide
          Jerome Despatis added a comment -

          Hello

          Well no sorry, it doesn't solve the issue http://issues.ez.no/IssueView.php?Id=18662
          nore http://issues.ez.no/IssueView.php?Id=18663

          It seems to be different problems

          Show
          Jerome Despatis added a comment - Hello Well no sorry, it doesn't solve the issue http://issues.ez.no/IssueView.php?Id=18662 nore http://issues.ez.no/IssueView.php?Id=18663 It seems to be different problems
          Hide
          Jerome Despatis added a comment -

          By the way, in my config, I use: MatchOrder=host;uri

          Show
          Jerome Despatis added a comment - By the way, in my config, I use: MatchOrder=host;uri
          Hide
          Edi Modrić added a comment -

          You are right, it is indeed a separate issue.

          Show
          Edi Modrić added a comment - You are right, it is indeed a separate issue.
          Show
          Jerome Despatis added a comment - https://github.com/ezsystems/ezpublish/pull/149
          Show
          Patrick Allaert (Inactive) added a comment - PR at: https://github.com/ezsystems/ezpublish/pull/533/
          Show
          Patrick Allaert (Inactive) added a comment - Fixed in: eZ Publish master (merge commit): https://github.com/ezsystems/ezpublish/commit/e780706c49889ef10f49ec404df5d2840f780693 eZ Publish master: https://github.com/ezsystems/ezpublish/commit/1208e20e3fafca96867826bd51a7b099ebd0e2b6

            People

            • Assignee:
              Unassigned
              Reporter:
              Jerome Despatis
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 5 hours, 30 minutes
                1d 5h 30m