Problem/Motivation
SettingsForm's constructor declares its injected services ($entityTypeManager, $entityFieldManager, $aiProvider) as readonly.
ConfigFormBase/FormBase use core's DependencySerializationTrait, which reassigns these properties in __wakeup() after the form is unserialized (e.g. from cache/batch/queue). PHP forbids reinitializing a readonly property from outside its declaring class scope, so this throws:
Error: Cannot initialize readonly property Drupal\ai_audio_generator\Form\SettingsForm::$entityTypeManager from scope
Drupal\Core\Form\FormBase in Drupal\Core\Form\FormBase->__wakeup() (line 80 of core/lib/Drupal/Core/DependencySerializationTrait.php). Proposed resolution
Remove readonly from the three constructor-promoted properties — incompatible with DependencySerializationTrait.
- protected readonly EntityTypeManagerInterface $entityTypeManager,
- protected readonly EntityFieldManagerInterface $entityFieldManager,
- protected readonly AiProviderPluginManager $aiProvider,
+ protected EntityTypeManagerInterface $entityTypeManager,
+ protected EntityFieldManagerInterface $entityFieldManager,
+ protected AiProviderPluginManager $aiProvider,
Issue fork ai_audio_generator-3611977
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
Comment #4
nnevillComment #6
scott_euser commentedLooks like this introduced phpstan issue though
Comment #7
nnevillFound 21 phpstan issues - will create a follow-up issue