urbantrout / site-language-redirection

TYPO3 Site Language Redirection
9 stars 15 forks source link

Android devices causing TYPO3 error in version 2.1.1 #6

Closed j-lang closed 2 years ago

j-lang commented 4 years ago

After installation of site-language-redirection we noticed two errors:

  1. Android devices are getting an error page, the corresponding error message in backend protocol is: Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1436717338: Unsupported scheme "android-app"; must be any empty string or in the set (http, https) | InvalidArgumentException thrown in file /html/typo3/typo3_src-9.5.11/typo3/sysext/core/Classes/Http/Uri.php in line 641.

  2. Another error message was fount in TYPO3 protocol but there is no further device/browser information in access.log: Core: Exception handler (WEB): Uncaught TYPO3 Exception: preg_match() expects parameter 2 to be string, array given | TypeError thrown in file /html/typo3/typo3conf/ext/site_language_redirection/Classes/Middleware/RedirectionMiddleware.php in line 346

Extensions is configured for: Browser language (HTTP headers)

urbantrout commented 4 years ago

Cannot reproduce. I am using v2.1.1 on a client's site without any problems. Android devices are redirected just fine.

What exact PHP version are you running?

j-lang commented 4 years ago

Version information:

TYPO3 9.5.11 PHP Version 7.2.10

Schweriner commented 4 years ago

I can confirm the same error in the logs - next to 404 error page fetch errors in the log. $userAgent = array_shift($userAgent); L:343 does not make sure, that a string is returned if the $userAgent is a multidimensional array. Changing the return to return is_string($userAgent) && preg_match($this->botPattern, $userAgent); maybe can solve the problem?

urbantrout commented 4 years ago

Thanks @Schweriner for the hint. Could you check if my PR solves the issue? https://github.com/urbantrout/site-language-redirection/pull/10

Schweriner commented 4 years ago

@urbantrout sorry I'm not able to test a redirect based on my browser settings - just had to fix this error. Someone else needs to test if the redirects still work.

j-lang commented 4 years ago

Made patch in /Classes/Middleware/RedirectionMiddleware.php but get still error (1) of first post:

Screenshot_Chrome

urbantrout commented 4 years ago

what is this android-app scheme? never heard of it. are you using this in a web app or native app or something?

urbantrout commented 4 years ago

Or a PWA?

j-lang commented 4 years ago

Samsung Tab S5e or S10+ - Google Chrome, entering URL...

urbantrout commented 4 years ago

Could you send me the link to the test installation again. Via email ;)

marksh commented 4 years ago

We could reproduce the error with a Google Pixel 3, Android 11 when typing the domain name directly in the Google search field at the mobile's desktop. The error occurs only if mobile browser(!) language is same as site default language.

Bildschirmfoto 2020-03-27 um 15 34 04
urbantrout commented 4 years ago

@marksh Thanks for the additional info. I will take a look into it…

erguenyogurtcu commented 4 years ago

Fixed: https://github.com/urbantrout/site-language-redirection/pull/20

urbantrout commented 4 years ago

Can someone check if this branch solves the problem?

https://github.com/urbantrout/site-language-redirection/tree/android-app-scheme

j-lang commented 4 years ago

Great job, now it works! Double checked with version 2.1.1 on repo, after updating of your last changes: // Check if referrer is present and scheme is notandroid-app. if ($normalizedParams->getHttpReferer() && substr($normalizedParams->getHttpReferer(), 0, 11) !== 'android-app') { there is no error when loading.