Problem/Motivation
When accessing a content entity type, like "User", which does not have a bundle entity type (null is returned with getBundleEntityType), on PHP 8.5, a deprecation warning is issued:
Deprecated function: Using null as an array offset is deprecated, use an empty string instead in ds_contextual_links_view_alter() (linje 728 in /app/platform_drupal_11_4_x/modules/patched/ds/ds.module)
#0 /app/platform_drupal_11_4_x/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 /app/platform_drupal_11_4_x/modules/patched/ds/ds.module(728): _drupal_error_handler()
#2 /app/platform_drupal_11_4_x/core/lib/Drupal/Core/Extension/ModuleHandler.php(460): ds_contextual_links_view_alter()
#3 /app/platform_drupal_11_4_x/core/modules/contextual/src/Element/ContextualLinks.php(96): Drupal\Core\Extension\ModuleHandler->alter()
...
When using submodule "ds_switch_view_mode", method "ds_switch_view_mode_form_node_form_alter" line 124:
Deprecated function: Using null as an array offset is deprecated, use an empty string instead in ds_switch_view_mode_form_node_form_alter() (linje 124 af /app/platform_drupal_11_4_x/modules/patched/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module)
#0 /app/platform_drupal_11_4_x/core/includes/bootstrap.inc(104): _drupal_error_handler_real()
#1 /app/platform_drupal_11_4_x/modules/patched/ds/modules/ds_switch_view_mode/ds_switch_view_mode.module(124): _drupal_error_handler()
#2 /app/platform_drupal_11_4_x/core/lib/Drupal/Core/Extension/ModuleHandler.php(460): ds_switch_view_mode_form_node_form_alter()
#3 /app/platform_drupal_11_4_x/core/lib/Drupal/Core/Form/FormBuilder.php(897): Drupal\Core\Extension\ModuleHandler->alter()
#4 /app/platform_drupal_11_4_x/core/lib/Drupal/Core/Form/FormBuilder.php(300): Drupal\Core\Form\FormBuilder->prepareForm()
#5 /app/platform_drupal_11_4_x/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
...
Steps to reproduce
- Install Drupal 11.4
- Activate dblog
- Install and activate DS version 3.37
- Add a DS block to the user page, so it's shown on /user/1 (for admin).
- Observe dblog (/admin/reports/dblog) or the message field for the deprecation warning.
Proposed resolution
See attached patch.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
flemming.fridthjof commentedComment #3
cosmin-hm commentedThank you for the patch, it works.
Comment #4
flemming.fridthjof commentedMinor fix to patch in modules/ds_switch_view_mode/ds_switch_view_mode.module