Skip to content
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

A simple incompability with php 8.1 #1284

Closed
AurelienZulian opened this issue Jan 31, 2022 · 5 comments
Closed

A simple incompability with php 8.1 #1284

AurelienZulian opened this issue Jan 31, 2022 · 5 comments

Comments

@AurelienZulian
Copy link

Hello, i've found an error here :

str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

You'll find the concerned method here : vendor/barryvdh/laravel-debugbar/src/DataCollector/QueryCollector.php

Function name : emulateQuote
Line : 214.

My PHP version is 8.1, this error is due to the recent changes on the acceptance of null values on native PHP methods.

Have a good fix !

@barryvdh
Copy link
Owner

barryvdh commented Feb 1, 2022

Can you create a PR?

@barryvdh
Copy link
Owner

barryvdh commented Feb 1, 2022

What is your input, why is the binding null?

@AurelienZulian
Copy link
Author

Hello,

I don't think I know enough about the project technically to create a pull request.

A first error occurs in QueryCollector.php line 163 because quote method does not allow a null value.
So there is a passage in the Exception and in the emulateQuote that will use the str_replace.

I think it would take a simple nullity check of $binding, soit au niveau de la ligne 160 avec
if ($binding != null && !is_int($binding) && !is_float($binding))

Or at the str_replace line 214, this is also to be confirmed with the behavior before PHP 8.1.
return "'" . str_replace($search, $replace, $value ?? '') . "'";

To answer your question, my input is null following the validation of a form, one of my fields is not mandatory and is empty, so the value remained null.

My input is just an empty textarea, a description that remained null in the form.

Have a good day !

@ankurk91
Copy link
Contributor

ankurk91 commented Feb 8, 2022

I have these error logged into storage/logs folder,

Laravel 8.x with php 8.1

[2022-02-07 06:33:23] local.WARNING: PDO::quote(): Passing null to parameter #1 ($string) of type string is deprecated in /laravel-app/vendor/barryvdh/laravel-debugbar/src/DataCollector/QueryCollector.php on line 163  
[2022-02-07 06:33:23] local.WARNING: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated in /laravel-app/vendor/barryvdh/laravel-debugbar/src/DataFormatter/QueryFormatter.php on line 58  

I have enabled the logger in this way

LOG_DEPRECATIONS_CHANNEL=stack

@barryvdh
Copy link
Owner

barryvdh commented Feb 8, 2022

So bafb390 ?

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

No branches or pull requests

3 participants