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
Comments
Comment #2
joachim commentedI 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.
Comment #3
joachim commentedOk, 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.
Comment #4
tr commentedSounds like you didn't run update.php?
Yes, some config datatypes like the one you mention were corrected, but the update hook should have fixed that in any views that use this module. There's also a test that checks this update process to ensure they were corrected by the hook.
#3480009: Update Views options schema and turn on strict config schema checking in tests
Comment #5
tr commented@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.
Comment #6
poker.ca commentedSame/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).Comment #7
poker.ca commentedSame/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).Comment #8
tr commented@poker.ca: That's a different problem.
I opened up a new issue for your bug here: #3484017: Table::getCellRaw(): Return value must be of type string, false returned
Please read that issue,
Comment #9
joachim commented> @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:
However, the update function also made these changes which I'm confused about:
Comment #10
tr commentedIn 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 they 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.
Comment #11
ericgsmith commentedHi @tr
I have also experience this same result after updating (the unexpected config diff of '1' => 0 and '2' => 0, not the original issue summary)
It looks like there is a missing
.inviews_aggregator_update_10200between 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'Comment #13
ericgsmith commentedOpened MR for that - https://git.drupalcode.org/project/views_aggregator/-/merge_requests/29/...
EDIT
I see now that this is not really to do with the original summary only the last few comments in this issue #3485998: Totals per page and column precision always set to 0 in views_aggregator_update_10200 so I moved it to a new issue - wasn't sure if it was better to reword / take over this issue or open a new one
Comment #15
ericgsmith commentedComment #16
tr commentedIt 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_pageandprecisionthat 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 #3485998: Totals per page and column precision always set to 0 in views_aggregator_update_10200 for further details.I think this issue can be closed now?
Comment #17
clava commentedAfter 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).
Comment #18
tr commented@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.
Comment #19
tr commentedAs 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.
Comment #20
mortona2k commentedI'm getting this error on a fresh install on Drupal 11.
All I did was create a view, and enable this display. I'm unable to get past the error with any settings.
Comment #21
davidwhthomas commentedThe original error in this post still occurs in 2.1x, so I'm reopening this issue. For example, when updating the table settings in the View with auto-preview enabled, you can see the error.
It appears to happen because the values for the views option form "group_aggregation_results" element are set to integers (0,1), while the HTML form input value will return a string ("0", or "1") ref: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement
i.e
The module config schema is set to use an integer for that field too, but views will sometimes return a string for the form input value, because HTML. While it's probably better to just use a string for that value, assuming it needs to be an integer, another solution would be to allow a string or integer to be passed to
Drupal\views_aggregator\Plugin\views\style\Table::setAggregatedGroupValuesfor the$group_aggregation_resultsparameter.Comment #23
davidwhthomas commentedComment #24
mortona2k commentedThis got it working for me, thanks!
I can't really account the parameter type question, but it looks like this change should be compatible with what's currently there.
Comment #25
nwells commentedI can confirm the same issue on a new Drupal 11 install
I updated
Drupal\views_aggregator\Plugin\views\style\Table::setAggregatedGroupValuesto allow forint|stringas suggested in #21 and that resolved the issue for me.Comment #26
ifrikI have the same issue when updating 2.0.2 to 2.0.3
Comment #27
davidwhthomas commentedComment #28
roxflame commentedOn my install (dev version) it still wasn't working after patching with #21, I updated the following around line 861 to cast the string to int if present
Comment #29
davidwhthomas commented@roxflame although #28 may have a similar cause, it appears to be a different issue from the title and topic addressed in this issue.
Comment #30
skaught+1 more.
branch: views_aggregator-data-type-fix-3482129-2
-> https://git.drupalcode.org/project/views_aggregator/-/merge_requests/36....
patch allows by view to work as expected.
Comment #31
flameingo commented+1
When I save the modal, the value of the variable $group_aggregation_results is a string, which causes an error message. If you then save the view, you don't get this error because the value is then of type integer. Patch from #30 solves the problem.
Drupal Version: 11.2.8
Comment #32
olivierh65 commentedSame problem, and patch solves it.