Error: Non-static method SmartDateRecurrenceFormatter::augmentOutput() cannot be called statically

Created on 27 October 2022, about 2 years ago
Updated 15 February 2023, over 1 year ago

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!

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Date Augmenter Integration

Created by

πŸ‡ΊπŸ‡ΈUnited States jon.lund

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡¨πŸ‡¦Canada mandclu

    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.

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

    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.

  • πŸ‡¨πŸ‡¦Canada mandclu

    @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.

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

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

  • πŸ‡¨πŸ‡¦Canada mandclu

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

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

    Unfortunately not.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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?

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

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

  • πŸ‡¨πŸ‡¦Canada mandclu

    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.

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

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

  • πŸ‡¨πŸ‡¦Canada mandclu

    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?

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

    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}
  • πŸ‡¨πŸ‡¦Canada mandclu

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

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

    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.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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)

  • πŸ‡©πŸ‡ͺGermany tobiasb Berlin

    smart_date_recur does not define the service smart_date_recur.manager.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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.

  • πŸ‡¨πŸ‡¦Canada mandclu

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

  • πŸ‡©πŸ‡ͺGermany tobiasb Berlin

    LGTM.

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

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

  • Status changed to RTBC almost 2 years ago
  • πŸ‡¨πŸ‡¦Canada mandclu

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

  • πŸ‡ΊπŸ‡ΈUnited States chanelwheeler

    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...
  • Status changed to Fixed almost 2 years ago
  • πŸ‡¨πŸ‡¦Canada mandclu

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

  • πŸ‡©πŸ‡ͺGermany tobiasb Berlin

    @mandclu

    Please also in 3.7.x + new release.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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.

  • πŸ‡©πŸ‡ͺGermany tobiasb Berlin

    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.

  • πŸ‡¨πŸ‡¦Canada mandclu

    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...
Production build 0.71.5 2024