The viewElements method of the DefaultNumberFormatter.php class contains references to the $instance variable which is simply not initialized. We'll want tests for this as well.

This is also visible in the change record, which is just wrong: https://drupal.org/node/1805846

Comments

plopesc’s picture

Assigned: Unassigned » plopesc
StatusFileSize
new4.34 KB
new2.68 KB

Hello,
Attaching patch that depends on field settings instead of $instance deprecated property.
Patch includes tests for prefix and suffix settings.

Regards

plopesc’s picture

Status: Active » Needs review

Changing status

yched’s picture

Status: Needs review » Needs work

Looks great, thanks @plopesc !

Minor nitpicks:

+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.phpundefined
@@ -170,16 +170,43 @@ function testNumberIntegerField() {
+    //Add prefix and suffix for the newly-created field

Missing space after //, and a trailing point.

+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.phpundefined
@@ -170,16 +170,43 @@ function testNumberIntegerField() {
     // Set the formatter to "number_integer" and to "unformatted", and just
     // check that the settings summary does not generate warnings.

Order of formatters should be reverted in the comment.

+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.phpundefined
@@ -170,16 +170,43 @@ function testNumberIntegerField() {
+    // Set display prefix and suffix properties to true.
+    $this->drupalPostAJAX(NULL, array(), "field_${field_name}_settings_edit");

"Configure the formatter to display the prefix and suffix." ?
+ Really minor: remove the two empty lines after that to keep that code as a single block after the comment.

plopesc’s picture

Status: Needs work » Needs review
StatusFileSize
new1.73 KB
new4.42 KB
new2.77 KB

Hi!
Thanks for your review. Attaching patch including your advices.

Regards.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Thanks !

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs a reroll

git ac https://drupal.org/files/fix_number_settings-2047475-3.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4523  100  4523    0     0   2893      0  0:00:01  0:00:01 --:--:--  4610
error: patch failed: core/modules/number/lib/Drupal/number/Plugin/field/formatter/DefaultNumberFormatter.php:66
error: core/modules/number/lib/Drupal/number/Plugin/field/formatter/DefaultNumberFormatter.php: patch does not apply
yched’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new4.39 KB

Rerolled.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed ddaeac5 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.