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

loadRelations raises an exception when user cannot read

    Details

      Description

      ContentService->loadRelations raises an exception when the user cannot read one of the related content objects, rendering the method useless to list relations on many scenarios

      steps to reproduce
      • adapt editor role so that content read does not include restricted section
      • create an editor user
      • create some content and add relation to 2 other objects
      • move one of the related objects into restricted section
      • run the command below
        => expected result: output should include the related object that the user can read
        => actual result: an exception is raised, no objects are listed

          $repository = $this->getContainer()->get( 'ezpublish.api.repository' );
          $repository->setCurrentUser( $repository->getUserService()->loadUser( <editor-userId> ) );
          $locationService = $repository->getLocationService();
          $rootLocation = $locationService->loadLocation( $parent ); 
          $contentService = $repository->getContentService();
          $content = $contentService->loadContentByContentInfo(  $rootLocation->contentInfo );
          $versionInfo = $contentService->loadVersionInfoById(
                  $content->id,
                  $content->getVersionInfo()->versionNo
              );
              $allItems = $contentService->loadRelations( $versionInfo );
              $output->writeln( print_r( $allItems, true ) );
        

      the same behavior seems to be affecting loadReverseRelations

        Issue Links

          Activity

          Show
          Joaquim Cavalleri (Inactive) added a comment - PR with a suggestion: https://github.com/ezsystems/ezpublish-kernel/pull/605
          Show
          Jérôme Vieilledent (Inactive) added a comment - Fixed in master: https://github.com/ezsystems/ezpublish-kernel/commit/e5a86e49606e00ce3292a5d4c0138d883cdca1fa
          Hide
          Marcos Loureiro (Inactive) added a comment -
          Show
          Marcos Loureiro (Inactive) added a comment - Add integration test PR: https://github.com/ezsystems/ezpublish-kernel/pull/622
          Hide
          Marcos Loureiro (Inactive) added a comment -

          QA Approved

          Show
          Marcos Loureiro (Inactive) added a comment - QA Approved

            People

            • Assignee:
              Unassigned
              Reporter:
              Joaquim Cavalleri (Inactive)
            • 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 - 6 hours, 45 minutes
                6h 45m