How to upgrade the most common problems found in Drupal 9 themes for Drupal 10 compatibility
.theme file in theme root:
Find |
Replace with |
$node_content = render($node_content); |
$node_content = \Drupal::service('renderer')->render($node_content); |
$node_comments = render($node_comments); |
$node_comments = \Drupal::service('renderer')->render($node_comments); |
Amend deprecated functions in .theme file:
Find |
Replace with |
file_create_url |
\Drupal::service('file_url_generator')->generateAbsoluteString |
file_url_transform_relative |
\Drupal::service('file_url_generator')->transformRelative |
file_url_transform_relative(file_create_url |
\Drupal::service('file_url_generator')->generateString |
Drupal\Core\Url::fromUri(file_create_url |
\Drupal::service('file_url_generator')->generate |
drupal_get_path |
\Drupal::service('extension.path.resolver')->getPath |
In page.html.twig
Find |
Replace with |
mt-no-opacity |
_ |
fade |
_ |
In .libraries.yml file
Find |
Replace with |
core/jquery.once |
core/once |
In any html.twig Template files
Find |
Replace with |
{% spaceless %} |
{% apply spaceless %} |
{% endspaceless %} |
{% endapply %} |