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.
We have to replace all usage of drupal_set_message() with an injectible service as described in #2278383: Create an injectible service for drupal_set_message()
Change record: https://www.drupal.org/node/2774931
The deprecation was added in Drupal 8.5 but suppressed until 8.6 hence we only started getting Travis test failures at 8.6.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | scheduler-Replace_drupal_set_message_with_an_injectible_service-2705499-8-D8.patch | 6.39 KB | thalles |
Comments
Comment #2
legovaerPostponed as the core team is still working on the service.
Comment #3
idebr commenteddrupal_get_message() and drupal_set_message() replaced by Messenger service
Comment #4
Snehal Brahmbhatt commented@legovaer, Please find my patch that Changes the drupal_set_message to $this->messenger->addMessage as per Drupal standard. Hope this helps you.
Thanks!.
Comment #6
legovaerThank you for your patch. However you are calling the messenger using
$this->messengerhowever this was never set. It would be better to get the service via\Drupal::service()so that other people won't get confused.Comment #7
thallesComment #8
thallesFollow the patch!
Comment #9
idebr commentedThe patch applies cleanly and replaces all occurrences of
drupal_set_message()with the Messenger service.Comment #11
jonathan1055 commentedThanks snehal.addweb, legovaer, thales and idebr.
Comment #12
thallesThanks all!
Comment #13
jonathan1055 commentedJust to record the effect this had, here are screen shots from my test builds on https://travis-ci.org/jonathan1055/scheduler
Before:

After:

The remaining failures were in the Devel Generate code itself, so had to be suppressed using
@group legacywhich I did in #3033108-6: Miscellaneous changes before Scheduler 8.x-1.1Comment #14
jonathan1055 commentedLinked to parent issue.
Comment #15
jonathan1055 commentedThe replacement
messengerservice does not exist in core 8.4, it was added in 8.5 so Scheduler now needs to explicitly state that it is only compatible with Drupal Core 8.5 and higher. Hence adding- drupal:system (>= 8.5)to scheduler.info.yml