Project

General

Profile

Actions

Task #99655

open

Backend: Set correct Site in site attribute of request when the current request has sufficient contextual information

Added by Philipp Wrann almost 2 years ago. Updated almost 2 years ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Start date:
2023-01-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

With the introduction of the site-config we added more and more multisite-specific features, that are configured in the site-config.

This works perfectly for the frontend. But when you rely on the site-config in the backend, you will need to add a middleware, that sets an internal site attribute for various backend routes. Otherwise you will often just have a NullSite, which is useless.

An example would be: You implement an api and each site has its own credentials because the site should only have access to a subset of data. So you configure the credentials in the site-config. But if you need to add some backend-features, that needs those credentials, you will often need to determine the rootpage by grabbing some id from the current queryParams and then retrieving the site-config from the rootpage id.

In my opinnion the site-config should be available whenever possible.

for example - it is possible to determine the site and set it as attribute when:

- you edit the site config itself
- you edit any tca record located inside the page-tree
- on any view you have relation to a page uid

At the moment i need to add a middleware for each extension, that makes extensive use of the site configuration.

Unfortunately i did not test the behaviour in V11, so i need to tag the typo3 version to 10. Once i can confirm this still exists in V11/V12, i can update this issue.

Update

This is still valid for V11/V12.

Actions #1

Updated by Chris Müller almost 2 years ago

  • Status changed from New to Needs Feedback
Actions #2

Updated by Philipp Wrann almost 2 years ago

  • Subject changed from set site attribute to request in the backend whenever possible to Backend: Set correct Site as site attribute in request whenever possible
  • Description updated (diff)

Yes, the attribute exists but it contains a NullSite most of the time, which is totally useless. I updated the question, so it is more clear, what i want. thank you.

Actions #3

Updated by Philipp Wrann almost 2 years ago

  • Subject changed from Backend: Set correct Site as site attribute in request whenever possible to Backend: Set correct Site in site attribute of request when the current request has sufficient contextual information
  • Description updated (diff)
  • TYPO3 Version changed from 10 to 12

As you can see here (https://github.com/TYPO3/typo3/blob/main/typo3/sysext/backend/Classes/Middleware/SiteResolver.php), typo3 will store the correct site only if the id parameter exists.

If you edit a content element inside the page tree the URL will not contain a id and the site wont be available. So if you need to access some site configuration values to generate your form-engine additions, you need to load the site-configuration by doing the following:

1) parse the returnUrl Param and extract the id parameter
2) load the siteconfig by using that id parameter (from now on you do the same thing the SiteResolver would do)

The following routes are generally affected by this issue.

record/edit
module/site/configuration
ajax/record/inline

In my opinion its very common to store certain config (things, that should not be the same for all sites) in the site-configuration.

Actions

Also available in: Atom PDF