Page MenuHomePhorge

D25220.1734637605.diff
No OneTemporary

D25220.1734637605.diff

diff --git a/src/applications/transactions/storage/PhabricatorModularTransactionType.php b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
--- a/src/applications/transactions/storage/PhabricatorModularTransactionType.php
+++ b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
@@ -334,12 +334,28 @@
return $this->getEditor()->getIsNewObject();
}
+ /**
+ * Check whenever a new transaction's value is considered an "empty text"
+ * @param mixed $value A string, null, an integer...
+ * @param array $xactions Transactions
+ */
final protected function isEmptyTextTransaction($value, array $xactions) {
foreach ($xactions as $xaction) {
$value = $xaction->getNewValue();
}
- return !phutil_nonempty_string($value);
+ // The $value can be a lot of stuff, null, string, integer and maybe more.
+ // We cast to string to answer the question "Is this string empty?".
+ // Note: Don't use phutil_nonempty_stringlike() since it was not designed
+ // for integers.
+ // Note: Don't use phutil_nonempty_scalar() since very probably we could
+ // receive a boolean, causing exceptions.
+ // https://we.phorge.it/T15239
+ $value_clean = phutil_string_cast($value);
+
+ // We made our lives easier and we don't need strlen(something)
+ // and we should not.
+ return $value_clean === '';
}
/**

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 19:46 (20 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015452
Default Alt Text
D25220.1734637605.diff (1 KB)

Event Timeline