Page MenuHomeIn-Portal Phabricator

INP-1380 - Use named parameters in error messages and add new parameter {field}
ClosedPublic

Authored by glebs on Sep 19 2014, 2:36 AM.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

glebs updated this revision to Diff 4.Sep 19 2014, 2:36 AM
glebs retitled this revision from to Use named parameters in error messages and add new parameter {field}.
glebs updated this object.
glebs edited the test plan for this revision. (Show Details)
glebs added 1 JIRA issue(s): INP-1380.
glebs added a reviewer: alex.
alex requested changes to this revision.Sep 19 2014, 3:24 AM
alex edited edge metadata.

Also please replace %s in all error messages that are affected by named error parameter introduction to corresponding named parameters in /core/install/upgrades.sql for 5.2.2-B1 version. Don't forget to update /core/install/english.lang as well.

core/kernel/utility/validator.php
211

The array declaration isn't fixed to match coding standard.

261

The parameter name should be max_value to be consistent with other parameter names.

442

There is dedicated $this->Application->Phrase method that should be used to translate a phrase.

445

Rename to $replacement_count to add more clarity.

453

Since introduced {field} parameter isn't currently used anywhere we put vsprintf function call into situation where we always have 1 more parameter given, then %s in the actual error message.

Please verify that this doesn't cause vsprintf to return empty string or trigger a warning. If it does, then we should just remove $msg and don't use vsprintf.

This revision now requires changes to proceed.Sep 19 2014, 3:24 AM
alex edited the test plan for this revision. (Show Details)Sep 19 2014, 4:09 AM
alex edited edge metadata.
glebs updated this revision to Diff 5.Sep 19 2014, 5:07 AM
glebs edited edge metadata.

fix by Alex's comments

alex edited edge metadata.Sep 19 2014, 5:44 AM
alex set the repository for this revision to rINP In-Portal.
alex requested changes to this revision.Sep 19 2014, 5:48 AM
alex edited edge metadata.
alex added inline comments.
core/install/upgrades.sql
2914–2924

Please remove any unnecessary trailing whitespaces:

  • after UPDATE word
  • after SET word
  • after =

I believe phpMyAdmin causes that bad looking SQL formatting.

core/kernel/utility/validator.php
50

The $params should be used here to make use of newly added {field} parameter as last %s.

This revision now requires changes to proceed.Sep 19 2014, 5:48 AM
glebs updated this revision to Diff 6.Sep 19 2014, 9:21 AM
glebs edited edge metadata.

Fix Alex's notes

alex requested changes to this revision.Sep 19 2014, 9:51 AM
alex edited edge metadata.
alex added inline comments.
core/kernel/utility/validator.php
445–450

Now, when we are not calling vsprintf at the end the parameter unsetting code isn't needed anymore. Same goes for replacement count tracking code.

This revision now requires changes to proceed.Sep 19 2014, 9:51 AM
glebs updated this revision to Diff 7.Sep 19 2014, 9:56 AM
glebs edited edge metadata.

remove unused code to detect replaces count

alex edited edge metadata.Sep 19 2014, 10:03 AM
alex set the repository for this revision to rINP In-Portal.
alex accepted this revision.Sep 19 2014, 10:07 AM
alex edited edge metadata.
This revision is now accepted and ready to land.Sep 19 2014, 10:07 AM
alex edited edge metadata.Sep 19 2014, 10:18 AM
alex changed the visibility from "All Users" to "Public (No Login Required)".
alex removed rINP In-Portal as the repository for this revision.Sep 24 2014, 3:40 AM
glebs closed this revision.Sep 24 2014, 6:08 AM
alex reopened this revision.Oct 18 2014, 2:27 AM
alex added inline comments.
core/kernel/utility/validator.php
441

We need to allow changing this via unit config as well. Here is what needs to be done:

$field_options = $this->dataSource->GetFieldOptions($field);

if ( $this->Application->isAdmin ) {
	$field_phrase = !empty($field_options['admin_label']) ? $field_options['admin_label'] : 'la_fld_' . $field;
}
else {
	$field_phrase = !empty($field_options['front_label']) ? $field_options['front_label'] : 'lu_fld_' . $field;
}

Theoretically this would allow to override corresponding phrase in unit config.

This revision is now accepted and ready to land.Oct 18 2014, 2:27 AM
alex requested changes to this revision.Oct 18 2014, 2:27 AM
alex edited edge metadata.
This revision now requires changes to proceed.Oct 18 2014, 2:27 AM
glebs updated this revision to Diff 21.Oct 19 2014, 1:55 AM
glebs edited edge metadata.

change field name in validation message via unit config

alex requested changes to this revision.Oct 19 2014, 3:42 AM
alex edited edge metadata.

By uploading patch that only has uncommited changes you've wiped out all other changes in this Differential Revision. Please reupload patch that has all pieces together: commited and uncommited.

To do so I:

  1. checkout SVN revision of a project prior to time, when patch was applied
  2. apply existing patch
  3. make changes
  4. create new patch
This revision now requires changes to proceed.Oct 19 2014, 3:42 AM
glebs updated this revision to Diff 22.Oct 19 2014, 8:28 AM
glebs edited edge metadata.

change field name in validation message via unit config - full patch

alex accepted this revision.Oct 19 2014, 9:04 AM
alex edited edge metadata.
This revision is now accepted and ready to land.Oct 19 2014, 9:04 AM
alex requested changes to this revision.Oct 30 2014, 12:21 PM
alex edited edge metadata.

Please also update FormSubmissionsEventHandler::OnBuildFormFields method to include following lines in the cycle that creates form field configuration:

$field_options['front_label'] = $options['FieldLabel'];
$field_options['admin_label'] = $options['Prompt'];

Make sure it works.

This revision now requires changes to proceed.Oct 30 2014, 12:21 PM
glebs updated this revision to Diff 52.Nov 3 2014, 1:26 PM
glebs edited edge metadata.

update FormSubmissionsEventHandler::OnBuildFormFields

alex accepted this revision.Nov 3 2014, 3:08 PM
alex edited edge metadata.
This revision is now accepted and ready to land.Nov 3 2014, 3:08 PM
alex closed this revision.Nov 18 2014, 4:15 AM
alex added a comment.Nov 23 2014, 3:10 AM

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

alex retitled this revision 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}.Dec 7 2014, 3:28 PM
alex edited edge metadata.
alex set the repository for this revision to rINP In-Portal.Dec 7 2014, 3:43 PM
alex edited the test plan for this revision. (Show Details)Mar 10 2016, 6:18 AM
alex added a project: Restricted Project.