Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1181848
D293.id780.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
Tue, Oct 14, 9:41 AM
Size
3 KB
Mime Type
text/x-diff
Expires
Wed, Oct 15, 9:41 AM (8 h, 15 m)
Engine
blob
Format
Raw Data
Handle
767330
Attached To
D293: INP-1688 - Support both "%s" and "{param_name}" in validation error messages
D293.id780.diff
View Options
Index: branches/5.2.x/core/install/english.lang
===================================================================
--- branches/5.2.x/core/install/english.lang
+++ branches/5.2.x/core/install/english.lang
@@ -294,7 +294,7 @@
<PHRASE Label="la_error_UserBanned" Module="Core" Type="1">VXNlciBCYW5uZWQ=</PHRASE>
<PHRASE Label="LA_ERROR_USERNOTFOUND" Module="Core" Type="1">dXNlciBub3QgZm91bmQ=</PHRASE>
<PHRASE Label="la_error_YouMustSelectOnlyOneUser" Module="Core" Type="1">WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI=</PHRASE>
- <PHRASE Label="la_err_bad_date_format" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICglcykgZXguICglcyk=</PHRASE>
+ <PHRASE Label="la_err_bad_date_format" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICh7Zm9ybWF0fSkgZXguICh7c2FtcGxlfSk=</PHRASE>
<PHRASE Label="la_err_bad_type" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGEgZm9ybWF0LCBwbGVhc2UgdXNlIHt0eXBlfQ==</PHRASE>
<PHRASE Label="la_err_invalid_format" Module="Core" Type="1">SW52YWxpZCBGb3JtYXQ=</PHRASE>
<PHRASE Label="la_err_length_out_of_range" Module="Core" Type="1">RmllbGQgdmFsdWUgbGVuZ3RoIGlzIG91dCBvZiByYW5nZSwgcG9zc2libGUgdmFsdWUgbGVuZ3RoIGZyb20ge21pbl9sZW5ndGh9IHRvIHttYXhfbGVuZ3RofQ==</PHRASE>
Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
--- branches/5.2.x/core/install/upgrades.sql
+++ branches/5.2.x/core/install/upgrades.sql
@@ -2942,3 +2942,7 @@
WHERE `Name` IN ('Core', 'In-Portal');
DELETE FROM CachedUrls;
+
+UPDATE LanguageLabels
+SET l1_Translation = 'Incorrect date format, please use ({format}) ex. ({sample})'
+WHERE PhraseKey = 'LA_ERR_BAD_DATE_FORMAT';
Index: branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
===================================================================
--- branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
+++ branches/5.2.x/core/kernel/utility/formatters/date_formatter.php
@@ -388,7 +388,11 @@
$format = $options['input_format'];
if ($dt_separator) $format = trim($format, $dt_separator);
- $error_params = Array( $this->HumanFormat($format), adodb_date($format), 'value' => $value );
+ $error_params = array(
+ 'format' => $this->HumanFormat($format),
+ 'sample' => adodb_date($format),
+ 'value' => $value,
+ );
$hour = 0;
$minute = 0;
Index: branches/5.2.x/core/kernel/utility/validator.php
===================================================================
--- branches/5.2.x/core/kernel/utility/validator.php
+++ branches/5.2.x/core/kernel/utility/validator.php
@@ -440,15 +440,16 @@
$params = array();
}
- $field_phrase = $this->Application->isAdmin ? 'la_fld_' . $field : 'lu_fld_' . $field;
- $params['field'] = $this->Application->Phrase($field_phrase);
-
- foreach ( $params as $param_name => $param_value ) {
- $msg = str_replace('{' . $param_name . '}', $param_value, $msg, $replacement_count);
+ if ( $params && preg_match('/%[^\s]/', $msg) ) {
+ $msg = vsprintf($msg, array_values($params));
}
+ else {
+ $field_phrase = $this->Application->isAdmin ? 'la_fld_' . $field : 'lu_fld_' . $field;
+ $params['field'] = $this->Application->Phrase($field_phrase);
- if ( strpos($msg, '%s') !== false ) {
- trigger_error('Unexpected "%s" in field "<b>' . $field . '</b>" validation error message (pseudo: "<b>' . $error_pseudo . '</b>") in "<b>' . $this->dataSource->Prefix . '</b>" unit', E_USER_WARNING);
+ foreach ( $params as $param_name => $param_value ) {
+ $msg = str_replace('{' . $param_name . '}', $param_value, $msg);
+ }
}
return $msg;
Event Timeline
Log In to Comment