Implement check for initialDate in AJAX query alter

Created on 6 June 2025, about 1 month ago

Problem/Motivation

As part of the work on 📌 Cleanup PhpStan test Active there was a section of code in fullcalendar.views_execution.inc that reliably triggered an error for phpstan (next) but never for phpstan:

    // If no exposed values set, use user-defined date values.
    elseif (!empty($settings['date']['month']) && !empty($settings['date']['year'])) {
      $ts = mktime(0, 0, 0, $settings['date']['month'] + 1, 1, $settings['date']['year']);

      $dateMin->setTimestamp($ts);
      $dateMax->setTimestamp($ts);

      $dateMin->modify('first day of this month');
      $dateMax->modify('first day of next month');
    }

As a result, adding a directive for phpstan to ignore errors in the next line would trigger an error in phpstan that there were no errors on the next line.

After some further investigation, I realized that the code in question (originally merged 7 years ago as part of this commit) doesn't actually do anything anymore. No date base property in $settings is possible, much less with month or year child properties. It seems like this must have been replaced with a reference to FullCalendar's initialDate property, currently nested within nav in the settings.

In the end, the phpstan errors were resolved by replacing the outdated code with a @todo, to reimplement a check for an initialDate value, and use that for the AJAX query alter if appropriate.

Proposed resolution

Reimplement the check and write a test for it.

📌 Task
Status

Active

Version

3.0

Component

Views

Created by

🇨🇦Canada mandclu

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

Comments & Activities

Production build 0.71.5 2024