Issue Bug New

#111707 Copying a page leaves inline children of denied records attached to the original record

Sven Juergens 12/02/26, 14:59 updated 12/02/26, 14:59

Description

Problem

An editor copies a page that contains a content element with a file reference. The editor’s group may modify tt_content and sys_file_reference, but the record type (CType) of the content element is not allowed via “Explicitly allow field values”.

The content element is correctly not copied (sys_log: Attempt to copy record "tt_content:…" without having permissions to do so [ERROR: authMode "explicitAllow" failed for field "CType" …]). Its file reference however is copied anyway, onto the new page, but still pointing to the original content element (uid_foreign). The original element then renders the image twice, although nobody edited it.

The order of the tables in “Tables (modify)” does not matter. Other inline children with foreign_field (e.g. IRRE child records) behave the same way. Admins do not run into this case, as they may use every record type.

Steps to reproduce

  1. Create a backend user group with “Tables (modify)” including pages, tt_content and sys_file_reference, the fields of the “Text & Media” element in “Allowed excludefields”, and in “Explicitly allow field values” only the record type “Regular Text Element” (text), not “Text & Media” (textmedia).
  2. Create an editor in this group with access to a page tree.
  3. As admin, create a page in that tree with a “Text & Media” element holding one image.
  4. As the editor, copy this page and paste it (e.g. into the same parent page).
  5. Look at the original page: the “Text & Media” element now shows the image twice. In the database, a new sys_file_reference record exists on the copied page with uid_foreign pointing to the original content element.

Cause

DataHandler::copySpecificPage() copies the records of a page table by table, including the tables of inline child records. A child copied this way still points to its original parent and is only reassigned once the parent itself is copied (as when a single record is copied, copyRecord_processRelation()). When the parent is rejected by the access checks in copyRecord(), the copied child stays attached to the original record. If the parent table comes first, the rejected parent copies nothing, and the child table is copied standalone afterwards with the same result.

Same pattern as #72975, which was fixed for localizing records.

Suggested fix

See the attached patch against main (the DataHandler part applies to 14.3 as well), including a functional test.

The records of a page that are children of an inline relation of their table are skipped in copySpecificPage(). A record counts as a child under the same conditions RelationHandler uses to fetch the children of a parent (foreign_field, foreign_table_field, foreign_match_fields); pointers to system fields like pid are not considered. Children are then copied along with their parent only, as when a single record is copied.

Notes:
  • Children whose parent is not copied along (e.g. located on another page, or missing) are no longer copied as standalone records.
  • Inline relations defined in FlexForms keep their previous behaviour.
  • l10n_source of translated children copied along with their parent still points to the original record. That is #111645 (change 98113) and already happens today when the parent table is copied first.
  • Not covered: a parent rejected only later in process_datamap() (e.g. by the content type restrictions of a backend layout column) still leaves its children attached to the original record, as copyRecord() copies the children before the parent is inserted. This affects admins too and is independent of copying a whole page.

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] Copying a page leaves inline children of denied records attached to the original record

Resolves: #111707
Releases: main

Files 1