[regression] COUNT aggregation no longer outputs count value for some fields

Created on 8 April 2025, 26 days ago

Problem/Motivation

See https://www.drupal.org/project/drupal/issues/2735997#comment-16058371 🐛 Decimal separator and decimals settings ignored when aggregating decimal fields Needs work

TLDR; using COUNT on some fields (so far tested with changed and created base fields) no longer outputs the actual count. Reverting 🐛 Decimal separator and decimals settings ignored when aggregating decimal fields Needs work fixes it.

Steps to reproduce

Steps to reproduce:
- Install standard on 11.1.6
- Install rest module
- Import attached view ( https://www.drupal.org/files/issues/2025-04-08/views.view_.test_count.yml )
- Go to /test/count
- Notice HTML in changed_1 field
- Revert commit
- Notice counts in changed_1 field

Proposed resolution

Add handlers back for COUNT and COUNT Distinct
Test coverage

Remaining tasks

Do it

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

views.module

Created by

🇦🇺Australia acbramley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @acbramley
  • 🇦🇺Australia acbramley

    It seems like string based fields work fine (tested the output of COUNT on the name and that works without the fixed) so perhaps it's a numeric field issue?

  • Pipeline finished with Failed
    26 days ago
    Total: 637s
    #467924
  • 🇦🇺Australia acbramley

    That breaks testFieldAggregationSettings again, gonna have to dig further into this

  • Pipeline finished with Running
    26 days ago
    #467936
  • 🇦🇺Australia acbramley

    Test is correctly failing now:

           ├ Failed asserting that two strings are equal.
           ┊ ---·Expected
           ┊ +++·Actual
           ┊ @@ @@
           ┊ -'4'
           ┊ +'Thu,·1·Jan·1970·-·10:00\n
    

    I'm debugging how views renders this stuff 🤯

    When we get to StylePluginBase::elementPreRenderRow we have the correct count value in $data['#row']. What's happening is that value of 4 is being passed to the timestamp formatter which results in the Jan 1 1970 date (unix epoch)

    Before 🐛 Decimal separator and decimals settings ignored when aggregating decimal fields Needs work , the field handler was being overridden to numeric, therefore $field in that preRender was the NumericField plugin, not EntityField.

  • 🇦🇺Australia acbramley

    Confirmed this isn't just an issue with COUNT either, SUM etc have the same behaviour. I'm starting to think we do need to revert here and come up with a proper fix. The field handlers should be overridden because we don't want to go through the EntityField plugin when outputting aggregation data.

  • 🇦🇺Australia acbramley

    I also confirmed this issue with other field types such as Link

  • 🇦🇺Australia elc

    The contrib module Fraction is also affected by this, with aggregation values disappearing.

    In Core 10.4.5 the SUM output used Drupal\views\Plugin\views\field\NumericField, but in 10.4.6 it turned up in a Drupal\fraction\Plugin\views\field\FractionField using Drupal\fraction\Fraction\FractionItem::setValue(['numerator' => NN.NN]). setValue wasn't expecting such a value (normally it would be presented with FractionItem::setValue(['decimal' => NN.NN]) or ['numerator' => X, 'denominator' => Y]) resulting in the value always being empty as per the FractionItem::isEmpty().

    Using both AUM & AVG in the same view ends up with one affecting the other, where in 10.4.5 that did not happen. I haven't figured out where that is happening.

  • 🇩🇪Germany Anybody Porta Westfalica

    I can also confirm this issue using commerce_reports. This is a major problem as these reports are essential for the stores.

  • First commit to issue fork.
  • 🇨🇦Canada joelpittet Vancouver

    Since @catch reverted the other issue, I caught up the branch to see if it now passes as I assume is expected now.

  • Pipeline finished with Success
    17 days ago
    Total: 597s
    #475501
  • 🇦🇺Australia acbramley

    Rescoping this issue for improved test coverage now that the regression was reverted.

Production build 0.71.5 2024