See the change record: drupal_get_message() and drupal_set_message() replaced by Messenger service.
In our case, this even leads to test fails because we explicitly check $_SESSION['messages'] in our QueryTest. But, while we're at it, we should fix this properly, get rid of the deprecated drupal_set_message() calls and use DI wherever possible for the new messenger service.
One thing I don't quite get is why \Drupal::messenger() doesn't get you the new messenger service but a LegacyMessenger object, which apparently uses the old session mechanism instead of the new flashbag thingie. Therefore, I'm not 100% sure what's the correct replacement for drupal_set_message() calls in procedural code (or other code where DI isn't possible).
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 2931730-12--use_messenger_service.patch | 64.76 KB | drunken monkey |
Comments
Comment #2
drunken monkeyComment #3
drunken monkeyOops. Lucky that I thought of that in time …
Seems we'll have to wait until we depend on 8.5 before we can do the proper fix/adaption. For now, let's just fix the test.
Comment #4
drunken monkeyOK, makes sense. Then maybe like this?
Comment #6
drunken monkeyCommitted.
Setting back to "Postponed" for the more thorough overhaul in #2 (once we depend on Drupal 8.5).
Comment #7
drunken monkeyComment #8
drunken monkeyComment #10
drunken monkeyRe-roll of #2.
Comment #11
borisson_I applied this patch, we have 2 leftover instances of
drupal_set_message.Those should be changed as well.
Comment #12
drunken monkeyGood catch, thanks!
Comment #13
chanderbhushan commented@drunken monkey, I have tested your patch, it looks fine.
Comment #14
drunken monkeyThanks a lot, good to hear!
Committed.
Comment #16
borisson_For some reason the new status didn't stick.