I ran phpstan and this is the deprecated code that we need to fix:

./vendor/bin/phpstan analyse  web/modules/contrib/comment_notify/
Note: Using configuration file /var/www/drupalvm/drupal/phpstan.neon.
 12/12 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------
  Line   comment_notify.inc
 ------ ------------------------------------------------------------
  30     Call to deprecated function db_select().
  67     Call to deprecated function db_delete().
  134    Call to deprecated function db_update().
  138    Call to deprecated function db_insert().
  162    Call to deprecated function db_select().
  170    Call to deprecated function db_update().
  182    Call to deprecated function db_insert().
  203    Call to deprecated function db_delete().
  220    Call to deprecated function db_update().
  238    Call to deprecated function db_select().
  257    Call to deprecated function db_query().
  263    Call to deprecated method entityManager() of class Drupal.
  280    Call to deprecated function db_update().
  315    Call to deprecated function db_update().
  334    Call to deprecated function db_select().
  350    Call to deprecated function db_query().
  358    Call to deprecated function db_update().
  367    Call to deprecated function db_update().
 ------ ------------------------------------------------------------

 ------ ---------------------------------------------------------------------------------------------------------------------------------
  Line   comment_notify.migrate.inc
 ------ ---------------------------------------------------------------------------------------------------------------------------------
         Class CommentNotifyMigrationHandler was not found while trying to analyse it - autoloading is probably not configured properly.
 ------ ---------------------------------------------------------------------------------------------------------------------------------

 ------ -------------------------------------------------------------------------------
  Line   comment_notify.module
 ------ -------------------------------------------------------------------------------
  234    Call to deprecated method entityManager() of class Drupal.
  335    Call to deprecated function db_select().
  382    Call to deprecated method entityManager() of class Drupal.
  467    Call to deprecated method strlen() of class Drupal\Component\Utility\Unicode.
  467    Call to deprecated method substr() of class Drupal\Component\Utility\Unicode.
 ------ -------------------------------------------------------------------------------


 [ERROR] Found 24 errors

---

Comments

Pavan B S created an issue. See original summary.

Pavan B S’s picture

Status: Active » Needs review
StatusFileSize
new6.61 KB

Applying the patch

greggles’s picture

Title: Remove depreciated Database queries » Remove deprecated database queries

Thanks for providing this patch! Can you point to some documentation for how/when to use this new style?

gnuget’s picture

I can help with that.

https://api.drupal.org/api/drupal/core!includes!database.inc/function/db...

In particular:

Deprecated

as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call query() on it. For example, $injected_database->query($query, $args, $options);

Eventually, on #2618168: Move procedural code into service we are going to change this again and inject the service instead to use \Drupal::database() That makes me wonder if this is worth it or if it would better to wait until move this into a service and do the change there?

gnuget’s picture

Pavan B S’s picture

Assigned: Pavan B S » Unassigned
gnuget’s picture

Title: Remove deprecated database queries » Remove deprecated code.
Issue summary: View changes

Instead to just remove the deprecate database code, let's remove all the deprecated code, so Drupal 9 can use this module since the day 1.

gnuget’s picture

Status: Needs review » Needs work
gnuget’s picture

Status: Needs work » Needs review
StatusFileSize
new9.3 KB

I replaced the deprecated code.

Status: Needs review » Needs work

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

gnuget’s picture

Status: Needs work » Needs review
StatusFileSize
new762 bytes
new9.3 KB

duh!

new patch.

  • gnuget committed e8ae6c7 on 8.x-1.x
    Issue #2853436 by gnuget, Pavan B S: Remove deprecated code
    
gnuget’s picture

Status: Needs review » Fixed

This module is ready for Drupal 9, yay!

Status: Fixed » Closed (fixed)

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