Skip to content

Conversation

@sbuerk
Copy link
Member

@sbuerk sbuerk commented Dec 18, 2025

Following issue has been reported by a user of the extension:

Core: Exception handler (WEB): Uncaught TYPO3 Exception:
  WebVision\DeeplWrite\Domain\Enum\RephraseSupportedDeepLLanguage::tryFrom():
  Argument #1 ($language) must be of type string, null given, called in
  vendor/web-vision/deepl-write/Classes/Service/LanguageService.php
  on line 18 | TypeError thrown in file
  vendor/web-vision/deepl-write/Classes/Domain/Enum/RephraseSupportedDeepLLanguage.php
  in line 59.

Core: Error handler (BE): PHP Warning: Undefined array key "deeplWriteLanguage"
  in vendor/web-vision/deepl-write/Classes/Service/LanguageService.php
  line 16

In case the language configuration in the SiteConfig has not been
done yet the array key does not exists and the current code tries
to access the array with a key not existing in the array, honered
with the above error and exception.

The array access is now guarded using null-coalsce fallback in
the LangaugeService and also ensuring that the result is really
a string, falling back to an empty string and mitigates the issue.

Functional tests have been added to cover the LanguageService
and one test specifically added for the above mentioned issue
failes if the change to fix the issue is reverted.

Important

Functional test infrastructure for this package not in place
yet and not active in github action workflow. Will be done
in a dedicated change. However, added tests works using the
functional test of the private deepltranslate root development
setup (internally).

Following issue has been reported by a user of the extension:

```
Core: Exception handler (WEB): Uncaught TYPO3 Exception:
  WebVision\DeeplWrite\Domain\Enum\RephraseSupportedDeepLLanguage::tryFrom():
  Argument #1 ($language) must be of type string, null given, called in
  vendor/web-vision/deepl-write/Classes/Service/LanguageService.php
  on line 18 | TypeError thrown in file
  vendor/web-vision/deepl-write/Classes/Domain/Enum/RephraseSupportedDeepLLanguage.php
  in line 59.

Core: Error handler (BE): PHP Warning: Undefined array key "deeplWriteLanguage"
  in vendor/web-vision/deepl-write/Classes/Service/LanguageService.php
  line 16
```

In case the language configuration in the SiteConfig has not been
done yet the array key does not exists and the current code tries
to access the array with a key not existing in the array, honered
with the above error and exception.

The array access is now guarded using `null-coalsce` fallback in
the `LangaugeService` and also ensuring that the result is really
a string, falling back to an empty string and mitigates the issue.

Functional tests have been added to cover the `LanguageService`
and one test specifically added for the above mentioned issue
failes if the change to fix the issue is reverted.

> [!IMPORTANT]
> Functional test infrastructure for this package not in place
> yet and not active in github action workflow. Will be done
> in a dedicated change.  However, added tests works using the
> functional test of the private deepltranslate root development
> setup (internally).
@sbuerk sbuerk merged commit e717b62 into main Dec 18, 2025
2 checks passed
@sbuerk sbuerk deleted the dpl-151-guard-array-key-access-in-language-service branch December 18, 2025 13:31
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.

3 participants