[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] PHP 8.5 deprecated warnings in calendar

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6992335e62be2_3b186618152d@gitlab-sidekiq-low-urgency-cpu-bound-v2-7b68dd745d-nf9j5.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
60967f52 by Yves Ngalamulume at 2026-02-15T20:50:27+00:00
[FIX] PHP 8.5 deprecated warnings in calendar
---
* Fix PHP 8.1 deprecation and type confusion in calendar start/end day handling

* Fix PHP 8.1 deprecation and type confusion in calendar start/end day handling

* Fix PHP 8.1 deprecation and type confusion in calendar start/end day handling

* Fix PHP 8.1 float→int deprecation in calendar time calculation

* [FIX] PHP 8.5 deprecated warnings in calendar and JS module debug output in headerlib

* [FIX] PHP 8.5 deprecated warnings in calendar and JS module debug output in headerlib

See merge request tikiwiki/tiki!9466

- - - - -


2 changed files:

- lib/calendar/calendarlib.php
- tiki-calendar.php


Changes:

=====================================
lib/calendar/calendarlib.php
=====================================
@@ -166,13 +166,14 @@ class CalendarLib extends TikiLib
             $calendars[$calendar['calendarId']] = $calendar;
             // for week and day views
             $startOfDayUnix = (int)($calendar['startday'] ?? $prefs['calendar_startday'] ?? 0);
-            $startOfDayHour = $startOfDayUnix / 3600;
-            $startOfDayMinute = ($startOfDayUnix % 3600) / 60;
-            $minHourOfDay = date('H:i:s', mktime($startOfDayHour, $startOfDayMinute, 0));
+
+            $startOfDayHour = intdiv($startOfDayUnix, 3600);
+            $startOfDayMinute = intdiv($startOfDayUnix % 3600, 60);
+            $minHourOfDay = sprintf('%02d:%02d:00', $startOfDayHour, $startOfDayMinute);
             $endOfDayUnix = (int)($calendar['endday'] ?? 0);
-            $endOfDayHour = $endOfDayUnix / 3600;
-            $endOfDayMinute = ($endOfDayUnix % 3600) / 60;
-            $maxHourOfDay = date('H:i:s', mktime($endOfDayHour, $endOfDayMinute, 0));
+            $endOfDayHour = intdiv($endOfDayUnix, 3600);
+            $endOfDayMinute = intdiv($endOfDayUnix % 3600, 60);
+            $maxHourOfDay = sprintf('%02d:%02d:00', $endOfDayHour, $endOfDayMinute);
             $canEditAnything = $canEditAnything || $calendar['perms']->add_events;
         }
         return  [


=====================================
tiki-calendar.php
=====================================
@@ -90,6 +90,8 @@ if (empty($rawcals['data'])) {
 
 $minHourOfDay = 12;
 $maxHourOfDay = 12;
+$startOfDayMinute = 0;
+$endOfDayMinute = 0;
 $calendars = [];
 $canEditAnything = false;
 
@@ -100,13 +102,12 @@ foreach ($rawcals['data'] as $calendar) {
 
     // for week and day views
     $startOfDayUnix = (int)($calendar['startday'] ?? $prefs['calendar_startday'] ?? 0);
-    $startOfDayHour = $startOfDayUnix / 3600;
-    $startOfDayMinute = ($startOfDayUnix % 3600) / 60;
-    $minHourOfDay = date('H:i:s', mktime($startOfDayHour, $startOfDayMinute, 0));
+    $startOfDayMinute = intdiv($startOfDayUnix % 3600, 60);
+    $minHourOfDay = intdiv($startOfDayUnix, 3600);
+
     $endOfDayUnix = (int)($calendar['endday'] ?? 0);
-    $endOfDayHour = $endOfDayUnix / 3600;
-    $endOfDayMinute = ($endOfDayUnix % 3600) / 60;
-    $maxHourOfDay = date('H:i:s', mktime($endOfDayHour, $endOfDayMinute, 0));
+    $endOfDayMinute = intdiv($endOfDayUnix % 3600, 60);
+    $maxHourOfDay = intdiv($endOfDayUnix, 3600);
 
     $canEditAnything = $canEditAnything || $calendar['perms']->add_events;
 }
@@ -236,7 +237,7 @@ if (! empty($_REQUEST['generate_availability'])) {
                 continue;
             }
             $ranges[$day] = [
-                [(int)$minHourOfDay, 0], [(int)$maxHourOfDay, 0]
+                [$minHourOfDay, $startOfDayMinute], [$maxHourOfDay, $endOfDayMinute]
             ];
         }
         $busy_list = [];



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/60967f52ecaac9893ca0a64c9a56e548839d4daf

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/60967f52ecaac9893ca0a64c9a56e548839d4daf
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.