Problem/Motivation

The buildVariables method is expecting the categories to be keyed by order. e.g.
0 => 'Foo'
1 => 'Bar'

However, if the keys are not in that order then we get the following notice:

Notice: Undefined offset: 1 in Drupal\charts_google\Plugin\chart\Google->buildVariables() (line 151 of modules/contrib/charts/modules/charts_google/src/Plugin/chart/Google.php).

Proposed resolution

Use the a foreach rather than the for so we can get the keys correctly.
File: modules/charts_google/src/Plugin/chart/Google.php
Line: 95

// From.
for ($j = 0; $j < $categoriesCount; $j++) {

// To.
foreach ($categories as $j => $category) {
CommentFileSizeAuthor
#2 3105485-2.patch610 bytesjkevingz

Comments

jkevingz created an issue. See original summary.

jkevingz’s picture

StatusFileSize
new610 bytes

  • andileco committed e2d22f5 on 8.x-3.x authored by jkevingz
    Issue #3105485 by jkevingz: Fix Notice Thrown In buildVariables Function
    
andileco’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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