-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Str.php #35854
Update Str.php #35854
Conversation
When $haystack is null or is not a string, mb_strpos throws a 500 PHP error. I'm not sure how I got the 500 error, but have three environments in the same server sharing the same database, all running the same app with different subdomains. Session is managed with the files drive, but cache uses the database driver. Two sites run as expected, and the other one wasn't able to handle the request. After checking the PHP error log: [proxy_fcgi:error] [pid 256670] [client 190.104.120.178:59913] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: mb_strpos(): Argument laravel#1 ($haystack) must be of type string, null given, called in /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 177 and defined in /var/www/test2.readforall.com/vendor/symfony/polyfill-mbstring/bootstrap80.php:60\nStack trace:\n#0 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Support/Str.php(177): mb_strpos()\n#1 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php(34): Illuminate\\Support\\Str::contains()\n#2 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(371): Illuminate\\Http\\Request->isJson()\n#3 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(435): Illuminate\\Http\\Request->getInputSource()\n#4 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(64): Illuminate\\Http\\Request::createFromBase()\n#...' And adding the propose change, I was able to run the application as expected.
Add tests for this case, please |
Seems to break the test suite. |
same issue here windows 10 + php 8.0.1 + Laravel Framework 8.21, full stacks: ` #1 E:\Projects\测试项目\admin\vendor\laravel\framework\src\Illuminate\Http\Concerns\InteractsWithContentTypes.php(16): Illuminate\Support\Str::contains(NULL, Array) #2 E:\Projects\测试项目\admin\vendor\laravel\framework\src\Illuminate\Http\Request.php(371): Illuminate\Http\Request->isJson() #3 E:\Projects\测试项目\admin\vendor\laravel\framework\src\Illuminate\Http\Request.php(435): Illuminate\Http\Request->getInputSource() #4 E:\Projects\测试项目\admin\vendor\laravel\framework\src\Illuminate\Http\Request.php(64): Illuminate\Http\Request::createFromBase(Object(Symfony\Component\HttpFoundation\Request)) #5 E:\Projects\测试项目\admin\public\index.php(52): Illuminate\Http\Request::capture() #6 E:\Projects\测试项目\admin\server.php(21): require_once('E:\Projects\\xE6\xB5\x8B...') #7 {main} ` |
Same Here !! |
See symfony/polyfill#329. In the meanwhile, you can work around this by downgrading to PHP 7.4.14, or installing ext-mbstring on PHP 8.0.1. |
When $haystack is null or is not a string, mb_strpos throws a 500 PHP error. I'm not sure how I got the 500 error, but have three environments in the same server sharing the same database, all running the same app with different subdomains. Session is managed with the files drive, but cache uses the database driver. Two sites run as expected, and the other one wasn't able to handle the request. After checking the PHP error log:
[proxy_fcgi:error] [pid 256670] [client 190.104.120.178:59913] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: mb_strpos(): Argument #1 ($haystack) must be of type string, null given, called in /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 177 and defined in /var/www/test2.readforall.com/vendor/symfony/polyfill-mbstring/bootstrap80.php:60\nStack trace:\n#0 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Support/Str.php(177): mb_strpos()\n#1 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php(34): Illuminate\Support\Str::contains()\n#2 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(371): Illuminate\Http\Request->isJson()\n#3 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(435): Illuminate\Http\Request->getInputSource()\n#4 /var/www/test2.readforall.com/vendor/laravel/framework/src/Illuminate/Http/Request.php(64): Illuminate\Http\Request::createFromBase()\n#...'
And adding the propose change, I was able to run the application as expected.