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

Checking content permissions in the `RichText/Renderer` requires active session to work

    XMLWordPrintable

Details

    • Ibexa Open Source
    • Yes

    Description

      A command that is destined to render content fields will fail in case of one field being rich text field with embedded content due to https://github.com/ibexa/fieldtype-richtext/blob/main/src/lib/RichText/Renderer.php#L463 (lack of session and given user).

      An idea to solve this would be to allow some kind of sudo or use `PermissionResolver` with `can` instead.

      Steps to reproduce:

      1. Create an Article with a RichText field and embed any content into it.
      2. Create a new Symfony command with the following body:
            protected function execute(InputInterface $input, OutputInterface $output): int
            {
        
                $io = new SymfonyStyle($input, $output);
                $content = $this->repository->getContentService()->loadContent(67); //ID of Article content
        
                $io->section($this->fieldRenderingExtension->renderField($content, 'title'));
        
                $body = $this->repository->sudo(
                    function () use ($content) {
                        return $this->fieldRenderingExtension->renderField($content, 'intro');
                    }
                );
        
                $io->section($body);
        
                return Command::SUCCESS;
            }
        
      3. Run the command.

      Result:
      The command finishes with the exception:

      An exception has been thrown during the rendering of a template ("The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.")
      in "@IbexaFieldTypeRichText/RichText/content_fields.html.twig".

      Expected result:
      The command should render the RichText field in the console properly.

      Designs

        Attachments

          Activity

            People

              Unassigned Unassigned
              bartlomiej.wajda@ibexa.co Bartłomiej Wajda
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: