Problem/Motivation
On the latest Smart Date v3.7, attempting to remove a recurring instance in the smart_date_recur submodule throws a WSOD:
ArgumentCountError: Too few arguments to function Drupal\smart_date_recur\Controller\Instances::__construct(), 0 passed in modules/contrib/smart_date/modules/smart_date_recur/src/Form/SmartDateRemoveInstanceForm.php on line 143 and exactly 2 expected in Drupal\smart_date_recur\Controller\Instances->__construct() (line 73 of modules/contrib/smart_date/modules/smart_date_recur/src/Controller/Instances.php).
Steps to reproduce
- Create a repeating event.
- Manage the repeating event instances.
- Remove the instance.
Proposed resolution
Every instance of new Instances(); should be generated by the class_resolver service since we're generating a controller. This will also setup future proofing for when the Instances controller has any services added/removed from it.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | smart_date-new-instances-failure-3342139-2.patch | 13.01 KB | collinhaines |
Comments
Comment #2
collinhaines commentedI found all instances of
new Instances();and replaced it withClassResolverInterface::getInstanceFromDefinition().It appears that on the
SmartDateOverrideForm, theform_builderservice was only being injected to be used as a constructor parameter. Since that was it's only usage and the controller initialization was replaced, I removed theform_builderservice from this form class.Comment #3
mandclu commentedThis sounds a lot like an issue I encountered while testing the 4.0.x branch. That was documented and a fix committed at #3341820: Fatal Error: missing arguments when using remove instance form.
Your proposed code changes look similar to the changes committed in that issue. Can you validate if there's a difference or if that commit could be backported to 3.7.x?
Comment #5
mandclu commentedI decided that the changes here are a better approach and more comprehensive than the changes in #3341820: Fatal Error: missing arguments when using remove instance form, in addition to being written for 3.7.x. I have reverted the changes there and merged in your patch. Thanks for your work on this!
Comment #8
mandclu commented