Error when calling endpoint with default language in strict mode

Issue #4 resolved
Rainer Becker created an issue

When I call an endpoint in default language, an error is thrown:
#1644319953 Error

Argument 1 passed to TYPO3\CMS\Core\Site\Entity\Site::getLanguageById() must be of the type int, string given, called in /Users/rainerbecker/GIT/tui-robinson---V9/app/html/typo3conf/ext/nnrestapi/Classes/Controller/ApiController.php on line 61

I think the reason is, that in https://bitbucket.org/99grad-team/nnrestapi/src/90713711c86351535b6cfa7dcdfa5add2dd35219/Classes/Mvc/Request.php#lines-178 a string is returned instead of an integer in case the languageId was found.

Comments (4)

  1. David Bascom

    Thanks for reporting!
    This could have to do with the way the languageId is defined in your site config yaml.
    Could you try replacing line 178 with the following code?

    return intval($languagesByName[$acceptedLanguage]['languageId']) ?? 0;
    

    Does that solve the problem?

  2. Rainer Becker reporter

    Yes, that fixes the problem.
    At least for TYPO3 v9 it seems that the languageId is written to site configuration as string when editing it in the BE and press save.

  3. Log in to comment