Problem/Motivation

Since updating to 3.6 and then trying 3.7 and then 3.7dev the error below has broken all Layout Builder displays and produces "The website has encountered a error please try again later." message on every page.

The website encountered an unexpected error. Please try again later.
Error: Non-static method Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::augmentOutput() cannot be called statically in Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::buildOutput() (line 388 of modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php).
Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::buildOutput() (Line: 197)
Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter->viewElements() (Line: 89)
Drupal\Core\Field\FormatterBase->view() (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 266)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple() (Line: 340)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 24)
Drupal\node\NodeViewBuilder->buildComponents() (Line: 282)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 772)
Drupal\Core\Render\Renderer->doCallback() (Line: 363)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 157)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 158)
Drupal\Core\Render\Renderer->renderPlain() (Line: 525)
Drupal\node\Plugin\Search\NodeSearch->indexNode() (Line: 489)
Drupal\node\Plugin\Search\NodeSearch->updateIndex() (Line: 121)
search_cron() (Line: 249)
Drupal\Core\Cron->Drupal\Core\{closure}() (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 257)
Drupal\Core\Cron->invokeCronHandlers() (Line: 136)
Drupal\Core\Cron->run() (Line: 75)
Drupal\Core\ProxyClass\Cron->run() (Line: 65)
Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 103)
Symfony\Component\HttpKernel\HttpKernel->terminate() (Line: 32)
Stack\StackedHttpKernel->terminate() (Line: 687)
Drupal\Core\DrupalKernel->terminate() (Line: 22)

This site extensively uses Smart Date and has been opperating nearly flawlessly for the last 9 months. Thank you for all you do!

Comments

jon.lund created an issue. See original summary.

mandclu’s picture

It took a little doing to reproduce this error. Based on my testing it only seems to happen with newer versions of PHP (probably >= 8.0 but not sure) and an active augmenter.

I thought I could resolve this by making that method static, but that quickly turned into a rabbit hole. I may need to re-examine why it needs to be called statically.

jon.lund’s picture

I am using php 8.1.12

I had tried to make the method static and found the rabbit hole before posting here. (I should have added that to my original post.)

I uninstalled all augmentors and that did get rid of the error message and also allows the layout builder to work. I can live with this for now, we did enjoy using the Add to Cal link augmentor. We use the Smart Date extensively on our site and could not live without it.

Thank you for looking into this.

hhvardan’s picture

@jon.lund please add more details how to reproduce the error.
I've upgraded module to 3.7-dev version and everything looks ok on D10, PHP version 8.1.10

jon.lund’s picture

This seems to be where I run into problems:

  1. Using the Layout Builder
  2. Add the When field
  3. Setting the Formatter to Recurring (This seems to be the issue)
  4. Use any Augmentor

This works:

  1. Using the Layout Builder
  2. Add the When field
  3. Setting the Formatter to Smart Date Formatter (This does not allow for controlling the display of past and future events. Which includes treating the current event as a future event which adds the link for Add to Calendar to the current event)
  4. Only tested the successful use of the Add to Calendar augmentor

You are welcome to view the site here

mandclu’s picture

Version: 3.7.x-dev » 4.0.x-dev

PHP 8.1 seems to be much more strict about mixing static and non-static code. In the 4.0.x branch I plan to remove the static availability of as many methods as possible, in favour of making services available instead. I decided to make this change as part of a new major version because this shift could be a breaking change for other code that expects these methods to be available statically.

mandclu’s picture

Title: Website has encountered an error/ Every page since update to 3.6 and then 3.7 » Error: Non-static method SmartDateRecurrenceFormatter::augmentOutput() cannot be called statically
Status: Active » Needs review
StatusFileSize
new26.59 KB

Here's a patch that seems to resolve the issue for me. This is targeted to 4.0.x for when it would be released but it should apply on the recent 3.7.0 release as well.

chanelwheeler’s picture

I just ran into the same error while upgrading to 3.7. I have PHP 8.1 also. I applied the patch which fixed the problem when you click on the event in the calendar. However, if, for one of those events, I click the Edit tab, I get the error:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "smart_date_recur.manager". Did you mean this: "smart_date.manager"? in Drupal\Component\DependencyInjection\Container->get() (line 157 of /var/www/html/yln/web/core/lib/Drupal/Component/DependencyInjection/Container.php).

I am using Add to Calendar Date Augmenter, Date Content Augmenter, and Date Augmenter.

mandclu’s picture

StatusFileSize
new26.77 KB

@chanelwheeler thanks for the feedback. Just to confirm, had you cleared the caches after applying the patch?

Here's a new patch, please let me know if it's any better with the new error.

chanelwheeler’s picture

Drush cr is my first solution to everything. :) I applied the patch but I'm still getting the same error when I click Edit.

mandclu’s picture

Hmmm if you go into the logged errors does it give you a stack trace at all?

chanelwheeler’s picture

Unfortunately not.

mandclu’s picture

So far I haven't been able to reproduce your error. Are you using the 1.1.0-alpha1 release for the Add to Calendar Date Augmenter? And are you using the 1.1.0-beta1 release for the Date Augmenter API?

chanelwheeler’s picture

I'm using 1.0 for both Add to Calendar and Date Augmenter. Should I upgrade?

mandclu’s picture

If you don't mind trying it would be good to validate if the versions have any impact. I also tried uninstalling smart_date_recur on my side but I still can't get your error.

chanelwheeler’s picture

I upgraded both, cleared the cache, and went through the same steps. I still get the same error.

mandclu’s picture

Is it possible for you to be more descriptive of the steps you're following? What calendar are you using? Do you have smart_date_recur enabled? One of the other comments mentioned Layout Builder. Are you using that?

chanelwheeler’s picture

I'm using fullcalendar_view, datetime, and datetime_range as well as the aforementioned modules. I have Smart Date Recurring enabled. I don't have Layout Builder installed. The calendar itself is built in Views.

I have a pre-existing calendar with meetings. I am going to the calendar display page and clicking on one of the user group meetings. That brings up a view of all the upcoming dates for that user group. I click the Edit tab which would normally let me edit the dates and instead I get "The website encountered an unexpected error. Please try again later."

Just now I tried creating a new meeting and instead of providing a form, it gave me that same unexpected error. And now there's some meaty info in the logs.

Warning: Undefined variable $recur_manager in smart_date_recur_widget_extra_fields() (line 252 of /var/www/html/yln/web/modules/smart_date/modules/smart_date_recur/smart_date_recur.module)

#0 /var/www/html/yln/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 /var/www/html/yln/web/modules/smart_date/modules/smart_date_recur/smart_date_recur.module(252): _drupal_error_handler()
#2 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php(161): smart_date_recur_widget_extra_fields()
#3 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php(110): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase->formElement()
#4 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateInlineWidget.php(35): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget->formElement()
#5 /var/www/html/yln/web/core/lib/Drupal/Core/Field/WidgetBase.php(353): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateInlineWidget->formElement()
#6 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php(492): Drupal\Core\Field\WidgetBase->formSingleElement()
#7 /var/www/html/yln/web/core/lib/Drupal/Core/Field/WidgetBase.php(111): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase->formMultipleElements()
#8 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(183): Drupal\Core\Field\WidgetBase->form()
#9 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(121): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
#10 /var/www/html/yln/web/core/modules/node/src/NodeForm.php(127): Drupal\Core\Entity\ContentEntityForm->form()
#11 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\node\NodeForm->form()
#12 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
#13 /var/www/html/yln/web/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
#14 /var/www/html/yln/web/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
#15 /var/www/html/yln/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#16 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#17 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#18 /var/www/html/yln/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#20 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#21 /var/www/html/yln/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#22 /var/www/html/yln/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#23 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#24 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#25 /var/www/html/yln/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#26 /var/www/html/yln/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#27 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#28 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#29 /var/www/html/yln/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#30 /var/www/html/yln/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
#31 /var/www/html/yln/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#32 {main}
Error: Call to a member function getThirdPartyFallback() on null in smart_date_recur_widget_extra_fields() (line 252 of /var/www/html/yln/web/modules/smart_date/modules/smart_date_recur/smart_date_recur.module)

#0 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php(161): smart_date_recur_widget_extra_fields()
#1 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateDefaultWidget.php(110): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase->formElement()
#2 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateInlineWidget.php(35): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateDefaultWidget->formElement()
#3 /var/www/html/yln/web/core/lib/Drupal/Core/Field/WidgetBase.php(353): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateInlineWidget->formElement()
#4 /var/www/html/yln/web/modules/smart_date/src/Plugin/Field/FieldWidget/SmartDateWidgetBase.php(492): Drupal\Core\Field\WidgetBase->formSingleElement()
#5 /var/www/html/yln/web/core/lib/Drupal/Core/Field/WidgetBase.php(111): Drupal\smart_date\Plugin\Field\FieldWidget\SmartDateWidgetBase->formMultipleElements()
#6 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(183): Drupal\Core\Field\WidgetBase->form()
#7 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(121): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm()
#8 /var/www/html/yln/web/core/modules/node/src/NodeForm.php(127): Drupal\Core\Entity\ContentEntityForm->form()
#9 /var/www/html/yln/web/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\node\NodeForm->form()
#10 [internal function]: Drupal\Core\Entity\EntityForm->buildForm()
#11 /var/www/html/yln/web/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
#12 /var/www/html/yln/web/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
#13 /var/www/html/yln/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#14 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#15 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#16 /var/www/html/yln/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#18 /var/www/html/yln/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#19 /var/www/html/yln/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /var/www/html/yln/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#21 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#22 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#23 /var/www/html/yln/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#24 /var/www/html/yln/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#25 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#26 /var/www/html/yln/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#27 /var/www/html/yln/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#28 /var/www/html/yln/web/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle()
#29 /var/www/html/yln/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#30 {main}
mandclu’s picture

StatusFileSize
new27.52 KB

I really appreciate your help in troubleshooting this. That most recent information was indeed helpful. Here's a new patch to try.

chanelwheeler’s picture

Thank YOU for being so helpful. We're dependent on this module.

I installed the new patch, cleared the cache, and tried both editing and creating, and I still get the same errors for each.

mandclu’s picture

What version of Drupal is the site on BTW?

A couple of other potential things to try:

- truncate the cache tables (make sure you do a full backup first)
- install the Whoops module to see if it has any new insight (doubtful if the stack trace is the same for the errors you're seeing)

tobiasb’s picture

smart_date_recur does not define the service smart_date_recur.manager.

mandclu’s picture

StatusFileSize
new28.5 KB

In my sleep deprived state yesterday I forgot that making a patch which creates new files requires an extra step. Here's a new patch that should ACTUALLY define the new service.

mandclu’s picture

StatusFileSize
new28.51 KB

Apologies, one more small tweak that may help with layout builder.

tobiasb’s picture

Issue summary: View changes

LGTM.

chanelwheeler’s picture

I'm on Drupal 9.5.3. Patch 24 fixed the problem! I confirmed that I can edit and save a meeting, and that I can create a new meeting. No problems in the logs. Thank you!!

mandclu’s picture

Status: Needs review » Reviewed & tested by the community

Awesome! Moving this to RTBC, but it would be great if anyone else in this thread has feedback.

chanelwheeler’s picture

One more thing to add. I installed this with the patch on the production server which is still on the stable releases of Add to Calendar and Date Augmenter. The patch works there so for anyone following this thread, you don't need the alpha/beta to get this to work.

  • mandclu committed 3ff40846 on 4.0.x
    Issue #3317694 by mandclu, chanelwheeler, tobiasb: Error: Non-static...
mandclu’s picture

Status: Reviewed & tested by the community » Fixed

I've merged this into the 4.0.x branch. Thanks for everyone's help with this!

tobiasb’s picture

@mandclu

Please also in 3.7.x + new release.

mandclu’s picture

IMHO the removal of the ability to call a number of functions statically is a compatibility-breaking change, and as such should only be undertaken in a major version change. I'm hoping to have a first release of the 4.0.x branch in the coming days, but if you need something in the meantime I'm afraid you'll have to use the patch for now.

tobiasb’s picture

I know. We need a separate fix or at least a warning in the release notes that part of the software (smart_date_recur: field formatter) does not work without this patch in php >= 8.0.

mandclu’s picture

Good idea, I've added a comment about this to the releases notes for 3.7.0

  • mandclu committed c6fe3426 on 4.0.x
    Revert "Issue #3317694 by mandclu, chanelwheeler, tobiasb: Error: Non-...

  • mandclu committed 76588a86 on 4.0.x
    Reinstate "Issue #3317694 by mandclu, chanelwheeler, tobiasb: Error: Non...

Status: Fixed » Closed (fixed)

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