Comments

Neslee Canil Pinto created an issue. See original summary.

neslee canil pinto’s picture

Status: Active » Needs review
StatusFileSize
new8.58 KB

Removed deprecated drupal_set_message()

samuel.mortenson’s picture

Status: Needs review » Needs work

@neslee-canil-pinto The messenger() method is not defined in any of the classes it's added to in this patch, and $this is not available in .module files (only in class methods).

sahana _n’s picture

Issue summary: View changes
StatusFileSize
new9.27 KB

Hi
I found some drupal_set_message deprecated method When I check the module with the "drupal-check" command.

------ ----------------------------------------------------------------------
Line src/StoreHandler.php
------ ----------------------------------------------------------------------
26 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
51 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
71 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------

------ ----------------------------------------------------------------------
Line src/ProductHandler.php
------ ----------------------------------------------------------------------
38 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
74 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
79 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
100 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
128 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
156 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
233 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/OrderHandler.php
------ ----------------------------------------------------------------------
30 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
64 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
84 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/CustomerHandler.php
------ ----------------------------------------------------------------------
50 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
89 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
109 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------

I created the patch Please review the patch.

sahana _n’s picture

Status: Needs work » Needs review
scottsawyer’s picture

Thank you for the patch, it's a good start. Honestly though, I am not sure why we need our own messager, why not just use Drupal's?

-    arguments: ['@mailchimp_ecommerce.database']
+    arguments: ['@mailchimp_ecommerce.database , @mailchimp_ecommerce.messenger']

Missing a single quote.

sahana _n’s picture

StatusFileSize
new536 bytes
new9.27 KB

Thanks for the review. ya we can use Drupal's messenger also, I created the patch for the single quote is missing please review the patch, if any mistakes are there please let me know
Thank you.

scottsawyer’s picture

Status: Needs review » Needs work

Thanks for continuing to plug away at this. There are 2 failures, though I am not sure if the second fail is directly related to this patch.

For the first fail:
I could be totally wrong, but

1) Drupal\Tests\mailchimp_ecommerce\Functional\MailchimpEcommerceTest::testConfigurationForm
Exception: Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Drupal\Core\Messenger' not found
Drupal\Component\DependencyInjection\Container->createService()() (Line: 255)

seems to me like the problem is in this service.

+  mailchimp_ecommerce.messenger:
+    class: Drupal\Core\Messenger\MessengerInterface
+    factory: Drupal\Core\Messenger::messenger
+    arguments: [default]

This is more of a general question, why do we need this service? Why not just do something like:

   mailchimp_ecommerce.customer_handler:
     class: '\Drupal\mailchimp_ecommerce\CustomerHandler'
+    arguments: ['@mailchimp_ecommerce.database' , '@messenger']
 
   mailchimp_ecommerce.order_handler:
     class: '\Drupal\mailchimp_ecommerce\OrderHandler'
 
   mailchimp_ecommerce.product_handler:
     class: '\Drupal\mailchimp_ecommerce\ProductHandler'
+    arguments: ['@messenger']
 
   mailchimp_ecommerce.store_handler:
     class: '\Drupal\mailchimp_ecommerce\StoreHandler'
+    arguments: ['@messenger']
 

Just curious, I just don't understand.

sahana _n’s picture

Status: Needs work » Needs review
StatusFileSize
new8.81 KB
new1.34 KB

Hi
Thanks for the review I have done changes in services please review the patch.

scottsawyer’s picture

Looks good from a visual inspection. I will try to test it on an install soon. Thank you for your effort.

samuel.mortenson’s picture

StatusFileSize
new15.22 KB
new9.19 KB

There was a lot of usage of these classes that wasn't covered - new patch should update all instances.

carsteng’s picture

In Relation to https://www.drupal.org/project/mailchimp_ecommerce/issues/3033720 I would prefer an option to hide...or remove the message completely.
There is no reason to present this message to a customer!

scottsawyer’s picture

I agree that these messages shouldn't be displayed by default. However, I feel like this issue is just about removing 'drupal_set_message' as it's deprecated code. I think we should address whether or not, and under what conditions messages like this should be shown in the other ( related ) issue.

If I understand correctly, samuel.mortenson is not going to be maintaining this module any more, so we'll need someone to step up.

aprice42’s picture

Assigned: Unassigned » aprice42
millenniumtree’s picture

Now fielding calls from confused customers when these errors appear during checkout. Whatever mechanism you use to print them, please also add a checkbox so we can disable these messages instead of having to comment them out for every composer run or new release.

xenophyle’s picture

Status: Needs review » Closed (duplicate)