Page MenuHomePhorge

D25117.1737346273.diff
No OneTemporary

D25117.1737346273.diff

diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -2184,6 +2184,9 @@
* string other than the empty string, integers, and floats are considered
* scalar.
*
+ * Note that booleans are also valid scalars, where false is considered empty,
+ * and true is non-empty since if you cast true to string, it's non-empty.
+ *
* This method raises an exception if passed any other value.
*
* @param Value to test.
@@ -2202,6 +2205,14 @@
return true;
}
+ // Booleans are also valid scalars by PHP. Inventing the opposite can be
+ // too much esoteric and problematic.
+ // false: empty, because casted to string becomes '' (empty)
+ // true: non-empty, because casted to string becomes '1' (non-empty)
+ if ($value === false || $value === true) {
+ return $value;
+ }
+
if (is_object($value)) {
try {
$string = phutil_string_cast($value);

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 20, 04:11 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1112827
Default Alt Text
D25117.1737346273.diff (943 B)

Event Timeline