Fix PHP 8.2 Deprecated function: Creation of dynamic property $renderer

Created on 14 December 2023, about 1 year ago
Updated 16 April 2024, 8 months ago

Problem/Motivation

While installing Varbase FAQs with PHP 8.2

Deprecated function: Creation of dynamic property Drupal\varbase_faqs\Plugin\Block\FaqPageBlock::$renderer is deprecated in Drupal\varbase_faqs\Plugin\Block\FaqPageBlock->__construct() (line 93 of modules/contrib/varbase_faqs/src/Plugin/Block/FaqPageBlock.php).
Drupal\varbase_faqs\Plugin\Block\FaqPageBlock->__construct(Array, 'faqs_list', Array, Object, Object, Object, Object, Object, Object) (Line: 100)
Drupal\varbase_faqs\Plugin\Block\FaqPageBlock::create(Object, Array, 'faqs_list', Array) (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('faqs_list', Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance('faqs_list', Array) (Line: 243)
Drupal\layout_builder\SectionComponent->getPlugin() (Line: 87)
Drupal\layout_builder\InlineBlockEntityOperations->getInlineBlockComponents(Array) (Line: 164)
Drupal\layout_builder\InlineBlockEntityOperations->handlePreSave(Object) (Line: 201)
layout_builder_entity_presave(Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'layout_builder') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_presave', Object) (Line: 408)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array) (Line: 217)
Drupal\Core\Entity\EntityStorageBase->invokeHook('presave', Object) (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 529)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 483)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 305)
Drupal\default_content\Importer->importContent('varbase_faqs') (Line: 15)
default_content_modules_installed(Array, )
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'default_content') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('modules_installed', Object) (Line: 408)
Drupal\Core\Extension\ModuleHandler->invokeAll('modules_installed', Array) (Line: 381)
Drupal\Core\Extension\ModuleInstaller->install(Array, 1) (Line: 83)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array) (Line: 175)
Drupal\system\Form\ModulesListConfirmForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('system_modules_non_stable_confirm_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

Add the $renderer property to the class
Not to keep the __construct and create functions set them as it was working with PHP 8.1, but no longer in PHP 8.2 and PHP 8.3

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ✅ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ✅ Code review from 1 Varbase core team member
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Update Release Notes and Update Helper on new feature change/addition
  • ✅ Release varbase-10.0.0-rc2 varbase-9.0.18 , varbase_faqs-9.0.10 , Varbase 9.1.1 , varbase_faqs-9.1.2 , varbase_faqs-10.0.0-beta3

Varbase update type

  • ✅ No Update
  • ➖ Optional Update
  • ➖ Forced Update
  • ➖ Forced Update if Unchanged

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Issue #3408876 : Fixed PHP 8.2 Deprecated function: Creation of dynamic property $renderer
🐛 Bug report
Status

Fixed

Version

10.0

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

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

Comments & Activities

Production build 0.71.5 2024