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

addLimitation() new SubtreeLimitation fails with InvalidArgumentException

    XMLWordPrintable

Details

    Description

      Using the API to add a limitation based on subtree to a role fails, with InvalidArgumentException

      steps to reproduce:
      • execute the following command
        $repository = $this->getContainer()->get( 'ezpublish.api.repository' );
        $repository->setCurrentUser( $repository->getUserService()->loadUser( 14 ) );
        $roleService = $repository->getRoleService();
        
        $roleCreate = $roleService->newRoleCreateStruct( "testrole" );
        $role = $roleService->createRole( $roleCreate );
        $roleService->newPolicyCreateStruct( "content", "read" );
        
        $policyStruct->addLimitation( new SubtreeLimitation, array( "limitationValues" => array( "/1/2/") ) );
        $roleService->addPolicy( $role, $policyStruct );
        
      • the command will fail with:
        [eZ\Publish\Core\Base\Exceptions\InvalidArgumentException]                                                 
          Argument 'limitations' is invalid: Some validations did not validate:                                      
           array (                                                                                                   
            'Subtree' =>                                                                                             
            array (                                                                                                  
              0 =>                                                                                                   
              eZ\Publish\Core\FieldType\ValidationError::__set_state(array(                                          
                 'singular' => 'limitationValues[%key%] => \'%value%\' does not exist in the backend :: /1/2/ :: ',  
                 'plural' => NULL,                                                                                   
                 'values' =>                                                                                         
                array (                                                                                              
                  'value' => '/1/2/',                                                                                
                  'key' => 0,                                                                                        
                ),                                                                                                   
              )),                                                                                                    
            ),                                                                                                       
          )              
        

      Attachments

        Activity

          People

            Unassigned Unassigned
            joaquim.cavalleri-obsolete@ez.no Joaquim Cavalleri (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 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 - 4 hours
                4h