-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Source: Support #14684
Summary
Calling jddayofweek() in src/Helpers/DataBuckets.php:118 causes a fatal E_ERROR on PHP installations that lack the optional calendar extension (ext-calendar). This crashes the entire stats dashboard when weekly chart granularity is used.
Affected environments: Synology NAS (DSM), Alpine-based containers, and any PHP build without ext-calendar.
Error
Uncaught Error: Call to undefined function SlimStat\Helpers\jddayofweek()
in src/Helpers/DataBuckets.php:118
Root Cause
jddayofweek() belongs to PHP's optional calendar extension. The code calls it unconditionally at line 118 of DataBuckets.php inside initSeqWeek() without checking whether the extension is loaded. When absent, PHP throws a fatal error.
Causal chain:
- User views stats dashboard →
Chart.php→processResults() new DataBuckets(...)withWEEKgranularity →initBuckets()→initSeqWeek()initSeqWeek()callsjddayofweek($startOfWeek - 1, 1)at line 118ext-calendarnot loaded → fatal error → page crash / 404
Suggested Fix
Replace jddayofweek() with a pure-PHP day-name lookup array:
// Before (line 118):
$start->modify('next ' . jddayofweek($startOfWeek - 1, 1));
// After:
$dayNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
$dayName = $dayNames[$startOfWeek % 7] ?? 'Monday';
$start->modify('next ' . $dayName);This eliminates the ext-calendar dependency entirely.
Reproduction
- Use PHP 8.x without
ext-calendarenabled - Install WP Slimstat
- Navigate to WP Admin → Slimstat → any dashboard with weekly chart view
- Expected: Charts render
- Actual: Fatal error crashes the page
Code References
| File | Line | Description |
|---|---|---|
src/Helpers/DataBuckets.php |
118 | jddayofweek() call — fault location |
src/Helpers/DataBuckets.php |
103-136 | initSeqWeek() method |
src/Modules/Chart.php |
525 | DataBuckets construction with WEEK granularity |
Severity
Critical — Completely blocks dashboard access on affected environments. No workaround except enabling ext-calendar in php.ini.
Validated via qa-issue-validate skill (jaan.to plugin)