Use named parameters in error messages and add new parameter {field}

Components

Labels

Description

1. locate "SetError" methods calls in the "kValidator" class, where additional parameters are passed to the error (I found 3)
2. in each found case transform index-based parameter array into associative array by assigning name for each of given parameters
3. in the "GetErrorMsg" method:

  • add "array_values" before giving error params to "vsprintf" function

  • after call to "ReplaceLanguageTags" we need to add "field" parameter to the error parameters, which value would be translation of this phrase: "la_fld_FieldName" (in Admin Console) and "lu_fld_FieldName" (on Front-End)

  • replace all named parameter occurrences in a string (before "la-la {param_name} la-la", after "la-la value_of_param_name_parameter la-la")

  • after named parameter is replaced (check number of actual replacements made) remove it from parameter list

Context Information

None

Additional information (do not use)

None

Activity

Alex November 28, 2016 at 9:26 AM

Closing issues of a released version.

Alex March 10, 2016 at 12:18 PM

alex updated the test plan for D2: - Use named parameters in error messages and add new parameter {field}.
alex added a project to D2: - Use named parameters in error messages and add new parameter {field}: Intechnic: ATV.

Alex December 7, 2014 at 9:43 PM

alex set the repository for D2: - Use named parameters in error messages and add new parameter {field} to rINP In-Portal.

http://qa.in-portal.org/D2

Alex December 7, 2014 at 9:28 PM

alex retitled D2: - Use named parameters in error messages and add new parameter {field}, from "Use named parameters in error messages and add new parameter {field}" to "INP-1380 - Use named parameters in error messages and add new parameter {field}".

http://qa.in-portal.org/D2

Alex November 23, 2014 at 9:10 AM

alex added a comment to D2: Use named parameters in error messages and add new parameter {field}.

Adding comment to create corresponding "Issue Link" from JIRA Issue back to this Differential Revision.

http://qa.in-portal.org/D2

Fixed

Details

Priority

Assignee

Reporter

Developer

Reviewer

Change Log Group

Added

Change Log Message

Patch Instructions

Patches must be submitted through Phabricator.

BC Break Details

  • the "%s", "%1$s" and similar are no longer processed inside error message phrases and cause notice

Solution

In the "kValidator::GetErrorMsg" method, when "$params" (error message params) array:

  • when error message contains "%" that is followed by non-whitespace symbol we execute old code (get from SVN), where "sprintf" was used

  • otherwise execute current code with " {param_name}" replacement

At the end both approach should work, since we're not planning to deprecate "%s" approach in error messages.

Story Points

Fix versions

Created September 18, 2014 at 10:40 AM
Updated December 29, 2024 at 8:57 PM
Resolved August 17, 2016 at 8:25 AM