Problem/Motivation

When a relationship is missing and used in a grouping function, the warning "Warning: Undefined array key XXX in Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw()" is triggered.

Add a check to ensure that warning is not triggered.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

plopesc created an issue. See original summary.

tr’s picture

Status: Active » Needs review

I triggered a re-test now that #3322628: Core Drupal broke this module's PHP 8 tests has been fixed.

mortona2k’s picture

Status: Needs review » Reviewed & tested by the community

I encountered this issue, looks like I have an aggregated table with a sum on a column that has no values.

This patch fixes the warnings. It's just checking isset($result_row->_relationship_entities[$relationship]) before using the value.

tr’s picture

Version: 2.0.x-dev » 2.1.x-dev

tr changed the visibility of the branch 8.x-1.x to hidden.

tr changed the visibility of the branch 2.1.x to hidden.

tr changed the visibility of the branch 2.0.x to hidden.

tr changed the visibility of the branch 3322452-warning-undefined-array to hidden.

tr changed the visibility of the branch 3322452-undefined-array-key to hidden.

tr changed the visibility of the branch 3322452-getcellraw to hidden.

tr’s picture

OK I screwed up the rebasing to a new branch, but it's fixed now. The new MR has the same changes as @plopesc posted in #1, but it's now on the current 2.1.x branch.

Adding an isset() to make an error go away is something I really don't like to do. Because for example in this case $source never gets a value, which may cause problems further down the line, and even if it doesn't cause a problem having to check a value with isset() tells me that there's something wrong in the code before we get to that point. Shouldn't we know at this point whether the relationship exists? Why are we trying to do something with it?

I am also trying to get new test cases written, so that we can catch things like this before they happen, or at least ensure that once this is fixed it won't show up again in the future because someone inadvertently broke it. A simple view export that causes this error to happen would be great if you can provide it, that way I can put it in a test.

tr’s picture