FluidTYPO3 / flux

TYPO3 extension Flux: Dynamic Fluid FlexForms
https://fluidtypo3.org
148 stars 214 forks source link

BUG: Missing site attribute in request with TYPO3 12.4.9 #2145

Open jonakieling opened 6 months ago

jonakieling commented 6 months ago

Hi there,

we encounter an exception with Flux 10.0.8 and TYPO3 12.4.9:

Call to a member function getDefaultLanguage() on null

(null is expected to be a site)

Describe the bug Any use of LocalizationUtility within a Flux template (e.g. f:translate within a configuration section) will lead to the exception.

Additional context

This change in TYPO3 Core uses the request type to decide how to get a locale and uses the requests site attribute for frontend requests: https://github.com/typo3/typo3/commit/490f12697b

This is always creating a frontend request with the site attribute missing: https://github.com/FluidTYPO3/flux/blob/development/Classes/Builder/RequestBuilder.php#L85

To Reproduce Steps to reproduce the behavior:

  1. Install Flux 10.0.8 and TYPO3 12.4.9
  2. Have a provider Extension registered
  3. Create a Flux Element with a f:translate ViewHelper in the configuration section
  4. Load Page module
NamelessCoder commented 6 months ago

Not to dismiss the problem, but: you should not be using f:translate within Configuration sections - ideally you should rely on the automatic building of field labels, or use full label references with LLL:EXT:... syntax. And in general, you should not be using f:translate in anything that runs in backend context.

magicsunday commented 5 months ago

This also fails for TYPO3 v12.4.10, Flux 10.0.9.

ideally you should rely on the automatic building of field labels

What does this mean?

or use full label references with LLL:EXT:...

This fails with the same error.

For instance:

<flux:field.custom name="settings.Banner.description">
    <div class="alert alert-info">
        <v:l key="LLL:EXT:ext_name/Resources/Private/Language/locallang.xlf:flux.Banner.description"/>
    </div>
</flux:field.custom>

And in general, you should not be using f:translate in anything that runs in backend context.

So what is the recommended way to translate the backend? TYPO3 itself uses f:translate too

Gitsko commented 2 months ago

Hi @NamelessCoder ,

do you see another alternative if I want to use a translated element (f:translate) e.g. with a element output a hint box for an editor ?