Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Not sure if this is releveant or not due to this issue: https://www.drupal.org/node/2278383
But if you have something like this:
drupal_set_message('test 1', 'error');
drupal_set_message('test 2', 'status');
Then the status message will be styled as an error message, but not as a status message.
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 448 bytes | star-szr |
#18 | 2348783-18.patch | 1.76 KB | star-szr |
#16 | fix-wrong-classes-on-status-messages-2348783-8.patch | 1.76 KB | kugta |
#16 | interdiff-2348783-8-16.txt | 1.38 KB | kugta |
#8 | fix-wrong-classes-on-status-messages-2348783.pass_.patch | 1.42 KB | larowlan |
Comments
Comment #1
leewillis77 CreditAttribution: leewillis77 commentedIt appears that this is a twig template issue, as duplicate classes are added (Each message inherits the previous message's classes). So - the first message gets
messages messages--error
and the next getsmessages messages--error messages--status
It seems that this is because the classes are added to a set of classes that is never reset in between messages.
The attached patch resolves this for me, but I'm not a twig expert, so there may be a better way to store/reset the attributes for each iteration through the loop.
Comment #2
larowlanI suspect a1a0cc86c086e8242701ef4a43fbf2398a139886
Comment #3
leewillis77 CreditAttribution: leewillis77 commentedSorry - that previous patch included a bunch of irrelevant changes. Revised patch attached.
Comment #4
larowlantests coming
Comment #5
larowlanshould be red/green
Comment #6
larowlanComment #8
larowlanmeh merge head first lee
Comment #9
larowlanComment #11
kugta CreditAttribution: kugta commentedTested by setting six messages of three different types in random order. All the class names are rendered correctly.
Comment #12
star-szrThis makes sense, maybe a comment in the template to explain though?
Comment #13
star-szrComment #14
pfrenssenReplace this with "Contains Drupal\system\...".
Use "{@inheritdoc}", this is already documented on the parent class.
Comment #15
kugta CreditAttribution: kugta commentedComment #16
kugta CreditAttribution: kugta commentedComment #17
larowlanComment only changes, back to rtbc
Comment #18
star-szrContains \Drupal
Fixed here and leaving at RTBC because it's so minor.
Comment #20
larowlanThanks, reviewing patches on your phone--
Comment #22
skein CreditAttribution: skein commentedNot sure if I have the authority to do it, but tested the patch and all seems fine and the tests have passed. So I will put it in RTBC.
Comment #23
star-szr@skein, yep thanks! Testbot is having a rough day :(
Comment #24
webchickThanks for the fix and the test!
Committed and pushed to 8.0.x. Thanks!