yiisoft / yii

Yii PHP Framework 1.1.x
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
4.84k stars 2.28k forks source link

PHP 8.1 support for active checkbox list #4478

Closed csears123 closed 2 years ago

csears123 commented 2 years ago

In PHP 8.1 I am receiving the error below when using CActiveForm checkbox field, when the CFormModel model attribute has a default 'null' value as defined.

"strcmp(): Passing null to parameter #2 ($string2) of type string is deprecated"

The 'null' value is passed to the checkBoxList() method as the second argument variable $select. A null value is not allowed in PHP 8.1 in strcmp(). An additional condition check for !empty() on the $select variable will prevent this error, as well as support the remaining variable types for a string or array.

Q A
Is bugfix? ✔️/❌
New feature? ✔️/❌
Breaks BC? ✔️/❌
Tests pass? ✔️/❌
Fixed issues comma-separated list of tickets # fixed by the PR, if any