gabordemooij / redbean

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

Null input to trim() deprecated on PHP 8.1 #895

Closed neyre closed 2 years ago

neyre commented 2 years ago

Getting the following error when doing anything on PHP 8.1.4, redbean version 5.7.1.

Internal Server Error
trim(): Passing null to parameter #1 ($string) of type string is deprecated

I was able to fix it by replacing: if ( trim( $sql ) === '' ) { with: if ( is_null($sql) || trim( $sql ) === '' ) { in the main glueSQLCondition function within the main redbean php file, line 6191.

Fix credit from closed issue here: https://github.com/gabordemooij/redbean/issues/871#issuecomment-1042222561

gabordemooij commented 2 years ago

Yep, another 8.1 compatibility issue probably, I will look into this. Thanks for reporting.

gabordemooij commented 2 years ago

Seems to have already been fixed in 5.7.2?

neyre commented 2 years ago

Yep, looks fixed in 5.7.2. Thanks!