Bug #51385

BooleanConverter considers "false" TRUE

Added by Bastian Waidelich almost 2 years ago. Updated about 1 year ago.

Status:Resolved Start date:2013-08-27
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:Property
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:Git master

Description

The BooleanConverter provided by Flow simply casts the $source to a boolean using boxing:

1return (boolean)$source;

This leads to some weird inconsistencies, e.g. the string "false" returning TRUE.


Related issues

related to TYPO3.Flow - Bug #59023: BooleanConverter should not convert empty values to boolean New 2014-05-22
duplicated by TYPO3.Flow - Bug #51255: CommandController: Fix parsing of boolean values Resolved 2013-08-22

Associated revisions

Revision 8207a130
Added by Bastian Waidelich almost 2 years ago

[BUGFIX] BooleanConverter considers "false" TRUE

The BooleanConverter provided by Flow simply casts the $source
to a boolean using boxing.
With this change a string "false" (case insensitive) is considered FALSE.

Change-Id: I95ba005490fb158a17b6b7fe3dc1787d96939299
Releases: master, 2.0
Fixes: #51255
Fixes: #51385

Revision 90d745a0
Added by Bastian Waidelich over 1 year ago

[BUGFIX] BooleanConverter considers "false" TRUE

The BooleanConverter provided by Flow simply casts the $source
to a boolean using boxing.
With this change a string "false" (case insensitive) is considered FALSE.

Change-Id: I95ba005490fb158a17b6b7fe3dc1787d96939299
Releases: master, 2.0
Fixes: #51255
Fixes: #51385

History

#1 Updated by Gerrit Code Review almost 2 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/23355

#2 Updated by Timo Dödtmann almost 2 years ago

The documentation (http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/CommandLine.html#passing-arguments) says following:
Possible values equivalent to TRUE are: on, 1, y, yes, true. Possible values equivalent to FALSE are: off, 0, n, no, false.

So, it must be something like that:
  • check (exactly) possible TRUE values (so, you can see FALSE as a fallback)
    if (is_bool($source)) {
        return $source;
    }
    return (!empty($source) && in_array(strtolower($source), array('on', '1', 'y', 'yes', 'true')));
    
  • check (exactly) possible FALSE values (so, you can see TRUE as a fallback)
    if (is_bool($source)) {
        return $source;
    }
    return (!empty($source) && !in_array(strtolower($source), array('off', '0', 'n', 'no', 'false')));
    

#3 Updated by Gerrit Code Review almost 2 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/23355

#4 Updated by Bastian Waidelich almost 2 years ago

Timo Dödtmann wrote:

The documentation (http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/CommandLine.html#passing-arguments) says following:
Possible values equivalent to TRUE are: on, 1, y, yes, true. Possible values equivalent to FALSE are: off, 0, n, no, false.

good point. See PS#2 at https://review.typo3.org/23355 and feel free to test/vote for the patch

#5 Updated by Bastian Waidelich almost 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#6 Updated by Gerrit Code Review over 1 year ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 2.0 of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/27205

#7 Updated by Bastian Waidelich about 1 year ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF