bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP 8 issue

esurov opened this issue · comments

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;
            }
        }
    }

The 2nd parameter of select is the $filter.. it should be set to NULL instead of an empty array.
Duplicate of #1257