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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mradcliffe created an issue. See original summary.

mradcliffe’s picture

Status: Active » Needs review
keshavv’s picture

Status: Needs review » Reviewed & tested by the community

I have gone through the issue and was able to reproduce it, Confirmed that there is an issue, and the given MR works well.
Moved to RTBC

Damien Laguerre made their first commit to this issue’s fork.

damien laguerre’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.