Skip to content

Commit 2706fa7

Browse files
authored
Remove null coalescing operators (#1020)
* Remove null coalescing operators * Add credit where credit is due
1 parent af36041 commit 2706fa7

File tree

5 files changed

+26
-40
lines changed

5 files changed

+26
-40
lines changed

Changelog

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Nagios Core 4 Change Log
55
4.5.10 - 2025-XX-XX
66
-------------------
77
* Update quickstart and documentations links (Aaron Cieslicki)
8+
* Remove null coalescing operators and fix some php errors (Dylan Anderson and Robert Högberg)
89

910
4.5.9 - 2024-12-19
1011
------------------

THANKS

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ wrong, please let me know.
291291
* Rob Remus
292292
* Robert August Vincent II
293293
* Robert Gash
294+
* Robert Högberg
294295
* Robert Thompson
295296
* Roberto Marrodan
296297
* Robin Kearney

html/includes/utils.inc.php

+22-38
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,26 @@ function get_update_information(){
2424
);
2525

2626
// first read CGI config file to determine main file location
27-
$ccfc=read_cgi_config_file();
28-
//print_r($ccfc);
27+
$ccf=read_cgi_config_file();
28+
//print_r($ccf);
2929

3030
// read main config file to determine file locations
31-
if(isset($ccf['main_config_file']))
32-
$mcf=$ccf['main_config_file'];
33-
else
34-
$mcf="";
35-
$mcfc=read_main_config_file($mcf);
36-
//print_r($mcfc);
31+
$mcf = isset($ccf['main_config_file']) ? $ccf['main_config_file'] : "";
3732

38-
if(isset($mcf['status_file']))
39-
$sf=$mcf['status_file'];
40-
else
41-
$sf="";
33+
$mcf=read_main_config_file($mcf);
34+
//print_r($mcf);
4235

43-
if(isset($mcf['state_retention_file']))
44-
$rf=$mcf['state_retention_file'];
45-
else
46-
$rf="";
36+
$sf = isset($mcf['status_file']) ? $mcf['status_file'] : "";
37+
38+
$rf = isset($mcf['state_retention_file']) ? $mcf['state_retention_file'] : "";
4739

4840

4941
///////////////////////////////////////////////
5042
// GET PROGRAM VARIABLES FROM MAIN CONFIG FILE
5143
///////////////////////////////////////////////
5244

5345
// are update checks enabled?
54-
if(isset($mcfc['check_for_updates']) && $mcfc['check_for_updates']=="0")
46+
if(isset($mcf['check_for_updates']) && $mcf['check_for_updates'] == "0")
5547
$updateinfo["update_checks_enabled"]=false;
5648

5749

@@ -68,20 +60,17 @@ function get_update_information(){
6860
if(isset($sfc['info']['last_update_check'])){
6961
$updateinfo["last_update_check"]=$sfc['info']['last_update_check'];
7062
$updateinfo["found_update_info"]=true;
71-
}
63+
}
7264

7365
// update available
7466
if(isset($sfc['info']['update_available'])){
75-
if($sfc['info']['update_available']=="1")
76-
$updateinfo["update_available"]=true;
77-
else
78-
$updateinfo["update_available"]=false;
79-
}
67+
$updateinfo["update_available"] = $sfc['info']['update_available'] == "1";
68+
}
8069

8170
// update version
8271
if(isset($sfc['info']['new_version'])){
8372
$updateinfo["update_version"]=$sfc['info']['new_version'];
84-
}
73+
}
8574

8675
// did we find update information in the status file? if so, we're done
8776
if($updateinfo["found_update_info"]==true)
@@ -100,29 +89,24 @@ function get_update_information(){
10089
//exit();
10190

10291
// last update time
103-
if(isset($rfc['info']['last_update_check'])){
104-
$updateinfo["last_update_check"]=$rfc['info']['last_update_check'];
105-
$updateinfo["found_update_info"]=true;
106-
}
92+
if(isset($rfc['info']['last_update_check'])) {
93+
$updateinfo["last_update_check"] = $rfc['info']['last_update_check'];
94+
$updateinfo["found_update_info"] = true;
95+
}
10796

10897
// update available
109-
if(isset($rfc['info']['update_available'])){
110-
if($rfc['info']['update_available']=="1")
111-
$updateinfo["update_available"]=true;
112-
else
113-
$updateinfo["update_available"]=false;
114-
}
98+
if(isset($rfc['info']['update_available'])) {
99+
$updateinfo["update_available"] = $rfc['info']['update_available'] == "1";
100+
}
115101

116102
// update version
117103
if(isset($rfc['info']['new_version'])){
118104
$updateinfo["update_version"]=$rfc['info']['new_version'];
119-
}
105+
}
120106

121107

122108
return $updateinfo;
123-
}
124-
125-
109+
}
126110

127111

128112
////////////////////////////////////////////////////////////////////////////////////////////////

html/main.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
$this_version = '4.5.9';
55
$this_year = '2024';
6-
$theme = $cfg['theme'] ?? 'dark';
6+
$theme = isset($cfg['theme']) ? $cfg['theme'] : 'dark';
77
if ($theme != 'dark' && $theme != 'light') {
88
$theme = 'dark';
99
}

html/side.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
$this_version = '4.5.9';
55
$link_target = 'main';
6-
$theme = $cfg['theme'] ?? 'dark';
6+
$theme = isset($cfg['theme']) ? $cfg['theme'] : 'dark';
77
if ($theme != 'dark' && $theme != 'light') {
88
$theme = 'dark';
99
}

0 commit comments

Comments
 (0)