Upgrade your custom modules to be Drupal 10 and PHP 8.1 compliant
Guidance on how to upgrade your custom modules to be Drupal 10 and PHP 8.1 compliant.
The following sections provide examples of the most common updates that you might need to make. However, you must check the deprecation lists for Drupal and PHP to ensure that you cover all of the scenarios in your Developer Portal sites.
Notable changes the update brings
The following items are some of the key changes in Drupal 10.
-
CKEditor4
is removed andCKEditor5
is now the default text editor. -
Claro
is now the default theme for the Admin UI, which gives it a modern and refreshing look. -
Ensure that none of your custom modules depend on them as they will not be there after the upgrade.
The following modules are uninstalled as they do not support Drupal 10:-
ckeditor_media_embed
-
console
-
flood_unblock
-
message
-
message_notify
-
message_subscribe
-
video_embed_field
-
video_embed_html5
-
content_browser
-
entity_browser
-
entity_browser_enhanced
-
entity_embed
-
file_browser
-
editor_file
-
color
-
Unlimited_number
-
embed
-
ckeditor
-
quickedit
-
-
The Drupal 10 upgrade comes with a major Symfony upgrade version. Drupal 9 used Symfony 4.4, and Drupal 10 now uses Symfony 6, so if you are using any Symfony ensure that they have not been deprecated. Symfony provides a guide at the following link https://symfony.com/doc/current/setup/upgrade_major.html.
-
The default Drush version is now Drush 11. If you are writing Drush commands in your custom modules, you must ensure they are Drush 11 compatible. The following links provide examples on how you can achieve compatibility, https://www.specbee.com/blogs/writing-your-own-custom-drush-9-and-10-commands and https://www.drush.org/11.x/commands/.
PHP 8.1 deprecations
The following items are some of the key PHP 8.1 deprecations.
- Passing null to non-nullable internal function parameters is deprecated
- There are multiple scenarios that require a fix with the possibility to pass a
null
to some PHP functions.
- Optional parameters specified before the required parameters
- Some functions in code have optional parameters before the required ones. However, in PHP 8.1, the required parameters come after the optional ones.
- Improved type safety
- PHP 8.1 improves the type of safety, which can result in numerous warnings that might require changing functions and variable declarations.
Drupal 10 deprecations
The following items are some of the key PHP 8.1 deprecations.
- Entity queries now require an
accessCheck
- If you have custom modules with entities, you must do an
accessCheck
. For more information about access checking, see https://www.drupal.org/node/3201242.
- The
Once
function is removed from the jQuery library and added to its own core library - If you have any modules that use the
once
function in your JavaScript files, you need an update to pull in the new library. For more information about how to remove jQuery dependency, see https://www.drupal.org/node/3158256.
- The
app.root
andsite.path
services that are converted into container parameters - If you use the
app.root
andsite.path
services in your custom modules, you must ensure they are converted into container parameters. - The parameters of some
Forms
are updated, so be aware if you are extending them. - If you are extending your
Forms
, note the parameters of some of them have changed. For more information about the updated parameters, see https://www.drupal.org/node/3251987.
Next steps
This topic covers the key upgrades you might need when upgrading your custom modules to be Drupal 10 and PHP 8.1 compliant. However, note that it is your responsibility to check the deprecation lists for Drupal and PHP to ensure that you cover all of the scenarios in your Developer Portal sites.