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

switchlanguage doesn't respect RemoveSiteAccessIfDefaultAccess (patch proposed)

    XMLWordPrintable

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            enzo enzo
            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