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

loadRelations raises an exception when user cannot read

    XMLWordPrintable

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            joaquim.cavalleri-obsolete@ez.no 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