Node Stats page - Deprecated function: DateTime::__construct(): Passing null to parameter #1

Created on 16 August 2023, 10 months ago
Updated 25 August 2023, 10 months ago

Problem/Motivation

If there are no date ranges (due to some internal test), then the module does not check whether $start is NULL. Passing NULL into the \DateTime constructor is deprecated in PHP 8.1 and a warning will be thrown.


Deprecated function: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in Drupal\simplenews_stats\SimplenewsStatsPage->getDates() (line 369 of modules/contrib/simplenews_stats/src/SimplenewsStatsPage.php).

Drupal\simplenews_stats\SimplenewsStatsPage->getDates() (Line: 387)
Drupal\simplenews_stats\SimplenewsStatsPage->getDatesForCharts() (Line: 266)
Drupal\simplenews_stats\SimplenewsStatsPage->getpage() (Line: 55)
Drupal\simplenews_stats\Controller\SimplenewsStatsAdminController->stats(Object)

Steps to reproduce

  1. Install the module
  2. Create a new Newsletter issue node
  3. Click the Stats tab

Proposed resolution

When there is no data in the series or no series, also return empty. Or use the null coalesce operator to set a $start and $end to an empty string or 'now'.

๐Ÿ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mradcliffe USA

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

Comments & Activities

Production build 0.69.0 2024