Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F804088
D287.id776.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:05 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:05 AM (4 h, 56 m)
Engine
blob
Format
Raw Data
Handle
576802
Attached To
D287: INP-1682 - Make "kFormatter::TypeCast" to return "false" when value (not type) is changed
D287.id776.diff
View Options
Index: branches/5.2.x/core/kernel/utility/formatters/formatter.php
===================================================================
--- branches/5.2.x/core/kernel/utility/formatters/formatter.php
+++ branches/5.2.x/core/kernel/utility/formatters/formatter.php
@@ -63,8 +63,6 @@
*/
function TypeCast($value, $options)
{
- $ret = true;
-
if ( isset($options['type']) ) {
$field_type = $options['type'];
@@ -81,20 +79,18 @@
}
$value = $this->formatNumber($value);
- $type_ok = preg_match('#int|integer|double|float|real|numeric|string#', $field_type);
+ $is_numeric_type = preg_match('#int|integer|double|float|real#', $field_type);
- if ( $value != '' && $type_ok ) {
- $ret = is_numeric($value);
+ if ( $value != '' && $is_numeric_type ) {
+ $tc_value = $value;
+ settype($tc_value, $field_type);
- if ($ret) {
- $f = 'is_' . $field_type;
- settype($value, $field_type);
- $ret = $f($value);
- }
+ // Type casing is considered a success only, when type casted value visually looks the same.
+ return (string)$value === (string)$tc_value ? $tc_value : false;
}
}
- return $ret ? $value : false;
+ return $value;
}
/**
Event Timeline
Log In to Comment