1x: drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. See https://www.drupal.org/node/2774931
1x in SiteAlertMenuTest::testDeleteAlert from Drupal\Tests\site_alert\Functional

CommentFileSizeAuthor
#6 interdiff_3-6.txt631 bytesswatichouhan012
#6 3112378-6.patch986 bytesswatichouhan012
#3 3112378-3.patch988 bytesAnonymous (not verified)
#2 3112378-1.patch988 bytesAnonymous (not verified)

Comments

Anonymous’s picture

DenisCi created an issue. See original summary.

Anonymous’s picture

StatusFileSize
new988 bytes
Anonymous’s picture

StatusFileSize
new988 bytes

I hopped if I edit it won't create a new post but will upload the patch bellow issue report. Well here is the fixed name of the patch. Sorry.

pfrenssen’s picture

Status: Active » Needs work

Thanks for picking this up!

diff --git a/src/Entity/Form/SiteAlertDeleteForm.php b/src/Entity/Form/SiteAlertDeleteForm.php
-    drupal_set_message($this->t('The Site Alert @label has been deleted.', ['@label' => $this->entity->label()]));
+    \Drupal::messenger()->addWarning($this->t('The Site Alert @label has been deleted.', ['@label' => $this->entity->label()]));

We shouldn't call \Drupal::messenger() in OO code. The \Drupal class is only intended to be able to call into services from legacy procedural code such as hook implementations etc. Instead we should inject the messenger service.

Luckily the entity forms already inject the messenger service so this can be easily fixed by changing the code to the following:

$this->messenger()->addWarning($this->t('The Site Alert @label has been deleted.', ['@label' => $this->entity->label()]));
swatichouhan012’s picture

Assigned: Unassigned » swatichouhan012
swatichouhan012’s picture

Assigned: swatichouhan012 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new986 bytes
new631 bytes

Here is new patch according #4, Kindly review.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Hello, thanks for the fix @swatichouhan012. I didn't have time to fix it yesterday. I tested your patch with unit tests and it worked flawlessly with no errors reported.

  • pfrenssen committed cd817c7 on 8.x-1.x authored by DenisCi
    Issue #3112378 by DenisCi, swatichouhan012: Deprecated function:...
pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Merged in 8.x-1.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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