Issue Bug Needs Feedback Quiet

#85403Copy of recursive pagetree does not keep permissions of the copy-source

Josef Glatz 06/27/18, 08:37 updated 10/18/26, 16:32

Description

Problem/Description

initial situation

  • Pagetree with configured page permissions for each/every subpage.
  • backend user config allows recursive copying

Problem

  • The copied pagetree doesn’t keep any of the permissions (An editor have to configure each copied pagetree and can not really benefit (except the copied pagetree)) perms_userid,perms_groupid,perms_user,perms_group,perms_everybody

Test #1

I removed any PageTSConfig: all subpages getting the same permissions as the rootpage which get’s copied.

Test #2

The root page includes following PageTSConfig:

TCEMAIN {
    // Permissions for "user"
    permissions.user = show,edit,delete,new,editcontent
    // Permissions for "group"
    permissions.group = show,edit,delete,new,editcontent
    // Set owner group
    permissions.groupid = 1
    // Permissions for "everybody"
    permissions.everybody =
}

—-

All subpages get these permissions. I would assume that when copying a record only the UID and the PIP columns gets adjusted by the datahandler.

Acceptance Criteria

  • All page permissions must be kept no matter if only one page or recursive pages are copied in the TYPO3 backend

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] Copy of recursive pagetree does not keep permissions of the copy-source Resolves: #85403 Releases: main

History 10

  1. Anonymous commented <span data-processor="relativetime" data-value="2019-03-26T15:29:18+00:00" > 03/26/19, 15:29 </span>

    Can confirm this bug. TYPO3 9.5.5

    Even using the TYPO3\CMS\Core\DataHandling\DataHandler to copy a tree ignores the permission.

    $cmd = array(
       'pages' => array(
          $srcPid => array(
             'copy' => array(
                'action' => 'paste',
                'target' => $targetPid,
                'update' => array(
                   'title' => $newRootPageTitle,
                   'hidden' => 0,
                )
             )
          )
        )
     );
     $dataHandler = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
     $dataHandler->copyTree = 99;
     $dataHandler->defaultPermissions = [
        'user' => 'show,edit,delete,new,editcontent',
        'group' => 'show,edit,delete,new,editcontent',
        'everybody' => 'show,edit,delete,new,editcontent'
     ];
     $dataHandler->defaultValues = [
        'pages' => [
           'perms_groupid' => 1
        ]
     ];
     // define which tables should be copied
     $dataHandler->copyWhichTables = 'sys_template,tt_content,backend_layout';
     $dataHandler->start([], $cmd);
     $dataHandler->process_cmdmap();

    This copies the tree but the permissions and the group is not set even I override the $dataHandler->defaultPermissions and $dataHandler->defaultValues.

  2. Anonymous commented <span data-processor="relativetime" data-value="2019-03-27T08:13:52+00:00" > 03/27/19, 08:13 </span>

    Well maybe I don’t use the permission stuff in DataHandler the right way?

    Setting

    $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'] = [
        'user' => 'show,edit,delete,new,editcontent',
        'group' => 'show,edit,new,editcontent',
        'everybody' => 'show,edit,delete,new,editcontent'
    ];

    in my AdditionalConfiguration.php and using the code above the permissions are set like defined in $GLOBALS[‘TYPO3_CONF_VARS’][‘BE’][‘defaultPermissions’].

    But this does not solve the main problem that copied pages don’t inherit the permissions from there source page.

  3. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2026-10-18T16:32:45+00:00" > 10/18/26, 16:32 </span>

    Hi everyone,

    I checked this on current main, and the behaviour is still the same. As far as I can tell, that’s intended.

    A copied page is a new page. The perms_* fields are deliberately not copied: the copy gets the permissions from TCEMAIN.permissions.* of the target page (or $GLOBALS[‘TYPO3_CONF_VARS’][‘BE’][‘defaultPermissions’]), and the user who copies it becomes the owner. If we copied the source’s permissions, the copy would still belong to the original owner. Editors could then end up with pages they can’t edit or delete themselves.

    For the edge case where a project really needs the permissions copied, there’s now the BeforeRemoveNonCopyableFieldsEvent (#106456). A listener can take the perms_* fields off the list, and they are copied along with the page:

    #[AsEventListener]
    public function __invoke(BeforeRemoveNonCopyableFieldsEvent $event): void
    {
        if ($event->getTable() !== 'pages' || $event->getCallingOperation() !== 'copyRecord') {
            return;
        }
        $event->setNonCopyableFields(array_diff(
            $event->getNonCopyableFields(),
            ['perms_groupid', 'perms_user', 'perms_group', 'perms_everybody']
        ));
    }

    This keeps the group and permission bits but still makes the copying user the owner.

    What do you think? Since this is an edge case that can now be solved with the event, I’d suggest we keep the current behaviour in Core as intended and close this issue. Any objections?