[BUGFIX] Do not check for pid=-1 when evaluating workspace records 41/61641/8
authorBenni Mack <benni@typo3.org>
Sun, 8 Sep 2019 13:34:52 +0000 (15:34 +0200)
committerSusanne Moog <look@susi.dev>
Wed, 11 Sep 2019 12:44:06 +0000 (14:44 +0200)
commita6363e851bb6bb789434a564fb42133a9c6b00e4
tree71d453cf5a3b45098f24c3564c306b999697d7d6
parente3822a5788297d0340de6e364b044da546dd19cd
[BUGFIX] Do not check for pid=-1 when evaluating workspace records

TYPO3 Core handles the result of database queries in a lot of different
ways to filter out workspace records.

With "versioning support v1" (= without workspaces), the identifier was
usually "pid = -1" to filter out records that should not be displayed in
live results.

With workspaces, there are other, better ways to identify versioned via
the following fields:
- t3ver_state (what kind of versioned record is there)
- t3ver_oid (if the versioned record points to a live record)
- t3ver_wsid (the workspace ID)

The "pid" field was kept as misuse, but fine for most of the database
queries. Since we now have Doctrine DBAL, and Restrictions, the Core
API can now be unified to actually check for "t3ver_oid>0" instead of
"pid<>-1" to identify a versioned record.

All places in TYPO3 Core now does not check for "pid<>-1" anymore for
tables that are workspace-aware.

In the future, it is then possible to get rid of the "pid=-1" value when
writing versioned records, streamlining the API effectively, to find one
proper way to query and write records.

This change does not modify any other places in TYPO3 Core where
Workspace Records are written, but only cleans up the API to only
consider "t3ver_oid" instead of "pid", avoiding the mis-use of "pid".

Most queries can then be handled by simply checking:
- t3ver_wsid=0 AND deleted=0 for only fetching live records
- t3ver_wsid IN (0,12) AND t3ver_oid=0 to find all live records,
  and draft placeholders, to do overlays then

Resolves: #89122
Releases: master
Change-Id: I781d1ae440fe944e6c8c99d02884a6eb0c1be0a7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61641
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Susanne Moog <look@susi.dev>
27 files changed:
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Classes/Form/FormDataProvider/EvaluateDisplayConditions.php
typo3/sysext/backend/Classes/Tree/Repository/PageTreeRepository.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/EvaluateDisplayConditionsTest.php
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/DataHandling/PlainDataResolver.php
typo3/sysext/core/Classes/Database/Query/Restriction/BackendWorkspaceRestriction.php
typo3/sysext/core/Classes/Database/Query/Restriction/FrontendWorkspaceRestriction.php
typo3/sysext/core/Classes/Database/Query/Restriction/WorkspaceRestriction.php
typo3/sysext/core/Classes/Database/RelationHandler.php
typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
typo3/sysext/core/Documentation/Changelog/master/Important-89122-UnifiedEvaluationOfVersionedRecordsInWorkspaces.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/BackendWorkspaceRestrictionTest.php
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendRestrictionContainerTest.php
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendWorkspaceRestrictionTest.php
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/WorkspaceRestrictionTest.php
typo3/sysext/install/Classes/Updates/PopulatePageSlugs.php
typo3/sysext/lowlevel/Classes/Command/MissingRelationsCommand.php
typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php
typo3/sysext/workspaces/Classes/Command/WorkspaceVersionRecordsCommand.php
typo3/sysext/workspaces/Classes/Dependency/ElementEntityProcessor.php
typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
typo3/sysext/workspaces/Classes/Service/WorkspaceService.php