Crashes with Drupal\views_aggregator\Plugin\views\style\Table::setAggregatedGroupValues(): Argument #3 ($group_aggregation_results) must be of type int, string given

Created on 21 October 2024, 2 months ago

Problem/Motivation

I've just updated from 2.0.2 to 2.1.0 and my views using aggregation now crash with:

> TypeError: Drupal\views_aggregator\Plugin\views\style\Table::setAggregatedGroupValues(): Argument #3 ($group_aggregation_results) must be of type int, string given, called in /var/www/html/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php on line 40

I expect this is because the config type has been changed recently, or been made stricter.

The values in my config YAML files show a string for this value:

          group_aggregation:
            group_aggregation_results: '0'

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

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

Merge Requests

Comments & Activities

  • Issue created by @joachim
  • πŸ‡¬πŸ‡§United Kingdom joachim

    I was thinking what would be needed here would be to do an update of existing config, but I've just tried creating a new view from scratch, and the preview crashes.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Ok, re-saving the view fixes the crash, so it *is* a config update that's needed.

    The views preview crash is still happening, so that must be something else.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Sounds like you didn't run update.php?

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    @joachim: Did the update function work properly? I can't reproduce this problem, and as I said I believe the update function should be updating any views_aggregator table views on your site.

    Are you still having the issue with the preview? If so I need steps to reproduce - if you are getting a crash with the preview I need the PHP error that you are seeing from your logs. I don't see that problem on my sites.

  • πŸ‡¨πŸ‡¦Canada poker.ca

    Same/similar issue here. After updating to 2.1.0, I ran update.php and cleared the caches, but still get this error when loading any page that uses this module. Other pages (tables) are working OK...
    TypeError: Drupal\views_aggregator\Plugin\views\style\Table::getCellRaw(): Return value must be of type string, false returned in Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw() (line 754 of /var/www/drupal/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).

  • πŸ‡¨πŸ‡¦Canada poker.ca

    Same/similar issue here. After updating to 2.1.0, I ran update.php and cleared the caches, but still get this error when loading any page that uses this module. Other pages (tables) are working OK...
    TypeError: Drupal\views_aggregator\Plugin\views\style\Table::getCellRaw(): Return value must be of type string, false returned in Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw() (line 754 of /var/www/drupal/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    @poker.ca: That's a different problem.
    I opened up a new issue for your bug here: πŸ› Table::getCellRaw(): Return value must be of type string, false returned Active
    Please read that issue,

  • πŸ‡¬πŸ‡§United Kingdom joachim

    > @joachim: Did the update function work properly? I can't reproduce this problem, and as I said I believe the update function should be updating any views_aggregator table views on your site.

    I'm embarassed to report I hadn't run the update function. Running it fixes the crash -- the update function correctly changes the type of the group_aggregation_results property:

    -            group_aggregation_results: '0'
    +            group_aggregation_results: 0
    

    However, the update function also made these changes which I'm confused about:

    -            totals_per_page: 1
    -            precision: 2
    +            totals_per_page: 0
    +            precision: 0
    
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia
    -            totals_per_page: 1
    -            precision: 2
    +            totals_per_page: 0
    +            precision: 0

    In the previous version of the module, totals_per_page was sometimes a string and sometimes boolean. The update function sets it to 1 if the old value can be evaluated to true, and sets it to 0 otherwise. I don't see what went wrong here, because your old value was 1 and that should have evaluated to true, so the update function shouldn't have changed it.

    For precision, the old type was a string, and the new type is integer. The update function just does a cast to an integer. So I don't see how that would have changed it from 2 to 0.

    In both cases, it looks like your old values were already integers, which is puzzling because the were not declared or used as integers in the old version of this module. That was part of the point with this update - to fix the wrongly typed configuration variables. I have no explanation for why the values were wrongly changed - I tested this by installing an older version of the module, setting my totals_per_page and precision to your values, then running the update function, and it worked properly for me.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Hi @tr

    I have also experience this same result after updating.

    It looks like there is a missing . in views_aggregator_update_10200 between the key and property for when the current values of precision and totals_per_page are fetched which is then not getting the actual values and setting them as 0.

    E.g. the value comes from $key . 'column_aggregation.precision' and is set to $key . '.column_aggregation.precision'

  • Pipeline finished with Success
    about 2 months ago
    Total: 156s
    #331373
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Opened MR for that - https://git.drupalcode.org/project/views_aggregator/-/merge_requests/29/...

    I see now that this is not really to do with the original summary only the last few comments in this issue - let me know if you want me to open as a new issue instead.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    It is my understanding that the original issue described in the issue summary was because update.php had not been run.

    The additional problem with totals_per_page and precision that was raised by @joachim in #9 is a bug and was correctly diagnosed by @ericgsmith in #11. That bug is now fixed, and there is a new release 2.1.1 now so that no-one else will have that same issue. See πŸ› Totals per page and column precision always set to 0 in views_aggregator_update_10200 Active for further details.

    I think this issue can be closed now?

  • πŸ‡¨πŸ‡­Switzerland clava

    After an update to 2.1.1 I still get an error:
    TypeError: Drupal\views_aggregator\Plugin\views\style\Table::getCellRaw(): Return value must be of type string, false returned in Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw() (line 754 of modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    @clava: As I already said in response to #6/#7, that's a different issue. I gave a link to that issue, and that is where that problem is being worked on. It has nothing to do with this issue.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    As per #16. The original issue was because update.php wasn't run - it wasn't a bug in this module.
    The subsequent problem raised in #9 was fixed in a different issue.
    Nothing left to fix here.

Production build 0.71.5 2024