Project

General

Profile

Actions

Bug #103611

closed

Use WorkspaceRestriction in BackendUtility only if workspace is loaded

Added by Sven Wappler 7 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Workspaces
Target version:
Start date:
2024-04-11
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
backendutility workspace
Complexity:
Is Regression:
Sprint Focus:

Description

The function getRecordLocalization throws an error, because WorkspaceRestriction:class is called, even workspace module isn't loaded. Please add a check before.

            $queryBuilder->getRestrictions()
                ->removeAll()
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
                ->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, static::getBackendUserAuthentication()->workspace));
Actions #1

Updated by Garvin Hicking 4 months ago

  • Status changed from New to Needs Feedback

Hi Sven,

for reference, this has also been discussed on Slack:

https://typo3.slack.com/archives/C025BQLFA/p1720711083726809
https://typo3.slack.com/archives/C025BQLFA/p1720713925738489
https://typo3.slack.com/archives/C025BQLFA/p1720705380157669

It seems that getRecordLocalization runs into this error is called from a context where a valid BE_USER object is missing.

Could you tell in which case you get the error specifically, ideally a stacktrace?

If it's done within CLI Context, please ensure to create/initialize the BE_USER before using functionality that accesses getRecordLocalization (i.e. if you use the DataHandler).

In "normal" backend context, the Backend Bootstrap should already take care of initializing the BE_USER. If you get the error there, could you tell in which case this happens?

Now for the most problematic use case: If you use this method in the Frontend (FE) context, this is behaviour the Core does not want to promote. So while the Workspace-Restriction could be gated with a check here, possible future other side errors can easily happen, because you would using BE functionality in a context that is not meant for it. In FE context, retrieval of records should probably better be done with custom QueryBuilder methods, or the PageRepository or Extbase models or the Core might need to create a new interface for this (i.e. via ContentBlocks, if you're accessing tt_content data). But also for that use case, maybe we could discuss the goals here to see what is the best route to take.

TL;DR: Just adding a check on "is the workspace extension installed" would hide a symptom, but not the root cause of a problematic utilization of BE methods.

Thanks for your time!

Actions #2

Updated by Garvin Hicking 4 months ago

  • Category set to Workspaces
  • Status changed from Needs Feedback to Closed

Closing for now due to lack of feedback. Feel free to get in touch if we can elaborate more on this!

Actions

Also available in: Atom PDF