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

  1. Create a repeating event.
  2. Manage the repeating event instances.
  3. 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

Comments

collinhaines created an issue. See original summary.

collinhaines’s picture

Status: Active » Needs review
StatusFileSize
new13.01 KB

I found all instances of new Instances(); and replaced it with ClassResolverInterface::getInstanceFromDefinition().

It appears that on the SmartDateOverrideForm, the form_builder service 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 the form_builder service from this form class.

mandclu’s picture

This 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?

  • mandclu committed fd5b3cd2 on 3.7.x
    Issue #3342139 by collinhaines: Cannot remove recurring instance
    
mandclu’s picture

I 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!

  • mandclu committed 0b000f13 on 4.0.x
    Issue #3342139 by collinhaines: Cannot remove recurring instance
    

  • mandclu committed fd5b3cd2 on 4.0.x
    Issue #3342139 by collinhaines: Cannot remove recurring instance
    
mandclu’s picture

Version: 3.7.x-dev » 4.0.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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