Problem/Motivation

Using Bulk Update Content Fields throws "Creation of dynamic property" deprecation error. This will eventually block compatibility with PHP 9

Steps to reproduce

Install the Action and Bulk Update Fields modules.

  1. Create two or more pieces of content.
  2. Visit the content listing.
  3. Select two or more pieces of content.
  4. Select the "Bulk update content fields" action and press "Apply to selected items".
  5. See the following error message:
Deprecated function: Creation of dynamic property Drupal\bulk_update_fields\Form\BulkUpdateFieldsForm::$entity is deprecated in Drupal\bulk_update_fields\Form\BulkUpdateFieldsForm->buildForm() (line 219 of modules/contrib/bulk_update_fields/src/Form/BulkUpdateFieldsForm.php).
Drupal\bulk_update_fields\Form\BulkUpdateFieldsForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Proposed resolution

Update the form to make sure $entity is declared.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

byrond created an issue. See original summary.

byrond’s picture

I created an MR to add the property to the form, but it looks like it is never used outside of the buildForm() method. Could a local variable be used there instead, or does something else read this property elsewhere? It seems unlikely, because this property will only hold the last entity of the ones passed to the form.

koppie’s picture

Status: Active » Reviewed & tested by the community

Can confirm, this patch works with the latest dev version. Please merge. :-)

el1_1el’s picture

Status: Reviewed & tested by the community » Fixed

Added to alpha8

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.