-
Notifications
You must be signed in to change notification settings - Fork 11k
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
SoftDelete trait throws PHP error with PHP7.2 #22162
Comments
Hey 5.1 is no longer supported. I submitted a PR fixing this for 5.6 |
I thought 5.1 had support for another year still (because of the LTS). 5.5 should also be updated too I think, again, because it's an LTS release. |
Yeah but it can be considered a breaking change for 5.5 |
I don't see how it'd be a breaking change. All of the doc blocks there hint it as an array, it's just not been initialised correctly. If it is a breaking change then the call to |
This shouldn't be affecting 5.5 for what I've tested. We have tests for soft deleting feature (e.g. DatabaseSoftDeletingScopeTest and DatabaseSoftDeletingTraitTest) and the Continuous Integration builds for PHP 7.2 aren't failing: https://travis-ci.org/laravel/framework/builds Note that this same line of This indeed affects Laravel 5.1, but the support for bug fixes have been ended - just security fixes are being accepted. 👍 |
Thanks everyone. |
If 5.1.x is LTS and doesn't support 7.2 then the documentation should reflect that. This page only says PHP >= 5.5.9 (and not PHP >= 5.5.9 < 7.2.0) which means it is promising something that is not being delivered... |
Yes it does because when 5.1 was created PHP 7.2 wasn't even though about 😛 |
I understand that. I'm not suggesting it should support 7.2. Just that releases still being supported should at least tell users which versions of PHP aren't supported. That's not unreasonable. Edit: I'm happy to submit a PR if it'll help. |
I solved by changing "$originalWhereCount = count($query->wheres);" for "$originalWhereCount = is_null($query->wheres) |
we are using Laravel 5.1.46 (LTS), PHP 7.2.4 (project is too large to upgrade) |
You could see about extending the base classes and then using those throughout the project. Since 5.1 is now EOL and won't get any new changes you could also fork the Laravel project and make the changes there, then update you composer.json to use your fork. |
Thank You @EspadaV8 |
Thanks!!! |
Description:
Using the SoftDelete trait on a model when using PHP 7.2 throws an internal error because of the usage of
count
in theSoftDeletingScope
on line 75. The propertyjoins
isn't always an array and results in a call ofcount(null)
.Updating line 92 of
Illuminate/Database/Query/Builder.php
tois enough to stop the error from happening, although it looks like there are multiple other properties in the class that should be updated in a similar way to prevent this error from happening elsewhere.
Steps To Reproduce:
SoftDeletes
count(): Parameter must be an array or an object that implements Countable
The text was updated successfully, but these errors were encountered: