bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

PHP 8 issue #1221

Closed esurov closed 2 years ago

esurov commented 3 years ago

On our attempt to migrate to PHP8 we found out an issue with DB\SQL\Mapper: It throws an error Undefined array key 0 on fatfree/lib/db/sql/mapper.php:230:

list($filter)=$filter;

Here's the complete code snippet:

    class mobile_device extends OW_Object {
        static protected $tableName  = 'mobile_device';
        static protected $primaryKey = 'mobile_device_id';

        public function loadToSession() {
            $modelKey = 'model';
            $myLookupTable = static::getMapper();
            $records = $myLookupTable->select($modelKey, [], array('order' => $modelKey, 'group' => $modelKey));
            foreach($records as $record) {
                $_SESSION['mobile_device_unique'][$record->$modelKey] = $record->$modelKey;
            }
        }
    }
ikkez commented 2 years ago

The 2nd parameter of select is the $filter.. it should be set to NULL instead of an empty array. Duplicate of https://github.com/bcosca/fatfree/issues/1257