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

URI attribute of ezbinaryfile is generated using URIElement of the first used Siteaccess

    XMLWordPrintable

Details

    Description

      Steps to reproduce

      1. Install clean eZ Platform (1.7/1.13/2.x).
      2. Edit default Article ContentType and add the new field of type ezbinaryfile.
      3. Add new language, for instance Norwegian (nor-NO).
      4. Configure Siteaccesses as following:
            siteaccess:
                list: [nor, eng]
                groups:
                    site_group: [nor, eng]
                default_siteaccess: eng
                match:
                    URIElement: 1
            system:
                nor:
                    languages: [nor-NO]
                eng:
                    languages: [eng-GB]
        
      5. Create new article in eng-GB and attach file, for instance english.pdf.
      6. Translate content created in the previous step and attach new file, for instance norwegian.pdf.
      7. Create new frontend template and match it to handle Article ContentType:
        {% extends '@EzPublishCore/pagelayout.html.twig' %}
        {% block content %}
            {% set fileUri = ez_field_value(content, 'file').uri %}
            <a href="{{ fileUri }}">Download</a><br />
        {% endblock %}
        
      8. Open article on the frontend using nor siteaccess and check download link. You should see something like: example.com/nor/content/download/56/288.
      9. Open article on the frontend using eng siteaccess and check download link. You should see something like: example.com/nor/content/download/56/295.

      Actual behavior:
      ezbinaryfile uri property always contains the name of the siteaccess which has been used first.

      Expected behavior:
      ezbinaryfile uri should contain the name of the currently used siteaccess.

      Note:
      The issue isn't reproducible in v2, due to the fact how ContentProxy loads content, but still, cached uri might be invalid.
      Note:
      To reproduce the issue in v2 use the following configuration:

      ezplatform.yml
      site:
          languages: [eng-GB]
              content_view:
                 full:
                     file:
                        controller: "AppBundle:Index:main"
                        template: "full/test.html.twig"
                        match:
                            Identifier\ContentType: "file"
      

      and example Controller e.g.

      IndexController.php
      <?php
      
      namespace AppBundle\Controller;
      
      use eZ\Bundle\EzPublishCoreBundle\Controller;
      use eZ\Publish\Core\MVC\Symfony\View\ContentView;
      
      class IndexController extends Controller
      {
          public function mainAction(ContentView $view)
          {
              $content = $view->getContent();
              /** @var Value $fieldValue */
              $fieldValue = $content->getFieldValue('file');
              dump($fieldValue);
              return $this->redirect($fieldValue->uri);
          }
      }
      

      After that create a new File content. After publishing it visit it on the frontend SiteAccess. You will be able to download the file, however, URI parameter will contain "admin" prefix, for instance: /admin/content/download/57/265.

      After clearing Symfony cache, URI is correct /content/download/57/265. The issue is also reproducible using Redis. In that case, you need to clear Redis cache instead to see proper URI.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kamil.madejski@ibexa.co Kamil Madejski
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: