Closed (fixed)
Project:
Drupal core
Version:
8.6.x-dev
Component:
base system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Mar 2018 at 17:31 UTC
Updated:
30 Jul 2018 at 09:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Sut3kh commentedComment #4
Sut3kh commentedOK from what I can tell the failure is that it is now (correctly) only finding 1 error because _file_save_upload_from_form() pulls any error messages from the messenger and into form errors. It was passing before the patch because drupal_get_messages('error') wasn't clearing the error before also printing it in a form error.
Before patch:
After patch:
Therefore using the 'after' count to test that error messages are preserved is no longer possible but I think this should be satisfied by the '$this->assertText($error);' on line 420 anyway.
Comment #5
dandaman commentedApplied this patch to a site and it did remove the messages of type status as expected where before it was not being removed when executing deleteByType().
Comment #6
Rob C commentedWhile the user_registrationpassword tests do not trip over this, this patch includes an assertRaw() on the number of messages. Great, but is this the only place we (can) test this? The patch indeed works like expected.
This is 8.5.0 without patch / with user_registrationpassword enabled / submit the registration form: (the module replaces the first message)

With the patch the first message does not appear.
And i wonder if this should be a major issue: we get more than we expect + indeed seems like a mistake / looked over.
Updating to RTBC to get some attention.
Not 100% sure, but this prolly was introduced in #2278383: Create an injectible service for drupal_set_message(). Adding a message there + linking in, so we can get this fixed asap.
Comment #7
jibranThanks, for reporting and creating the patch.
We should add explicit tests for this change.
Comment #8
simgui8 commentedThanks @Sut3kh
\Drupal::messenger()->deleteByType($type) was deleting nothing for me in Drupal 8.5.1
#4 fixed it
Comment #9
nottaken commentedPatch in #4 worked for me as well on 8.5.3. Thanks Sut3kh
Comment #10
thejacer87 commentedconfirmed working on 8.5.5
Comment #11
alexpottAdding a test.
Removed this comment because it is not necessary - in fact whilst doing #2942068: FileTestSaveUploadFromForm incorrectly counts messages we should have noticed that deleteByType is not working. There's no case in which the messages should increase because the whole point of _file_save_upload_from_form() is to move messages to form errors.
No interdiff because this is also a re-roll for 8.6.x. We need to apply the patch to 8.6.x / 8.7.x first.
Comment #13
jibranTest only patch failed. RTBC if #11 comes back green on 8.6.x.
Comment #14
alexpottCommitted and pushed 7353b6f170 to 8.7.x and f2d09530f4 to 8.6.x and cbe0ec9 and to 8.5.x. Thanks!
Comment #19
alexpottReverted from 8.5.x since 8.5.x is in criticals only. This will be fixed in 8.6.0.
Comment #20
dawehner@Sut3kh I'm wondering whether you could describe how you encountered this problem. Is this something which was a problem on your site / your contrib module or did you just read the code itself?
Comment #21
Sut3kh commented@dawehner I was updating some code that improves the node save messages to use \Drupal::messenger() for 8.5 (used to manipulate $_SESSION directly).
It grabs all status messages, deletes them (deleteByType) and then adds them again after parsing through regex.
When I saw that i was still getting the original messages as well, stepping through \Drupal::messenger()->deleteByType() showed where the issue was.