Function gmstrftime() is deprecated in Drupal\openweather\WeatherService->getHourlyForecastWeatherInformation()

Created on 21 January 2023, almost 2 years ago
Updated 25 February 2023, almost 2 years ago

Problem/Motivation

On php 8.1 the following deprecation warnings appear anywhere that the module block is used

Deprecated function: Function gmstrftime() is deprecated in Drupal\openweather\WeatherService->getHourlyForecastWeatherInformation() (line 286 of /app/docroot/modules/contrib/openweather/src/WeatherService.php)
#0 /app/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'Function gmstrf...', '/app/docroot/mo...', 286)
#1 /app/docroot/modules/contrib/openweather/src/WeatherService.php(286): _drupal_error_handler(8192, 'Function gmstrf...', '/app/docroot/mo...', 286)
#2 /app/docroot/modules/contrib/openweather/src/Plugin/Block/WeatherBlock.php(209): Drupal\openweather\WeatherService->getHourlyForecastWeatherInformation(Array, Array)
#3 /app/docroot/core/modules/block/src/BlockViewBuilder.php(171): Drupal\openweather\Plugin\Block\WeatherBlock->build()
#4 [internal function]: Drupal\block\BlockViewBuilder::preRender(Array)
#5 /app/docroot/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#6 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#7 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#8 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender(Array)
#9 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
#10 /app/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array)
#11 /app/docroot/sites/default/files/php/twig/63cb8dab71f08_page.html.twig_IovfqLbiP4BCJdd2jYLGl72DX/DrTy3Jdai-7WsdVRN3S1RR8WY_Nwazb0zD_aljlrGI0.php(116): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#12 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_68d1d486baf851ce943de718852d52ed->doDisplay(Array, Array)
#13 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#14 /app/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#15 /app/docroot/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array)
#16 /app/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/alpha/te...', Array)
#17 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('page', Array)
#18 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
#19 /app/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render(Array)
#20 /app/docroot/sites/default/files/php/twig/63cb8dab71f08_html.html.twig_8xgAPzViUUaU5CukLQ9l5imeX/RuPxcjUbmnnZpIwlUkZObn6wZm8d-vhCRE-ZLttuEFE.php(159): Drupal\Core\Template\TwigExtension->escapeFilter(Object(Drupal\Core\Template\TwigEnvironment), Array, 'html', NULL, true)
#21 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_f93b4d2b3eed1f6f257a6e58033a535f->doDisplay(Array, Array)
#22 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#23 /app/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#24 /app/docroot/core/themes/engines/twig/twig.engine(55): Twig\Template->render(Array)
#25 /app/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/alpha/te...', Array)
#26 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('html', Array)
#27 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, false)
#28 /app/docroot/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(162): Drupal\Core\Render\Renderer->render(Array)
#29 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#30 /app/docroot/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(163): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#31 /app/docroot/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#32 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#33 /app/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#34 /app/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#35 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#36 /app/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /app/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /app/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#39 /app/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#40 /app/docroot/modules/contrib/services/src/StackMiddleware/FormatSetter.php(44): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#41 /app/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\services\StackMiddleware\FormatSetter->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#42 /app/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#43 /app/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#44 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#45 /app/docroot/core/lib/Drupal/Core/DrupalKernel.php(713): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#46 /app/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#47 {main}

Steps to reproduce

php 8.1, visit a page where openweather is used

Proposed resolution

Here is described a way to translate those functions to newer counterparts https://php.watch/versions/8.1/strftime-gmstrftime-deprecated

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇷Greece giorgosk Chios, Greece 🇬🇷

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

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.

Production build 0.71.5 2024