gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.31k stars 279 forks source link

PHP notices in findLike() and makeSQLFromConditions() #671

Closed krisives closed 6 years ago

krisives commented 6 years ago

Using RedBean 4.3 in an existing application and we get this PHP notice:

PHP Warning:  count(): Parameter must be an array or an object that implements Countable in vendor/gabordemooij/redbean/RedBeanPHP/Finder.php on line 242
PHP Warning:  count(): Parameter must be an array or an object that implements Countable in vendor/gabordemooij/redbean/RedBeanPHP/QueryWriter/AQueryWriter.php on line 335

Which appears to be:

if ( !count( $condition ) ) unset( $conditions[$key] );

and

if ( !count( $values ) ) continue;

Thank you for all your hide work @gabordemooij please let me know if I should make a PR to fix this and if RedBean 4.3 can even have changes applied to it or if we should consider upgrading to 5.x. You rock!

gabordemooij commented 6 years ago

As far as I can see these issues have been fixed in version 5. I recommend to upgrade to version 5. Note that although it's a major version, it should be fully backward compatible.

Please keep me informed if you encounter any issues.

krisives commented 6 years ago

How will RedBean 5.x handle the existing data with charset utf8mb4_unicode_ci since the new version uses utf8mb4_unicode_520_ci ?

jreklund commented 6 years ago

It will only changes your tables if you don't have RedBeanPHP set with R::freeze( TRUE );. And it will also keep your data intact if you are upgrading. It's a newer standard on how it compares characters and sort it a different (more correct) way in some languages.

krisives commented 6 years ago

Thanks @jreklund I will upgrade to 5.x soon. I will report any problems I have as a new issue if they arise.