Unsupported operand types: string - string in OfficeHoursItemList->getStatusTimeLeft()

Created on 28 February 2022, over 2 years ago
Updated 18 June 2024, 10 days ago

The website encountered an unexpected error. Please try again later.
TypeError: Unsupported operand types: string - string in Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->getStatusTimeLeft() (line 161 of modules/contrib/office_hours/src/Plugin/Field/FieldType/OfficeHoursItemList.php).
Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->getStatusTimeLeft() (Line: 64)
Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterStatus->viewElements() (Line: 315)
Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterBase->addStatusFormatter() (Line: 68)
Drupal\office_hours\Plugin\Field\FieldFormatter\OfficeHoursFormatterDefault->viewElements() (Line: 89)
Drupal\Core\Field\FormatterBase->view() (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 267)
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: 463)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 66)
__TwigTemplate_7a533b4907f681001ddf521051e1505fca434a01d0916e74e3e8534ceddfc07a->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 435)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 463)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 110)
__TwigTemplate_f045781459a76b84da05b2308c2b39a6b4eda816f3999da2711a109736318cea->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 435)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Fixed with

    $time_left += ((int) substr($next_time, 2, 2) - (int) substr($now, 2, 2)) * 60;
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code - formatter

Created by

🇺🇦Ukraine super_romeo Kiev

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.

  • 🇮🇳India shashank5563 New Delhi

    I am getting the following error:
    TypeError: Unsupported operand types: string + int in Drupal\office_hours\OfficeHoursDateHelper::format() (line 158 of /modules/contrib/office_hours/src/OfficeHoursDateHelper.php).

    1. How reproduce the issue.

    1. Please see the screenshot and put the value same way.

    1. Then click on save button.

Production build 0.69.0 2024