Issue Bug Closed

#103092Persisting File reference on new page gets pid 0 instead of the pid of the record

Sven Ignor 02/09/24, 12:35 updated 12/02/25, 14:33

Description

Hello everyone,

unfortunately I can reproduce the “problem” of the already solved bug https://forge.typo3.org/issues/82931 in our TYPO3 12LTS (12.4.10).
Could someone take a look at it?

Thanks in advance

Here is the content of the linked bug as a quote:

> Steps to reproduce:
> Go to ‘list’ mode (You can use ‘Create New’ wizard also)
> Create a new page (so it has uid NEW_*)
> Attach a resource like an image
> Save the record

> Expected behavior:
> The sys_file_reference entry has a pid of the newly created page

> Observed behavior:
> The sys_file_reference entry has a pid of 0

> Result:
> A regular ‘mortal’ user can never remove the reference from the page object because it has no access to remove stuff from pid 0.
> I only observed this behavior in page records. tt_content for example, seems to work fine

Reviews 3

Files 1

History 913

  1. Sybille Peters commented <span data-processor="relativetime" data-value="2024-02-09T15:47:47+00:00" > 02/09/24, 15:47 </span>

    I could reproduce this in latest v12 and v13 via the description – important is to use list module and not save page until the the file reference is created.

  2. Georg Ringer commented and changed status New Accepted <span data-processor="relativetime" data-value="2025-04-03T11:15:53+00:00" > 04/03/25, 11:15 </span>

    can be still confirmed on main (14-0)

  3. Georg Ringer changed subject TYPO3 12LTS | php8.1 | File reference on new page gets pid 0 instead of the pid of the record Persisting File reference on new page gets pid 0 instead of the pid of the record <span data-processor="relativetime" data-value="2025-04-03T11:16:07+00:00" > 04/03/25, 11:16 </span>

  4. Georg Großberger commented <span data-processor="relativetime" data-value="2025-08-22T12:33:35+00:00" > 08/22/25, 12:33 </span>

    The problem seems to be in \TYPO3\CMS\Backend\Form\Container\FileReferenceContainer::render: The HTML has a form field [pid] with the UID of the parent record. That value is cast to an integer, which yields 0 if the PID of the parent record is a NEW... reference.

  5. Gerrit Code Review pushed patch set 1 for main to change 90474 status Accepted Under Review <span data-processor="relativetime" data-value="2025-08-22T12:37:05+00:00" > 08/22/25, 12:37 </span>

  6. Christian Kuhn commented <span data-processor="relativetime" data-value="2025-08-22T13:21:06+00:00" > 08/22/25, 13:21 </span>

    Note: ext:dbdoctor fixes affected existing sys_file_reference records by updating to correct pid.

  7. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-08-22T13:50:12+00:00" > 08/22/25, 13:50 </span>

    Applied in changeset commit:cfc640ba873e6ca554ff322a09547e69c41f0764.