-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
PHP 7.2: count(): Parameter must be an array or an object that implements Countable #4167
Comments
@cebe Have you opened an issue against this on https://bugs.php.net/ ? |
this is not a bug, but a feature ;) PHP changed count() behavior in the following RFC: https://wiki.php.net/rfc/counting_non_countables |
How it looks like with upgrade to PHP 7.2 ? |
Not a good idea for now. |
Here are 7.2 compatibility fixes: |
Hello, there are some issues.
There is maybe better solution to create new count (_count for example) function which have behaviour like before 7.2. |
@pajon I have no need to support 5.4, so you are free to add |
Hi Is there any option slove this pblm Please help me with the details |
@manumonviru sizeof is just alias to count function. |
i have same issue with wordpress |
Partly fixed. |
When can you make release 1.1.20 with this fix? |
Hope having it soon. We have 7.2 tests now and these are passing. |
There is another one on framework/gii/generators/model/ModelCode.php:371
|
There is another one on framework/web/CController.php:928
|
@seregagl would you like to fix it and do a pull request? If not, please create a separate issue. Will be lost here in the closed one... |
…nder` and CController::renderDynamic()
There is another issue in CActiveFinder in queryOneMany |
Would you like to send a pull request fixing it? |
I've checked trunk version and it looks it is already fixed with 05d2c67. The latest version 1.1.19 is not. |
When we'll fix the rest of https://github.com/yiisoft/yii/issues |
Please forgive me if this is not the correct issue on which to report problems, but there's at least two places in framework/db/schema/CDbCriteria that got missed:
similarly:
|
|
our application has been using Yii since 2009 and it's worked fine - the methods mentioned in the previous comment have been quite robust at handling various arguments. Sometimes it gets called with empty value, or single (non-array) value; or array with 1 element, or array with multiple elements. The first three cases break now in PHP 7.2 The patches in my previous comment are to make the framework more robust and consistent with previous behavior, so the application code does not have to change. Note that we're running our Dev/Test environment with error_reporting = E_ALL, so the warnings emitted by 7.2 are actually reported as errors. I like this so we can find/fix them now... |
If you pass a scalar value as So I do not see how your code runs fine in other PHP versions < 7.2: https://3v4l.org/nHrpA |
Thank you @cebe and @rob006 for this feedback. I have taken this opportunity to audit all our application code that uses CDbCriteria::addInCondition() and ::addNotInCondition(). All instances except one pass an array as the $value parameter. The one case where a non-array is (sometimes) passed, it's always empty. I will fix the application code in this one case. |
What steps will reproduce the problem?
A lot of tests on PHP 7.2 are failing with
count()
throws a warning since PHP 7.2 in case a scalar or non-countable object is passed. We rely on this behavior in many places so code needs to be adjusted.Need to check how many places are affected and whether its easy to fix. If its hard to fix in a BC way, PHP 7.1 may be the last version that Yii 1.1 runs on.
More info
The text was updated successfully, but these errors were encountered: