Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Handle deleted workspace records #3427

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jschlier
Copy link
Contributor

What this pr does

This pull request handles deleted records when checking if the changed record is part of a workspace.

How to test

Delete a record with workspaces enabled.

Fixes: #3413

@jschlier
Copy link
Contributor Author

jschlier commented Dec 20, 2022

I may not fully understand in which cases this function is used, but I think that deleted records should be checked as well.
A simple check if the $record is null before accessing the array keys could also be sufficient, but this leads to deleted records from a workspace as being return as "live" records (should be the same behaviour as before with PHP < 8).

Since this only happens when records are deleted it probably does not add any unwanted behaviour - except possibly a call to Solr to delete a record that is not indexed - but checking the deleted record anyway is cleaner in my opinion.

@froemken
Copy link
Contributor

froemken commented Feb 2, 2023

Can someone please restart the tests? It's not possible to see whats wrong with this patch.

@dkd-kaehm
Copy link
Collaborator

@froemken
Rebased to current main state, which starts the build.

Classes/Util.php Outdated
@@ -114,7 +114,7 @@ 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');
$record = BackendUtility::getRecord($table, $uid, 'pid, t3ver_state', '', false);

if ($record['pid'] == '-1' || $record['t3ver_state'] > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Officially getRecord() can return either array or null. This patch works, but I would prefer to check for array first, before accessing the array keys.

@jschlier
Copy link
Contributor Author

Sorry, I lost track of this PR.

The new version of the main branch already includes a null check in the following IF statement.

This could be merged then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] PHP Warning Trying to access array offset on value of type null in Util.php
3 participants