fatfree icon indicating copy to clipboard operation
fatfree copied to clipboard

Mapper->load() fails if the first parameter is an empty array

Open paolobertani opened this issue 2 years ago • 2 comments

Mapper->load() calls stringyfy() passing the filter

on line 225 of db/sql/mapper.php

if (is_array($filter) )

doesn't check if $filter is an empty array. In that case the function produces an error trying to access $filter[0]

I suggest to change with

if (is_array($filter) && count($filter)>0)

paolobertani avatar Jun 24 '22 13:06 paolobertani

You should pass null, if the filter is otherwise empty.

Because that's what's used if you specify nothing at all in the parens.

pauljherring avatar Jun 24 '22 14:06 pauljherring

yes, off course

I just wonder if it's enought clear from the documentation

I think an empty array should be allowed as well to specify that no filter have to be applied, just as passing null or an empty string.

paolobertani avatar Jun 24 '22 14:06 paolobertani