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

addLimitation() new SubtreeLimitation fails with InvalidArgumentException

    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,                                                                                        
                ),                                                                                                   
              )),                                                                                                    
            ),                                                                                                       
          )              
        

        Issue Links

          Activity

          Show
          Joaquim Cavalleri (Inactive) added a comment - PR: https://github.com/ezsystems/ezpublish-kernel/pull/543
          Show
          Joaquim Cavalleri (Inactive) added a comment - Fixed in master: https://github.com/ezsystems/ezpublish-kernel/commit/282b91036d358e24717c5e7a0c020cfb41dc4af5
          Hide
          Joao Pingo (Inactive) added a comment -

          QA Approved

          Show
          Joao Pingo (Inactive) added a comment - QA Approved

            People

            • Assignee:
              Unassigned
              Reporter:
              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