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.
As part of #2935256: Remove all usages of drupal_get_message and drupal_set_message in modules we discovered that there are two calls to drupal_get_message() which incorrectly assume the structure of the returned array.
drupal_set_message($this->t('Number of error messages before _file_save_upload_from_form(): @count.', ['@count' => count(drupal_get_messages('error', FALSE))]));
$file = _file_save_upload_from_form($form['file_test_upload'], $form_state, 0, $form_state->getValue('file_test_replace'));
drupal_set_message($this->t('Number of error messages after _file_save_upload_from_form(): @count.', ['@count' => count(drupal_get_messages('error', FALSE))]));
drupal_get_messages($type) actually returns an array in the format:
[$type => $messages[$type]];
So, the above use of count() is only counting the number of keys in that array, which is 1 if there are any number of errors, or 0 if there is no array key 'error'.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2942068-7-interdiff.txt | 4.18 KB | kim.pepper |
#7 | 2942068-7.patch | 4.77 KB | kim.pepper |
#4 | 2942068-4-interdiff.txt | 774 bytes | kim.pepper |
#4 | 2942068-4.patch | 2.35 KB | kim.pepper |
#2 | 2942068-2.patch | 1.6 KB | kim.pepper |
Comments
Comment #2
kim.pepperInitial patch.
Comment #4
kim.pepperUpdates the test to check for the number of error messages. There is actually 2.
Comment #5
jibranI'd say we are already touching these lines of code. Can we remove deprecated function calls?
Isn't this a BC break if we have to check
isset
whereas in before messenger service we don't have to?Can we somehow add default to these vars and avoid calling
isset
?Comment #6
kim.pepperComment #7
kim.pepperConverted to MessengerInterface. This removes the need to check isset.
Comment #8
jibranThanks, for addressing the feedback.
Comment #10
kim.pepperRested so back to RTBC
Comment #12
jibranUnrelated Jenkins DB fails.
Comment #13
voleger+1 for RTBC
Comment #14
alexpottCommitted and pushed c10cc9ec84 to 8.6.x and a8802f74cd to 8.5.x. Thanks!
Backported as a test only change.