Problem/Motivation

Finding a major problem with a clean installation on Drupal 9

After creating a new event series it is not possible to edit an event instance. A WSOD is seen and the following is recorded in the DB Log

ArgumentCountError: Too few arguments to function Drupal\Core\Entity\ContentEntityForm::__construct(), 1 passed in /var/www/html/web/modules/contrib/recurring_events/src/Form/EventInstanceForm.php on line 69 and exactly 3 expected in Drupal\Core\Entity\ContentEntityForm->__construct() (line 56 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php)
#0 /var/www/html/web/modules/contrib/recurring_events/src/Form/EventInstanceForm.php(69): Drupal\Core\Entity\ContentEntityForm->__construct(Object(Drupal\Core\Entity\EntityRepository))
#1 /var/www/html/web/modules/contrib/recurring_events/src/Form/EventInstanceForm.php(49): Drupal\recurring_events\Form\EventInstanceForm->__construct(Object(Drupal\Core\Entity\EntityRepository), Object(Drupal\Core\Messenger\Messenger), Object(Drupal\Core\Session\AccountProxy), Object(Drupal\Component\Datetime\Time))
#2 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\recurring_events\Form\EventInstanceForm::create(Object(Drupal\Core\DependencyInjection\Container))
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(226): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('Drupal\\recurrin...')
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php(69): Drupal\Core\Entity\EntityTypeManager->getFormObject('eventinstance', 'edit')
#5 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(58): Drupal\Core\Entity\HtmlEntityFormController->getFormObject(Object(Drupal\Core\Routing\RouteMatch), 'eventinstance.e...')
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(705): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}

Steps to reproduce

1. Spin up a clean D9 installation and install Development version: 2.0.x-dev updated 5 Aug 2020 at 16:37 UTC
2. Create a new event series and then attempt to edit one of the event instances

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

MrPaulDriver created an issue. See original summary.

owenbush’s picture

Thanks for this issue. I was hoping to keep the 8.x-1.0-dev and 2.0.0-dev in sync but it's looking like something changed in D9 which means I need make the 2.0.0 release a D9 only version.

I'll get this reviewed and roll a patch

owenbush’s picture

Status: Active » Needs review
StatusFileSize
new4.64 KB

Attached is a patch to fix this issue - it was also applicable to editing Registrants. The problem seems that the definition of the ContentEntityForm class went from having the last 2 arguments (EntityTypeBundleInfoInterface $entity_type_bundle_info and TimeInterface $time) as optional arguments, to having them as required arguments.

The good news is this patch will apply for both the D8 and D9 versions, so I may not need a version split at this point.

mrpauldriver’s picture

Status: Needs review » Reviewed & tested by the community

I haven't tested with registrants, but this fixes the problem I described in the OP.

Thank you

  • owenbush committed e49a60b on 2.0.x
    Issue #3164160 by owenbush, MrPaulDriver: ArgumentCountError : Drupal 9...

  • owenbush committed c7e0680 on 8.x-1.x
    Issue #3164160 by owenbush, MrPaulDriver: ArgumentCountError : Drupal 9...
owenbush’s picture

Status: Reviewed & tested by the community » Fixed

This has been merged and marked as fixed.

Status: Fixed » Closed (fixed)

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

dr. gubó’s picture

Hey, sorry for the issue necromancy, but I'm getting the very same error when trying to delete event series or instances.
"ArgumentCountError: Too few arguments to function Drupal\Core\Entity\ContentEntityForm::__construct(), 1 passed in ..."

  • "EventSeriesDeleteForm.php on line 77" - when trying to delete Event series
  • "EventInstanceDeleteForm.php on line 52" - when trying to delete Event instances.

Looking at the committed patch, maybe the same modifications need to be done to the above mentioned 2 files?

I'm on Drupal 9.1.3 and the errors happen with both current 1.x dev and 2.x dev versions of the module.

owenbush’s picture

Status: Closed (fixed) » Needs work
Issue tags: +rc eligible

Thanks for raising the issue. I'll take a look.

owenbush’s picture

Status: Needs work » Needs review
StatusFileSize
new4.32 KB

Attached is a patch to resolve the issue with event series and instance deletion

dr. gubó’s picture

StatusFileSize
new135.55 KB

Thanks, I can confirm event series and event instance deletion works with the latest patch.

Might be unrelated, but on event instance deletion I see empty list items on the confirmation screen. According to the message I should see the event instance dates listed. (See image.)

screenshot

All event instances get deleted properly though.

  • owenbush committed 2920ce2 on 2.0.x
    Issue #3164160 by owenbush, dr. gubó: ArgumentCountError : Drupal 9 only
    

  • owenbush committed a571869 on 8.x-1.x
    Issue #3164160 by owenbush, dr. gubó: ArgumentCountError : Drupal 9 only
    
owenbush’s picture

Status: Needs review » Fixed

The issue with deletion and the missing dates has now been merged into the latest dev release of the module.

Status: Fixed » Closed (fixed)

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