Problem/Motivation

In Drupal 8.5.0 drupal_set_message() is deprecated in favor the Messenger service. See the change record at #2774931: drupal_set_message() and drupal_get_messages() replaced by Messenger service

Proposed resolution

  • Replace drupal_set_message() with the Messenger service
  • Raise minimum Drupal version to 8.5.x

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

idebr created an issue. See original summary.

rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10
rajeshwari10’s picture

Assigned: rajeshwari10 » Unassigned
Status: Active » Needs review
StatusFileSize
new2.64 KB

Hi,

I have replaced the drupal_set_message with the Messenger Service. Added patch, Please review.

Thanks

tessa bakker’s picture

Priority: Normal » Minor
Status: Needs review » Needs work

Hi Rajeshwari,

Thanks for you work on the patch, here are some points for improvement:

* Update guardian.services.yml with the messenger service.
* Add a dependency for Drupal Core 8.5 in guardian.info.yml, see https://www.drupal.org/node/2000204 for more information.

rajeshwari10’s picture

Status: Needs work » Needs review
StatusFileSize
new3.32 KB

Hi Tessa,

Thanks for the Review. I worked on your suggestions. Added the patch. Please review.

Thanks

idebr’s picture

Status: Needs review » Needs work

@rajeshwari10 Thanks for working on this issue. I would like to suggest a few minor changes before this is ready to be committed:

  1. +++ b/guardian.info.yml
    @@ -4,3 +4,5 @@ description: Requires users to log in with only password reset or drush uli.
    +dependencies:
    +  - 'drupal:system(>=8.5.999)'
    

    This notation seems a little off. Let's use a similar notation as the Search API: #2961537: Increase Core dependency to Drupal 8.5

    dependencies:
      - system (>=8.5)
    
  2. +++ b/src/GuardianManager.php
    @@ -89,6 +90,13 @@ final class GuardianManager implements GuardianManagerInterface {
       /**
    +   * The messenger service
    +   *
    +   * @var \Drupal\Core\Messenger\MessengerInterface
    +   */
    +  protected $messenger;
    

    The doc comment short description should end with a full stop.

tessa bakker’s picture

Change of plans: There is a MessengerTrait available in Core. By using the trait, the Messenger doesn't need to be injected anymore.

See: \Drupal\Core\Messenger\MessengerTrait

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new3.88 KB
new1.98 KB

Attached patch fixes the following remarks:

#6.1 Updated dependency on Drupal 8.5.x in the guardian.info.yml file

#6.2 The property description is no longer applicable because of

#7 Replaced the injected messengerService with the MessengerTrait

  • idebr authored 0ed810d on 8.x-1.x
    Issue #2941390 by rajeshwari10, idebr: Replace deprecated...
tessa bakker’s picture

Status: Needs review » Fixed

Thanks for the patch!

Status: Fixed » Closed (fixed)

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