Friday, March 20, 2020

Check deprecation and Make your project Drupal 9 compatible


Hello Drupalers,

As we know Drupal 9 will be release at 3rd of june 2020.

Drupal 9 = Drupal 8 - remove deprecation + increase dependency package


you are here because you also want to know ->

  • How we can make our project Drupal 9 compatible ? 
  • How we can check deprecated code ?


Drupal-check :- We can check all deprecated method using the "drupal-check".


Drupal check will provide you a result based on your project which deprecated method you used in your code and in the place of that code what should we should.


Install Drupal -check : - Download package using below command

 curl -O -L https://github.com/mglaman/drupal-check/releases/latest/download/drupal-check.phar  
 mv drupal-check.phar /usr/local/bin/drupal-check  
 chmod +x /usr/local/bin/drupal-check  


Composer :-
You can install this in your project using Composer as a development dependency like so:

 composer require mglaman/drupal-check --dev  


You can also install this globally using Composer like so:


 composer global require mglaman/drupal-check  


 Check Deprecation :- Now your system is ready to check any Drupal check with deprecation then you can make the project compatible with Drupal 9

If you installed drupal-check locally, open your terminal and run below command.

 lenovo@lenovo-ThinkPad-L450:/var/www/html/drupal_directory $ vendor/bin/drupal-checck web/modules/contrib/module_name  



If there is any error you will be able to see result like :-


  21   Call to deprecated function db_select():                  
      in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get       
      a database connection injected into your service from the container and   
      call select() on it. For example,                      
  ------ -------------------------------------------------------------------------  
  [ERROR] Found 1 errors  


Now you can remove deprecated code and make its Drupal 9 compatible.



How Drupal will know your project Drupal 9 compatible ?

Here is a way to let know Drupal.org that our module is Compatible with Drupal 8 and Drupal 9

 core_version_requirement: ^8 || ^9  


Add this line in your project info file. If want to know more about core_version_requirement see core_version_requirement



I hope guys you like this, if you have any suggestion and correcction feel free to comment here. Thanks 😊

No comments:
Write comments