Review 14.3 Merged

95612[TASK] Remove leftovers of the "pid=-1" workspace marker

Benni Mack CR +2 V +2 Normal +22 −37 updated 09/03/26, 19:02

Commit message

Until TYPO3 v10, a versioned record did not live on the page it
belonged to: DataHandler wrote "pid = -1" to mark a record as an
"offline version". Queries all over the Core therefore had to add
"pid >= 0", "pid > -1" or "pid <> -1" to keep such records out of
regular result sets.

That marker was introduced in 2004 together with the first
versioning API and has been dismantled in three steps since:

* v10.1 (#89122, #89157) moved all read paths from "pid" to the
  fields that actually describe a version, namely t3ver_oid,
  t3ver_wsid and t3ver_state, and replaced hand-written SQL with
  WorkspaceRestriction.
* v10.4 (#89555) stopped writing "pid = -1" altogether. A version
  now lives on the same page as its live record, and an upgrade
  wizard migrated existing rows.
* v11.0 (#92497, #92291, #92598) removed the move placeholder
  (t3ver_state = 3), which only existed because the move pointer
  had no usable "pid", dropped the computed property "_REAL_PID"
  and streamlined "_ORIG_pid".

Since "pid" is defined as an unsigned integer, every remaining
"pid >= 0", "pid > -1" or "pid <> -1" check is not just redundant,
it can never evaluate to false. These leftovers are removed:

* AbstractItemProvider added "AND pid <> -1" to every foreign_table
  query of a table with rootLevel = -1, among them sys_category,
  sys_file_reference and sys_redirect.
* Clipboard::getLocalizations() added "AND pid > -1", although the
  query already applies WorkspaceRestriction.
* DataHandler::getUniqueCountStatement() added "AND pid >= 0" when
  evaluating a unique value for a record on the root level. The
  behaviour is unchanged, such values stay unique across all pages.
* DataHandler::workspaceAllowAutoCreation() returned early for a
  negative "$recpid". Its only caller passes the "pid" read from
  the database, so the check can no longer trigger. The argument
  itself is kept to not change the method signature.
* WorkspaceService selected "A.pid" next to "B.pid", a relic of the
  time when the version had no usable pid of its own.

The remaining changes are wording only: comments that still
describe the removed move placeholder now speak of the move
pointer, and comments in EXT:lowlevel and BackendUtility no longer
explain an offline version as a record with "pid = -1".

Left untouched are the unrelated places where a negative pid is a
command argument meaning "insert after the record with this uid",
the "no page selected" marker of EXT:impexp and the "$event_pid"
default of the sys_log API.

Review

  • Code review CR +2 Done
    • Benni Mack +2
  • Verified V +2 Done
    • Benni Mack +2
    • core-ci +1 CI

Issues 1

Files 6

Review log 34

  1. Benni Mack commented on patch set 1 09/03/26, 18:46

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 09/03/26, 18:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107770

  3. Benni Mack voted on patch set 1 CR +2 V +2 09/03/26, 19:02

  4. Benni Mack merged patch set 2 09/03/26, 19:02