Fix error on call to a member function addMessage() on null in CacheflushApi form

Created on 26 April 2023, over 1 year ago
Updated 3 December 2023, 12 months ago

Problem/Motivation

Message Error: Call to a member function addMessage() on null in Drupal\cacheflush_ui\Entity\Form\CacheflushEntityForm->save() (line 115 of /code/web/modules/contrib/cacheflush/modules/cacheflush_ui/src/Entity/Form/CacheflushEntityForm.php)

Steps to reproduce

  1. Enable Cacheflush, CacheFfush UI, and Cacheflush Entity modules
  2. Go to Structure ->Cacheflush ->Add new
  3. Fill out the form (only title is required) and save. This should go to a white error page.

Proposed resolution

In CacheflushApi, $this->messenger exists because of MessengerTrait in FormBase but it is not set, so it should be changed to $this->messenger(), which is a function in MessengerTrait.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kelly.m.jacobs

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

  • Issue created by @kelly.m.jacobs
  • Open on Drupal.org β†’
    Core: 10.0.7 + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • Status changed to RTBC 12 months ago
  • πŸ‡ΈπŸ‡°Slovakia trafo

    Reviewed and applied patch. It solves the issue.

    Changing status to Reviewed and Tested by Community

  • Status changed to Needs work 12 months ago
  • πŸ‡§πŸ‡¬Bulgaria vuil Bulgaria πŸ‡§πŸ‡¬ πŸ‡ͺπŸ‡Ί 🌍

    The patch can not be applied, reroll is needed.

  • πŸ‡§πŸ‡¬Bulgaria vuil Bulgaria πŸ‡§πŸ‡¬ πŸ‡ͺπŸ‡Ί 🌍

    There is another issue with the messenger:

    TypeError: Drupal\cacheflush_ui\Plugin\Action\DeleteCacheflush::__construct(): Argument #4 ($temp_store_factory) must be of type Drupal\user\PrivateTempStoreFactory, Drupal\Core\TempStore\PrivateTempStoreFactory given, called in /var/www/web/modules/custom/cacheflush/modules/cacheflush_ui/src/Plugin/Action/DeleteCacheflush.php on line 67 in Drupal\cacheflush_ui\Plugin\Action\DeleteCacheflush->__construct() (line 51 of modules/custom/cacheflush/modules/cacheflush_ui/src/Plugin/Action/DeleteCacheflush.php). 
    
  • πŸ‡§πŸ‡¬Bulgaria vuil Bulgaria πŸ‡§πŸ‡¬ πŸ‡ͺπŸ‡Ί 🌍
  • πŸ‡§πŸ‡¬Bulgaria vuil Bulgaria πŸ‡§πŸ‡¬ πŸ‡ͺπŸ‡Ί 🌍
  • Status changed to RTBC 12 months ago
    • vuil β†’ committed dc085768 on 2.0.x
      Issue #3356600 by vuil, kelly.m.jacobs, trafo: Fix error on call to a...
  • Status changed to Fixed 12 months ago
  • πŸ‡§πŸ‡¬Bulgaria vuil Bulgaria πŸ‡§πŸ‡¬ πŸ‡ͺπŸ‡Ί 🌍
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024