[TYPO3-core] RFC #4272: Inconsistent return values of ini_get() produce false positives for safe_mode detection

Peter Beernink p.beernink at drecomm.nl
Thu Oct 7 10:05:36 CEST 2010


On 4-10-2010 10:39, Christian Futterlieb wrote:
> [...]
>
> The method getIniValueBoolean() does not return correct values (as
> expected). ini_get() could return empty strings, when a option has a
> null value. In this case filter_var() returns NULL instead of FALSE.
>
> // without save_mode set in php.ini
> var_dump(ini_get('safe_mode'));
> var_dump(filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN,
> FILTER_REQUIRE_SCALAR | FILTER_NULL_ON_FAILURE));
>
> string(0) ""
> NULL
>
> Of course this return value could be used in conditions (read: the patch
> does what it looks like). But due to the method name I'd expect FALSE,
> except when ini_get() returns "1", "true", "on" or "yes".
>
> Sorry again for the angry 'It does not work'. Maybe it's nitpicking, but
> I like it to count on clear return values.
>
> Regards, Christian

Point taken. I'll have a look on how PHP specifies the behaviour on an 
empty string / NULL value. If PHP interprets this as FALSE, I'll change 
the functions to only return TRUE or FALSE.

Peter



More information about the TYPO3-team-core mailing list