Skip to content

Commit

Permalink
[BUG] Fix detection of "draft records" in workspaces
Browse files Browse the repository at this point in the history
Also consider "modified placeholder records" as draft records to avoid them
being indexed and also to avoid exceptions in the backend (PHP 8) in the
garbage collector.

Resolves #3641
  • Loading branch information
baschny authored and dkd-kaehm committed Sep 15, 2023
1 parent 770f1e6 commit 282d0d2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ public static function isDraftRecord(string $table, int $uid): bool
$isWorkspaceRecord = false;

if ((ExtensionManagementUtility::isLoaded('workspaces')) && (BackendUtility::isTableWorkspaceEnabled($table))) {
$record = BackendUtility::getRecord($table, $uid, 'pid, t3ver_state');

if ($record !== null && ($record['pid'] == '-1' || $record['t3ver_state'] > 0)) {
$record = BackendUtility::getRecord($table, $uid, 'pid, t3ver_state, t3ver_oid');

// \TYPO3\CMS\Core\Versioning\VersionState for an explanation of the t3ver_state field
// if it is >0, it is a draft record or
// if it is "0" (DEFAULT_STATE), could also be draft if t3ver_oid points to any uid (modified record)
if ($record !== null &&
($record['pid'] == '-1' || $record['t3ver_state'] > 0 || (int)$record['t3ver_oid'] > 0)
) {
$isWorkspaceRecord = true;
}
}
Expand Down

0 comments on commit 282d0d2

Please sign in to comment.