Comments

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Title: Remove all usages of drupal_get_message and drupal_set_message in modules A-F » [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules A-F
Status: Active » Postponed
StatusFileSize
new100.45 KB

Initial patch split from parent issue. Blocked on messenger trait in #2935255: Remove all usages of drupal_set_message and drupal_get_messages in core lib

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kim.pepper’s picture

Title: [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules A-F » Remove all usages of drupal_get_message and drupal_set_message in modules A-F
Status: Postponed » Active
Issue tags: +Needs reroll

Unblocked as messenger trait was added in #2937945: Add messenger to ControllerBase and FormBase

kim.pepper’s picture

Status: Active » Needs review
Issue tags: -Needs reroll
StatusFileSize
new90.82 KB

Reroll

Status: Needs review » Needs work

The last submitted patch, 5: 2935256-5.patch, failed testing. View results

kim.pepper’s picture

Status: Needs work » Needs review
Issue tags: +messenger
StatusFileSize
new96.24 KB
new8.88 KB

Adds missing messenger.

Status: Needs review » Needs work

The last submitted patch, 7: 2935256-7.patch, failed testing. View results

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new97.23 KB
new1.85 KB

Fixing test fails.

bhanuprakashnani’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly. The requirements needed are satisfied.

bhanuprakashnani’s picture

Status: Reviewed & tested by the community » Needs review

Patch applies cleanly. The requirements needed are satisfied.

The last submitted patch, 2: 2935256-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 9: 2935256-9.patch, failed testing. View results

shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
kim.pepper’s picture

Title: Remove all usages of drupal_get_message and drupal_set_message in modules A-F » [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules A-F
Status: Needs work » Postponed
jibran’s picture

Issue summary: View changes
grep -inr -e "drupal_set_message" -e "drupal_set_message" core/modules/[a-f]*
core/modules/big_pipe/src/Render/BigPipe.php:733:    // change the way drupal_set_message() works in the Drupal 8 cycle. So we
core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php:20:    // Output all attached placeholders trough drupal_set_message(), so we can
core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php:77:      drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly published.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php:77:      drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly unpublished.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
core/modules/file/file.module:1013:      // @todo Add support for render arrays in drupal_set_message()? See
jibran’s picture

Issue summary: View changes
shubhangi1995’s picture

Assigned: shubhangi1995 » Unassigned
voleger’s picture

Title: [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules A-F » Remove all usages of drupal_get_message and drupal_set_message in modules A-F
Status: Postponed » Needs work
voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new90.94 KB

Rerolled regarding last changes.
core/modules/file/tests/file_test/src/Form/FileTestSaveUploadFromForm.php - calls already replaced. Removed changes from the patch.
core/modules/content_moderation/src/EntityTypeInfo.php - content moderation changes had removed single usage of DSM. So, removed changes from the patch for this file.
core/modules/field/tests/modules/field_test/field_test.module - rerolled regarding #2940201: hook_field_widget_form_alter() can no longer affect the whole widget for multi-value fields

kim.pepper’s picture

Status: Needs review » Needs work

Thanks @voleger. I ran  grep -inr -e "drupal_set_message" -e "drupal_get_message" core/modules/[a-f]*

and found a few missing converstions and comments:

core/modules/big_pipe/src/Render/BigPipe.php:733:    // change the way drupal_set_message() works in the Drupal 8 cycle. So we
core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php:20:    // Output all attached placeholders trough drupal_set_message(), so we can
core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublish.php:77:      drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly unpublished.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublish.php:77:      drupal_set_message($this->t("@bundle @label were skipped as they are under moderation and may not be directly published.", ['@bundle' => $bundle_label, '@label' => $entity->getEntityType()->getPluralLabel()]), 'warning');
core/modules/file/file.module:1013:      // @todo Add support for render arrays in drupal_set_message()? See
voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new8.87 KB
new99.51 KB

Thank's @kim.pepper for review.
Added missing replacements.

kim.pepper’s picture

Status: Needs review » Reviewed & tested by the community

Addresses all feedback to RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work

Please combine the patches in #2935258: Remove all usages of drupal_get_message and drupal_set_message in modules M-R and #2935259: Remove all usages of drupal_get_message and drupal_set_message in modules S-Z into this one so all the module changes can be reviewed together. I think it's fine to do core/lib separately.

catch’s picture

Title: Remove all usages of drupal_get_message and drupal_set_message in modules A-F » Remove all usages of drupal_get_message and drupal_set_message in modules
yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar

@catch - i will combine all three patches

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new277.22 KB

@catch - I have combined all three patches & removed the core/lib separately as mentioned in #24 but i think few usages #2935257: [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules G-L are still there.

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
StatusFileSize
new305.35 KB

As discussed with @catch, here is the latest updated patch to remove all usage of drupal_get_message & drupal_set_message in modules, only two occurrences left when we check with grep -inr -e "drupal_set_message" -e "drupal_get_message" core/modules/* as mentioned in #16.
Hopefully it pass all the test cases.

The last submitted patch, 27: remove_all_usages_of_dsm-2935256-27-8.6.x.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 28: remove_all_usages_of_dsm-2935256-28-8.6.x.patch, failed testing. View results

ibustos’s picture

StatusFileSize
new308.33 KB
new2.25 KB
ibustos’s picture

Oops.

voleger’s picture

Status: Needs work » Needs review
StatusFileSize
new367.57 KB
new63.58 KB
voleger’s picture

StatusFileSize
new307.25 KB
new60.19 KB

Cleanup after reroll in #33.

The last submitted patch, 33: remove_all_usages_of_dsm-2935256-33-8.6.x.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 34: remove_all_usages_of_dsm-2935256-34-8.6.x.patch, failed testing. View results

girish-jerk’s picture

Assigned: Unassigned » girish-jerk
jofitz’s picture

Assigned: girish-jerk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new306.53 KB
new691 bytes

@Girish-jerk hasn't touched this for 3 weeks so I'll have a go.

Corrected the failing test (after a minor re-roll).

kim.pepper’s picture

Status: Needs review » Needs work

Thanks for picking this up again @Jo Fitzgerald

It's not great having to review a 306K patch, but here we are!

I've reviewed this a few times in the sub-issues that were merged into this one, so scanning through, I could only find one obvious issue.

+++ b/core/lib/Drupal/Core/Form/FormErrorHandler.php
@@ -166,7 +168,7 @@ protected function setElementErrorsFromFormState(array &$form, FormStateInterfac
   protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
-    drupal_set_message($message, $type, $repeat);
+    $this->messenger()->addMessage($message, $type, $repeat);

This method and usages are not necessary if we use messenger directly.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new307.21 KB
new1.42 KB

Resolved the issue that @kim.pepper raised in #39.

A quick search suggests there are plenty of instances of drupal_set_message() remaining in the codebase (e.g. Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber::drupalSetMessage) - do any of these have reason to remain? I'm fast going off this ticket!

Status: Needs review » Needs work

The last submitted patch, 40: 2935256-40.patch, failed testing. View results

voleger’s picture

I guess this method should not be removed for now. Maybe better mark that method internal or deprecated?

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new311.35 KB
new4.13 KB

Update tests to reflect removal of drupalSetMessage().

kim.pepper’s picture

Looking great.

I ran a check for instances of drupal_set_message and drupal_get_message in the core/modules directory.

grep -inr -e "drupal_set_message" -e "drupal_get_message" core/modules
core/modules/system/tests/modules/system_test/system_test.routing.yml:16:system_test.drupal_set_message:
core/modules/system/tests/modules/system_test/system_test.routing.yml:19:    _title: 'Set messages with drupal_set_message()'
core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php:8: * Tests drupal_set_message() and related functions.
core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php:22:   * Tests drupal_set_message().

Those are all valid instances and can remain.

+++ b/core/modules/views/src/Analyzer.php
@@ -52,7 +52,8 @@ public function getMessages(ViewExecutable $view) {
-   * This is based upon the format of drupal_set_message which uses separate
+   * This is based upon the format of
+   * \Drupal\Core\Messenger\MessengerInterface::addStatus() which uses separate
    * boxes for "ok", "warning" and "error".

Nit: Should really be ::addMessage().

Other than that, I think this is ready.

voleger’s picture

#44: +1

jofitz’s picture

StatusFileSize
new311.35 KB
new640 bytes

Corrected the nit from #44.

Let's push this one across the line and forget this huge patch forever!

kim.pepper’s picture

Status: Needs review » Reviewed & tested by the community
voleger’s picture

+1 for RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 46: 2935256-46.patch, failed testing. View results

kim.pepper’s picture

Drupal\Tests\system\FunctionalJavascript\ThemeFormSettingsTest failed. Retesting.

kim.pepper’s picture

Status: Needs work » Reviewed & tested by the community

Random bot fail. Setting back to RTBC

alexpott’s picture

Crediting @jibran and @catch for reviewing this and the other patches that have been merged into this one.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b84b827 and pushed to 8.6.x. Thanks!

  • alexpott committed b84b827 on 8.6.x
    Issue #2935256 by Jo Fitzgerald, voleger, kim.pepper, ibustos, Yogesh...

  • alexpott committed 2e8be78 on 8.6.x
    Issue #2935256 follow-up by alexpott: Remove all usages of...
alexpott’s picture

This broke PHP 5.5 testing. I hotfixed because it is the 8.6.x branch and committing this patch once is enough disruption.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.