Review main Abandoned

54066[BUGFIX] Change empty to isset to let value 0 or false pass through

Łukasz Uznański CR 0 V 0 Easy +1 −1 updated 10/16/17, 14:53

Commit message

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 1516

  1. Łukasz Uznański uploaded patch set 1 09/09/17, 14:19

  2. TYPO3com voted on patch set 1 V +1 09/09/17, 14:35 Completed build in 16m 02s on Sat, 9 Sep, 04:35 PM Test Summary: 58140 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-14682

  3. Stefan Neufeind voted on patch set 1 CR +1 09/09/17, 16:55

  4. Wouter Wolters voted on patch set 1 CR +1 09/09/17, 17:29

  5. Jan Helke voted on patch set 1 CR +1 V +1 09/09/17, 18:21

  6. Ralf Zimmermann voted on patch set 1 CR +1 09/10/17, 13:33

  7. Jan Stockfisch voted on patch set 1 CR +1 09/11/17, 07:48

  8. Sascha Rademacher voted on patch set 1 CR +1 09/11/17, 07:50

  9. Jörg Bösche voted on patch set 1 CR +1 09/18/17, 07:55

  10. Susi Moog commented on patch set 1 CR -1 09/20/17, 08:52

    For reference: $var0 = null; $var1 = ''; $var2 = 0; $var3 = 'foo'; var_dump(isset($var0)); // false var_dump(isset($var1)); // true var_dump(isset($var2)); // true var_dump(isset($var3)); // true

    AbstractFinisher.php:222

    I don't think this works. If $optionValue is now anything BUT null the condition will evaluate to true. Meaning every set option will be overwritten by its' default. Additionally the TranslationService one line up will always return a string ... in the case of the attachUploads from the issue it will return an empty string, but still a string - which means isset($optionValue) can never be false.
  11. Susi Moog commented on patch set 1 09/20/17, 08:58

    AbstractFinisher.php:222 Reply

    (or at least will return a set value)
  12. Jan Helke voted on patch set 1 V 0 09/20/17, 09:11

  13. Ralf Zimmermann voted on patch set 1 CR -1 09/20/17, 09:12

  14. Claus Due commented on patch set 1 09/20/17, 09:55

    AbstractFinisher.php:222 Reply

    Normally if we really want to allow "0" as value we use two checks: - empty() - and comparison to "0" explicitly One way could be: empty($optionValue) && (string)$optionValue !== '0' But reading this it kind of looks like the intention is that only null and perhaps false should cause the $defaultValue to be used, so perhaps explicitly checking those plus empty string as positive match is better? $optionValue === null || $optionValue === false || (string)$optionValue === '' // then use $defaultValue
  15. Susi Moog commented on patch set 1 09/20/17, 10:00

    AbstractFinisher.php:222 Reply

    as long as we don't also touch the TranslationService above and stop that from changing the value this check is probably too late for fixing the behaviour.
  16. Susi Moog abandoned the change 10/16/17, 14:53

    abandoned in favor of https://review.typo3.org/#/c/54226/ which tackles the same issue.