Problem/Motivation

When having empty categories in a bar chart, multiple warnings are written to the Drupal log.
Warning: current() expects parameter 1 to be array, string given in Drupal\charts\Plugin\views\style\ChartsPluginStyleChart->processNumberValueFromField() (line 500 of /....../modules/contrib/charts/src/Plugin/views/style/ChartsPluginStyleChart.php)

Steps to reproduce

Create a stacked column chart.
Let it render also empty data series.
Check Drupal log - for each empty row you will get at least 3 log entries.

Proposed resolution

The function processNumberValueFromField uses the getField method to get the rendered field value and then supplies it to the current() php function, which triggers the warning if the value returned by getField() is not an array.
Need a simple check for this to avoid the warning and the log spamming.

Remaining tasks

Provide a patch.

User interface changes

None

API changes

None

Data model changes

None

Comments

JordiK created an issue. See original summary.

jordik’s picture

jordik’s picture

Status: Active » Needs review

  • JordiK authored be1dd29 on 5.0.x
    Issue #3216611 by JordiK: Empty rows result in log warning
    
andileco’s picture

Status: Needs review » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

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