Skip to content

Commit 9128ce7

Browse files
committed
Fixes PHP 8.2 deprecation warnings when calling round() with null first parameter.
1 parent b054195 commit 9128ce7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to **Device Detector** are documented in this *changelog*.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and **Device Detector** adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [3.6.0] - Not Yet Released
7+
8+
### Fixed
9+
- With PHP 8.2, in some edge cases, deprecation warnings may be triggered when viewing analytics.
10+
611
## [3.5.0] - 2023-07-12
712

813
### Added

includes/features/class-analytics.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ public static function get_status_kpi_collection( $args = [] ) {
10391039
'ratio' => null,
10401040
'variation' => [
10411041
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1042-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1042+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
10431043
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
10441044
],
10451045
'value' => [
@@ -1058,7 +1058,7 @@ public static function get_status_kpi_collection( $args = [] ) {
10581058
'ratio' => null,
10591059
'variation' => [
10601060
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1061-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1061+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
10621062
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
10631063
],
10641064
'value' => [
@@ -1077,7 +1077,7 @@ public static function get_status_kpi_collection( $args = [] ) {
10771077
'ratio' => null,
10781078
'variation' => [
10791079
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1080-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1080+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
10811081
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
10821082
],
10831083
'value' => [
@@ -1095,12 +1095,12 @@ public static function get_status_kpi_collection( $args = [] ) {
10951095
'dimension' => 'none',
10961096
'ratio' => [
10971097
'raw' => round( $data['kpi-main-' . $query] / 100, 6 ),
1098-
'percent' => round( $data['kpi-main-' . $query], 2 ),
1098+
'percent' => round( $data['kpi-main-' . $query] ?? 0, 2 ),
10991099
'permille' => round( $data['kpi-main-' . $query] * 10, 2 ),
11001100
],
11011101
'variation' => [
11021102
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1103-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1103+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
11041104
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
11051105
],
11061106
'value' => [
@@ -1118,12 +1118,12 @@ public static function get_status_kpi_collection( $args = [] ) {
11181118
'dimension' => 'none',
11191119
'ratio' => [
11201120
'raw' => round( $data['kpi-main-' . $query] / 100, 6 ),
1121-
'percent' => round( $data['kpi-main-' . $query], 2 ),
1121+
'percent' => round( $data['kpi-main-' . $query] ?? 0, 2 ),
11221122
'permille' => round( $data['kpi-main-' . $query] * 10, 2 ),
11231123
],
11241124
'variation' => [
11251125
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1126-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1126+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
11271127
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
11281128
],
11291129
'value' => [
@@ -1141,12 +1141,12 @@ public static function get_status_kpi_collection( $args = [] ) {
11411141
'dimension' => 'none',
11421142
'ratio' => [
11431143
'raw' => round( $data['kpi-main-' . $query] / 100, 6 ),
1144-
'percent' => round( $data['kpi-main-' . $query], 2 ),
1144+
'percent' => round( $data['kpi-main-' . $query] ?? 0, 2 ),
11451145
'permille' => round( $data['kpi-main-' . $query] * 10, 2 ),
11461146
],
11471147
'variation' => [
11481148
'raw' => round( $data['kpi-index-' . $query] / 100, 6 ),
1149-
'percent' => round( $data['kpi-index-' . $query], 2 ),
1149+
'percent' => round( $data['kpi-index-' . $query] ?? 0, 2 ),
11501150
'permille' => round( $data['kpi-index-' . $query] * 10, 2 ),
11511151
],
11521152
'value' => [

0 commit comments

Comments
 (0)