Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-17332

New permission copied from existing permission ignores permission set options

XMLWordPrintable

      I have been trying to add permissions through an extension and came across this issue where creating a new permission and copying an existing permission will ignore the Yes or Never option when using the permission set tool. It's hard to explain but here's a deeper dive...

      Here is the code I had:

      public function update_data() {
       
      	return [
      		[ 'permission.add', [ 'f_my_new_permission', false, 'f_reply' ] ],
      		[ 'if', [
      			[ 'permission.role_exists', [ 'ROLE_FORUM_FULL' ] ],
      			[ 'permission.permission_set', [ 'ROLE_FORUM_FULL', 'f_my_new_permission' ] ], // Yes
      		] ],
      		[ 'if', [
      			[ 'permission.role_exists', [ 'ROLE_FORUM_STANDARD' ] ],
      			[ 'permission.permission_set', [ 'ROLE_FORUM_STANDARD', 'f_my_new_permission' ] ], // Yes
      		] ],
      		[ 'if', [
      			[ 'permission.role_exists', [ 'ROLE_FORUM_LIMITED' ] ],
      			[ 'permission.permission_set', [ 'ROLE_FORUM_LIMITED', 'f_my_new_permission', 'role', false ] ], // Never
      		] ],
      	];
       
      }
      

      Now I'm creating a new permission called f_my_new_permission which I want to copy f_reply so that it basically mimics the Yes/No/Never setting that it uses.

      • So if f_reply is Yes, f_my_new_permission is also Yes;
      • and if f_reply is No, f_my_new_permission is No;
      • and if f_reply is Never, f_my_new_permission is Never.

      However, the problem is that further down, particularly at this line:

      [ 'permission.permission_set', [ 'ROLE_FORUM_LIMITED', 'f_my_new_permission', 'role', false ] ], // Never
      

      I'm trying to set f_my_new_permission to Never but because further up when adding the permission I said I wanted it to copy f_reply, the permission tool is doing just that and ignoring the permission_set declaration further down.

      In my opinion, this is a bug and not correct behaviour.

      The permission should copy the specified permission implicitly, it should not be setting the permission to the copy if it has explicit instruction during permission_set to do something else because as it currently stands, you won't be able to set a different value for various permission role combinations if you state it's a copy.

            Marc Marc
            danieltj Daniel James
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: