BackgroundImageCssController->getCssTemplate() makes log noise after cache clear

Created on 18 October 2023, about 1 year ago
Updated 12 June 2024, 5 months ago

After a cache clear, loading a page with a background image causes this warning message:

Warning: Undefined property: Drupal\Core\Cache\DatabaseBackend::$data in Drupal\background_image\Controller\BackgroundImageCssController->getCssTemplate() (line 437 of modules/contrib/background_image/src/Controller/BackgroundImageCssController.php).

The line in question:

$this->cssTemplates = $cache && is_array($cache->data) ? $cache->data : [];

A simple isset check squelches the warning easily enough:

$this->cssTemplates = $cache && isset($cache->data) && is_array($cache->data) ? $cache->data : [];

I don't know if there are any deeper issues with this code that need to be investigated, but in the meantime this at least reduces log noise.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States olarin

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

Comments & Activities

  • Issue created by @olarin
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States olarin
  • Status changed to Active about 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia Nigel Cunningham Geelong

    Thanks for your report.

    Line 437 doesn't match current dev so I assume you're actually trying the 2.0.1 release.

    If that's not correct, could I get you to provide steps for reproducing the issue from a fresh install? I haven't succeeded in reproducing it so far.

    I'm planning on continuing to look at other issues and hope to provide a new release today too; assuming that happens, please try that instead.

    Thanks again!

  • Status changed to Fixed 6 months ago
  • πŸ‡¦πŸ‡ΊAustralia Nigel Cunningham Geelong

    Patch applied; thanks.

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

Production build 0.71.5 2024