Comments

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Status: Active » Needs review
StatusFileSize
new26.37 KB

Initial patch split from parent issue.

Status: Needs review » Needs work

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

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.

voleger’s picture

voleger’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new26.28 KB

Re-roll.

Status: Needs review » Needs work

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

jofitz’s picture

Assigned: Unassigned » jofitz

Trying to fix the test failures.

jofitz’s picture

Assigned: jofitz » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.47 KB
new28.75 KB

Fix some of the test failures.

Status: Needs review » Needs work

The last submitted patch, 10: 2935255-10.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new4.11 KB
new31.36 KB

Fix one of the test failures.

jofitz’s picture

StatusFileSize
new1.11 KB
new32.47 KB

Here's a possible fix to avoid the remaining deprecation notice, but it is a real hack.

The last submitted patch, 12: 2935255-12.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 13: 2935255-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new648 bytes
new32.48 KB

Fix coding standards errors.

kim.pepper’s picture

Looks like there are core tests that rely on inline_form_errors module. The patch in #2935257: [PP-1] Remove all usages of drupal_get_message and drupal_set_message in modules G-L addresses the inline form error changes. You may want to copy them over here as well.

kim.pepper’s picture

Title: Remove all usages of drupal_get_message and drupal_set_message in core lib » [PP-1] Remove all usages of drupal_get_message and drupal_set_message in core lib
Status: Needs review » Postponed

Messenger Trait is now being added as part of #2937945: Add messenger to ControllerBase and FormBase

voleger’s picture

Title: [PP-1] Remove all usages of drupal_get_message and drupal_set_message in core lib » Remove all usages of drupal_get_message and drupal_set_message in core lib
Status: Postponed » Needs work
jofitz’s picture

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

Patch in #16 no longer applies. Re-roll.

voleger’s picture

+1 for RTBC

kim.pepper’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

jibran’s picture

Issue summary: View changes
grep -inr -e "drupal_set_message" -e "drupal_set_message" core/lib/
core/lib/Drupal/Core/Render/Renderer.php:652:    // change the way drupal_set_message() works in the Drupal 8 cycle. So we
kim.pepper’s picture

Issue tags: +messenger

Tagging

jibran’s picture

Status: Reviewed & tested by the community » Needs work

There are some usages remaining.

grep -inr -e "drupal_set_message" -e "drupal_set_message" core/tests/
core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php:173:      'drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. See https://www.drupal.org/node/2774931',
core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php:27:    drupal_set_message('An error occurred', 'error');
core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php:28:    drupal_set_message('But then something nice happened');
core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php:8: * @covers ::drupal_set_message
core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php:14:   * The basic functionality of drupal_set_message().
core/tests/Drupal/KernelTests/Core/Common/DrupalSetMessageTest.php:17:    drupal_set_message(t('A message: @foo', ['@foo' => 'bar']));
kim.pepper’s picture

All of those are testing the drupal_set_message and shouldn't be removed before Drupal 9.0.0, right?

jibran’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Sure.

yogeshmpawar’s picture

Verified the patch +1 for RTBC, good to go.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
@@ -74,7 +74,13 @@ public static function generatePlaceholder(array $element) {
    */
   public static function renderMessages($type) {
     $render = [];
-    $messages = drupal_get_messages($type);
+    if (isset($type)) {
+      $messages = \Drupal::messenger()->deleteByType($type);
+    }
+    else {
+      $messages = \Drupal::messenger()->deleteAll();
+    }
+

Given $type isn't optional, when would it be null?

kim.pepper’s picture

@catch From the docblock:

<?php
* @param string|null $type
   *   Limit the messages returned by type. Defaults to NULL, meaning all types.
   *   Passed on to drupal_get_messages(). These values are supported:
   *   - NULL
   *   - 'status'
   *   - 'warning'
   *   - 'error'
?>

Are you saying because there's no default arg (e.g. $type = NULL), then this comment is wrong?

Messenger has different methods for delete by type vs all, so we need to check here if it's null.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Yep we need to support NULL here for BC. We probably want to deprecate that at some point in the future but not in this issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Actually this needs a reroll and also there are still instances for drupal_set_message and drupal_get_message outside of the modules directories. I think this issue should clean up everything that the modules issue does not. We should leave \Drupal\KernelTests\Core\Common\DrupalSetMessageTest alone though and make this the legacy test once we've removed the entry from \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations().

The files which contain stuff to fix are:

  • core/lib/Drupal/Core/Render/Element/StatusMessages.php
  • core/lib/Drupal/Core/Render/Renderer.php
  • core/core.api.php
  • core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
  • core/scripts/run-tests.sh
alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new4.21 KB
new36.34 KB

Did #32.

voleger’s picture

+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -240,6 +240,10 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat
         ],
+        [
+          'data' => $this->t('Expanded'),
+          'class' => ['checkbox', 'priority-medium'],
+        ],
         $this->t('Weight'),

@@ -298,8 +302,19 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat
         ];
...
         $form['links'][$id]['enabled'] = $element['enabled'];
-        $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = ['checkbox', 'menu-enabled'];
+        $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = [
+          'checkbox',
+          'menu-enabled',
+        ];
+
+        $form['links'][$id]['expanded'] = $element['expanded'];
+        $form['links'][$id]['expanded']['#wrapper_attributes']['class'] = [
+          'checkbox',
+          'menu-expanded',
+          'priority-medium',
+        ];
 

@@ -361,6 +376,12 @@ protected function buildOverviewTreeForm($tree, $delta) {
         ];
+        $form[$id]['expanded'] = [
+          '#type' => 'checkbox',
+          '#title' => $this->t('Show @title as expanded', ['@title' => $link->getTitle()]),
+          '#title_display' => 'invisible',
+          '#default_value' => $link->isExpanded(),
+        ];
         $form[$id]['weight'] = [

@@ -455,7 +476,7 @@ protected function submitOverviewForm(array $complete_form, FormStateInterface $
     // Update our original form with the new order.
     $form = array_intersect_key(array_merge($order, $form), $form);
 
-    $fields = ['weight', 'parent', 'enabled'];
+    $fields = ['weight', 'parent', 'enabled', 'expanded'];
     $form_links = $form['links'];

Should it be in the current scope?

catch’s picture

Limit the messages returned by type. Defaults to NULL, meaning all types.
* Passed on to drupal_get_messages(). These values are supported:

This says defaults to NULL, but there is no default. I think it'd be more self-explanatory to add a default arg, or to change the comment to not say 'defaults to NULL'.

voleger’s picture

StatusFileSize
new25.18 KB
new22.93 KB
new2.45 KB

Rerolled #33

Also addressed:
#34: Reverted changes that are out of scope.
#35: Added arg default value.

alexpott’s picture

Status: Needs review » Needs work

This issue should also be able to remove the messages from \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations() for drupal_set_message(). Any legacy tests of drupal_set_message() should be in the legacy test group and have an @expectedDeprecation annotation.

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new25.82 KB
new3.28 KB

I removed drupal_set_message and drupal_get_message from DeprecationListenerTrait and added @expectedDeprecation to \Drupal\KernelTests\Core\Common\DrupalSetMessageTest

voleger’s picture

Should comments in core/modules/system/tests/src/Functional/Bootstrap/DrupalSetMessageTest.php also be updated?
Update:
I guess not. Because those changes are out of scope. Maybe should this be updated in the followup issue if changes are required?

Anyway, +1 for RTBC.

martin107’s picture

Status: Needs review » Needs work

It think there is a overcomplication that should be stripped out

SiteConfigureForm extends ConfigFormBase extends FormBase

FormBase makes use of MessengerTrait.

So there is not need to inject the messenger service into SiteConfigureForm

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new24.31 KB
new1.79 KB

Less talk more do.

PS BTW This was close to RTBC ... I think it is now.

kim.pepper’s picture

StatusFileSize
new25.42 KB
new1.11 KB

Fix php 5.5 fails.

voleger’s picture

Status: Needs review » Reviewed & tested by the community

+1 for RTBC

alexpott’s picture

Can we get a follow up to fix the naming of:

  • The system_test.drupal_set_message route
  • The /system-test/drupal-set-message path
  • The SystemTestController::drupalSetMessageTest() method
  • The \Drupal\Tests\system\Functional\Bootstrap\DrupalSetMessageTest() test class

None of these things test drupal_set_message() anymore. Actually, lets use the parent issue to finally finish that one - #2924538: [META] Remove all usages of drupal_set_message and drupal_get_messages.

Crediting @catch and @jibran for reviews.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3c82d71 and pushed to 8.6.x. Thanks!

diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
index 9d05c27407..51f60b473a 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
@@ -3,7 +3,6 @@
 namespace Drupal\block_test\Plugin\Block;
 
 use Drupal\Core\Block\BlockBase;
-use Drupal\Core\Messenger\MessengerTrait;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\user\UserInterface;
 
diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
index 82eaaeff5d..2367981ad5 100644
--- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
+++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php
@@ -3,7 +3,6 @@
 namespace Drupal\views_test_data\Plugin\views\field;
 
 use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Messenger\MessengerTrait;
 use Drupal\views\Plugin\views\field\FieldPluginBase;
 use Drupal\views\Plugin\views\field\UncacheableFieldHandlerTrait;
 use Drupal\views\ResultRow;

fixed unused uses on commit.

  • alexpott committed 3c82d71 on 8.6.x
    Issue #2935255 by Jo Fitzgerald, kim.pepper, voleger, alexpott,...
tr’s picture

Can we get a change notice please, to notify us that MessengerTrait was added to a number of base classes? (which doesn't seem to be mentioned in the issue summary or discussed here ...)

drupal_set_message() was removed in 8.5.0, so I for one already converted my code to use the messenger service, which includes using MessengerTrait in my own plugin bases and list builders.

But as part of this patch for 8.6.x MessengerTrait was added to the core PluginBase, EntityListBuilder, BlockBase, etc. So now I get all sorts of errors from previously-working code. Adding MessengerTrait is a change in the core API for these important base classes, and there should be a change notice for this.

tr’s picture

Status: Fixed » Needs work

This should not have been committed without a change record. See Change records now needed before commit

markhalliwell’s picture

Status: Needs work » Fixed

#2937945: Add messenger to ControllerBase and FormBase added this trait and there is a CR for it: https://www.drupal.org/node/2774931

I've added a note (and referenced this issue) mentioning that a few base classes now have this trait.

Status: Fixed » Closed (fixed)

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

devad’s picture

Title: Remove all usages of drupal_get_message and drupal_set_message in core lib » Remove all usages of drupal_set_message and drupal_get_messages in core lib
Issue summary: View changes