Deprecated function with Drupal 9.5.3 Installation with PHP 8.2

Created on 24 February 2023, almost 2 years ago
Updated 5 June 2023, over 1 year ago

Problem/Motivation

While installing Drupal 9.5.3 with PHP 8.2.0 and MySQL 8.0.31
Getting this error on Step 5:

Error message

Deprecated function: Use of "static" in callables is deprecated in Drupal\user\Entity\Role::postLoad() (line 172 of core\modules\user\src\Entity\Role.php).
Drupal\user\Entity\Role::postLoad(Object, Array) (Line: 423)
Drupal\Core\Entity\EntityStorageBase->postLoad(Array) (Line: 353)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 16)
Drupal\user\RoleStorage->isPermissionInRoles('access administration pages', Array) (Line: 112)
Drupal\Core\Session\UserSession->hasPermission('access administration pages') (Line: 105)
Drupal\Core\Session\AccountProxy->hasPermission('access administration pages') (Line: 363)
user_template_preprocess_default_variables_alter(Array, NULL, NULL) (Line: 562)
Drupal\Core\Extension\ModuleHandler->alter('template_preprocess_default_variables', Array) (Line: 1308)
_template_preprocess_default_variables() (Line: 1277)
template_preprocess(Array, 'html', Array)
call_user_func_array('template_preprocess', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 148)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 147)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 1058)
install_display_output(Array, Array) (Line: 161)
install_drupal(Object) (Line: 48)

Steps to reproduce

Install Fresh using the Drupal 9.5.3 ZIP with PHP 8.2.0 and MySQL 8.0.31

🐛 Bug report
Status

Closed: works as designed

Version

9.5

Component
Entity 

Last updated about 12 hours ago

Created by

🇮🇳India adminazhar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adminazhar
  • 🇨🇭Switzerland lomale@bluewin.ch Switzerland

    I had the same experience.
    I run Drupal 9.5.3 since a while.
    Then i changed to PHP 8.2
    and get a bunch of errors

    Deprecated function: Creation of dynamic property Drupal\views\ManyToOneHelper::$handler is deprecated in Drupal\views\ManyToOneHelper->__construct() (Zeile 24 in /home/webXXX/www/test.istdp.ch/core/modules/views/src/ManyToOneHelper.php)

    Deprecated function: Use of "static" in callables is deprecated in Drupal\user\Entity\Role::postLoad() (Zeile 172 in /home/webXXX/www/test.istdp.ch/core/modules/user/src/Entity/Role.php)

    Deprecated function: Use of "static" in callables is deprecated in Drupal\Core\Asset\AssetResolver->getCssAssets() (Zeile 163 in /home/webXXX/www/test.istdp.ch/core/lib/Drupal/Core/Asset/AssetResolver.php)

    I moved back to PHP 8.1.6 and these logs went away.

    I'm not a PRO. So no idea. Maybe it will help the core maintainers.

  • Status changed to Closed: works as designed almost 2 years ago
  • 🇬🇧United Kingdom longwave UK

    Drupal 9 does not support PHP 8.2; see https://www.drupal.org/docs/system-requirements/php-requirements#versions

    Use PHP 8.1 for now, then upgrade to Drupal 10 before upgrading to PHP 8.2.

  • 🇭🇺Hungary djg_tram

    @longwave That doesn't really help because D10 is also full of deprecated message (including this one).

    Being warnings, things are not critical per se, but this makes the log practically unusable. So, some co-ordinated effort to root out these deprecated things would be very welcome. :-) Yes, I know, everybody is free to contribute but not all of us are actively participating in core. So, the question is whether you, who do, can at least inform us whether this is something that is currently undertaken or not.

  • 🇬🇧United Kingdom longwave UK

    @djg_tram please search for existing issues if you are finding PHP 8.2 deprecation messages in Drupal 10, and open a new issue if you can't find a relevant one - Drupal 10 has many deprecations already fixed compared to Drupal 9, and we are happy to fix more as they are found in the Drupal 10 branches.

  • 🇺🇸United States pthurmond Overland Park, KS

    Looks like Drupal 9 DOES support PHP 8.2. And anyway I get this error in PHP 7.4 and 8.1. So that isn't the problem. Why in the world was this deprecation setup without fixing all the places in core first? That seems like an oversight.

    It seems to me that this ticket should be about fixing the cause of the deprecation by making all the right changes and not just reporting the issue.

  • patrick.thurmond@gmail.com:

    These are PHP language deprecations, not something that Drupal deprecated. Drupal is subject to them, not causing them.

Production build 0.71.5 2024