Skip to content

Commit

Permalink
Fix #19 (Passing NULL to mktime() is deprecated as of PHP 8.1.0)
Browse files Browse the repository at this point in the history
We should never pass `null` to functions expecting scalar values.
Since passing `null` to `int` parameters coerced `null` to zero, we
pass that in the first place.
  • Loading branch information
cmb69 committed Jan 21, 2023
1 parent 070b086 commit e1a9f63
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions includes/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@


// determine period on display to prevent useless calculation of events outside this period
$calendarstart = mktime(NULL,NULL,NULL,$month,1,$year);
$calendarstart = mktime(0,0,0,$month,1,$year);
$calendarend = strtotime("+$number months -1 day",$calendarstart);

// if months of different years are to be shown holiday list has to be looped twice
Expand Down Expand Up @@ -230,7 +230,7 @@
$trimmeddates = trim($value);
list($d,$m,$y) = explode(dpSeperator(),$trimmeddates);
$y = rtrim($y,'*');
$timestamp = mktime(null,null,null,$m,$d,$y);
$timestamp = mktime(0,0,0,$m,$d,$y);
$additionaldatesarray[] = $timestamp;
}
// eliminating additional dates from $event
Expand All @@ -242,7 +242,7 @@
foreach ($dates as $value) {
$trimmeddates = trim($value);
list($d,$m,$y) = explode(dpSeperator(),$trimmeddates);
$timestamp = mktime(null,null,null,$m,$d,$y);
$timestamp = mktime(0,0,0,$m,$d,$y);
$exceptionsarray[] = $timestamp;
}
// eliminating exception dates from entry3
Expand Down
6 changes: 3 additions & 3 deletions includes/editevents.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
foreach ($dates as $key => $value) {
$dates[$key] = trim($value);
list($day,$month,$year) = explode(dpSeperator(),$dates[$key]);
$timestamp = mktime(null,null,null,$month,$day,$year);
$timestamp = mktime(0,0,0,$month,$day,$year);
//exceptions must be later than the event start
if($timestamp > $event_start_timestamp) {
$dates[$key] = date('d' .dpSeperator(). 'm' .dpSeperator() . 'y', $timestamp) ;
Expand All @@ -212,7 +212,7 @@
$addeventfull = '*';
$year = trim($year,'*');
}
$timestamp = mktime(null,null,null,$month,$day,$year);
$timestamp = mktime(0,0,0,$month,$day,$year);
//exceptions must be later than the event start
if($timestamp > $event_start_timestamp) {
$dates[$key] = date('d' .dpSeperator(). 'm' .dpSeperator() . 'y', $timestamp).$addeventfull ;
Expand Down Expand Up @@ -345,7 +345,7 @@
if (!isset($events[$j]['yearly2'])) $events[$j]['yearly2'] = '';

@list($day,$month,$year) = explode( dpSeperator(), $events[$j]['datestart']);
$event_start_timestamp = mktime(null,null,null,(int)$month,(int)$day,(int)$year);
$event_start_timestamp = mktime(0,0,0,(int)$month,(int)$day,(int)$year);
if ($events[$j]['weekly']) {
$events[$j]['weekday'] = date('w',$event_start_timestamp);
//sort first weekly events on sundays
Expand Down
2 changes: 1 addition & 1 deletion includes/eventform.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function crossout(area)

//finding day of the week and month of an event
if($entry['datestart']) list($event_day,$event_month,$event_year) = explode( dpSeperator(), $entry['datestart']);
$timestamp = mktime(null,null,null,(int)$event_month,(int)$event_day,(int)$event_year);
$timestamp = mktime(0,0,0,(int)$event_month,(int)$event_day,(int)$event_year);
$longdayname_array = explode(",", $plugin_tx['calendar']['names_of_days_longform']);
$longdayname[$i] = $longdayname_array[date('w',$timestamp)];
$shortdayname_array = explode(",", $plugin_tx['calendar']['names_of_days']);
Expand Down
2 changes: 1 addition & 1 deletion includes/eventlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
if ($event_info_icon) $event_info_txt = substr($event_info_txt,1);

// for sorting algorithm that puts weekly events orderd by weekday first
$event_time_stamp = mktime(null,null,null,(int)$event_month,(int)$event_day,(int)$event_year);
$event_time_stamp = mktime(0,0,0,(int)$event_month,(int)$event_day,(int)$event_year);
if($weekly) $weekday = 1 + date('w',$event_time_stamp); else $weekday = '';
// 1 was added to avoid "0"

Expand Down
4 changes: 2 additions & 2 deletions includes/nextevent.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
$trimmeddates = trim($value);
list($d,$m,$y) = explode(dpSeperator(),$trimmeddates);
$y = rtrim($y,'*');
$timestamp = mktime(null,null,null,$m,$d,$y);
$timestamp = mktime(0,0,0,$m,$d,$y);
$additionaldatesarray[] = $timestamp;
}
// eliminating additional dates from $event
Expand Down Expand Up @@ -131,7 +131,7 @@
foreach ($dates as $value) {
$trimmed_dates = trim($value);
list($d,$m,$y) = explode(dpSeperator(),$trimmed_dates);
$timestamp = mktime(null,null,null,$m,$d,$y);
$timestamp = mktime(0,0,0,$m,$d,$y);
$exceptionsarray[] = $timestamp;
}
// eliminating exception dates from entry3
Expand Down

0 comments on commit e1a9f63

Please sign in to comment.