Description
When running Contao 5.3 with cgoit/calendar-extended-bundle 2.6.0 on PHP 8.4, the timetable module throws a fatal TypeError that breaks the page rendering.
Error message
request.CRITICAL: Uncaught PHP Exception TypeError: "date(): Argument #2 ($timestamp) must be of type ?int, string given" at ModuleTimeTable.php line 168
Cause
Starting with PHP 8.4, date() strictly enforces that its second argument must be ?int. In ModuleTimeTable.php, several values passed to date() are strings:
- Line 168:
$this->Date->tstamp — Contao's Date object may return the timestamp as a string
- Lines ~183ff:
$objMinMax->dateFrom, $objMinMax->dateTo, $objMinMax->repeatUntil — database query results are always returned as strings in PHP
compileDays() method: $this->weekBegin, $vv['startTime'], $vv['endTime'] — also potentially strings
setWeekStartAndEnd() method: $newDate->tstamp — same issue
On PHP 8.3 these were silently accepted. On PHP 8.4+ they cause a fatal TypeError.
Steps to reproduce
- Install Contao 5.3 with
cgoit/calendar-extended-bundle 2.6.0
- Switch to PHP 8.4
- Create a page with a timetable module that has calendar events
- Open the page in the frontend
Expected behavior
The timetable renders without errors.
Actual behavior
Page throws a fatal TypeError and fails to render.
Suggested fix
Cast all values passed as the second argument to date() to (int). The affected locations are:
compile(): (int) $this->Date->tstamp
compile(): (int) $objMinMax->dateFrom, (int) $objMinMax->dateTo, (int) $objMinMax->repeatUntil
compileDays(): (int) $this->weekBegin, (int) $vv['startTime'], (int) $vv['endTime']
setWeekStartAndEnd(): (int) $newDate->tstamp
Environment
- Contao: 5.3.45
- PHP: 8.4
- Bundle version: 2.6.0
Description
When running Contao 5.3 with
cgoit/calendar-extended-bundle2.6.0 on PHP 8.4, the timetable module throws a fatalTypeErrorthat breaks the page rendering.Error message
Cause
Starting with PHP 8.4,
date()strictly enforces that its second argument must be?int. InModuleTimeTable.php, several values passed todate()are strings:$this->Date->tstamp— Contao'sDateobject may return the timestamp as a string$objMinMax->dateFrom,$objMinMax->dateTo,$objMinMax->repeatUntil— database query results are always returned as strings in PHPcompileDays()method:$this->weekBegin,$vv['startTime'],$vv['endTime']— also potentially stringssetWeekStartAndEnd()method:$newDate->tstamp— same issueOn PHP 8.3 these were silently accepted. On PHP 8.4+ they cause a fatal TypeError.
Steps to reproduce
cgoit/calendar-extended-bundle2.6.0Expected behavior
The timetable renders without errors.
Actual behavior
Page throws a fatal TypeError and fails to render.
Suggested fix
Cast all values passed as the second argument to
date()to(int). The affected locations are:compile():(int) $this->Date->tstampcompile():(int) $objMinMax->dateFrom,(int) $objMinMax->dateTo,(int) $objMinMax->repeatUntilcompileDays():(int) $this->weekBegin,(int) $vv['startTime'],(int) $vv['endTime']setWeekStartAndEnd():(int) $newDate->tstampEnvironment