InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp().

Created on 7 January 2024, 10 months ago
Updated 20 January 2024, 10 months ago

Problem/Motivation

In some situations, you can get:

InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of core/lib/Drupa
Drupal\quant\Utility::getPageInfo() (Line: 440)
quant_preprocess_page(Array, 'page', Array)
call_user_func_array('quant_preprocess_page', Array) (Line: 285)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 477)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 86)
__TwigTemplate_c3de7236844b3caf8ae2d932e5d50dd4->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
...

Steps to reproduce

In my case, I was switching a translated term without aliases back and forth between published and unpublished. But, this may be hard to reproduce.

Proposed resolution

Defensively check for null timestamps before calling DrupalDateTime::createFromTimestamp.

Remaining tasks

  • Update code
  • Review and test
  • Commit :)

User interface changes

No fatal error.

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

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

Comments & Activities

Production build 0.71.5 2024