Skip to content

Commit

Permalink
Work around stricter typing in PHP 8.1.2 when performing some date ca…
Browse files Browse the repository at this point in the history
…lculations
  • Loading branch information
TheWitness committed Feb 13, 2022
1 parent 0801ec3 commit 44bf278
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -5,6 +5,7 @@ Cacti CHANGELOG
-security: Resolve issues with XSS issues in color_template. Thanks @M0rphling
-issue: Reports Drag and Drop not functioning
-issue: At 30 second data collection in PHP 8.1.2 PHP reports a loss of precision in poller.php
-issue: Work around stricter typing in PHP 8.1.2 when performing some date calculations
-issue#3816: Installation can sometimes appear stuck during replication or table conversion
-issue#4363: Duplicate entries in graph_templates_item - mabye an aftermath of the template edit bug
-issue#4435: Unable to Save Graph Settings from the Graphs pages
Expand Down
5 changes: 5 additions & 0 deletions lib/functions.php
Expand Up @@ -5250,6 +5250,11 @@ function get_uptime($host) {
function get_daysfromtime($time, $secs = false, $pad = '', $format = DAYS_FORMAT_SHORT, $all = false) {
global $days_from_time_settings;

// Work around stricter typing in PHP 8.1.2+
if (is_float($time)) {
$time = intval(ceil($time));
}

// Ensure we use an existing format or we'll end up with no text at all
if (!isset($days_from_time_settings['text'][$format])) {
$format = DAYS_FORMAT_SHORT;
Expand Down

0 comments on commit 44bf278

Please sign in to comment.