getStyles warning due to wrong isset() check

Created on 17 October 2024, about 1 month ago

Problem/Motivation

In version 1.3.0 the condition for checking if the css array element exists is incorrect and outputs a warning

[variables] => Array
      │         (
      │             [%type] => Warning
      │             [@message] => Drupal\Core\Render\Markup Object
      │                 (
      │                     [string:protected] => Undefined array key "css"
      │                 )
      │ 
      │             [%function] => Drupal\vite\Manifest->getStyles()
      │             [%file] => /var/www/site/web/modules/contrib/vite/src/Manifest.php
      │             [%line] => 77

Steps to reproduce

Add a module libraries.yml entry which includes vite but doesn't include a css element. Then rebuild caches and note the error in the drush output.

Proposed resolution

The if statement should be changed from:

    if (
      !$this->chunkExists($chunk)
      || isset($this->manifest[$chunk]['css'])
      || !is_array($this->manifest[$chunk]['css'])
    ) {
      return [];
    }

to:

    if (
      !$this->chunkExists($chunk)
      || !isset($this->manifest[$chunk]['css'])
      || !is_array($this->manifest[$chunk]['css'])
    ) {
      return [];
    }
🐛 Bug report
Status

Active

Version

1.3

Component

Code

Created by

🇮🇹Italy tanc Italy

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

Comments & Activities

Production build 0.71.5 2024