Skip to content

Commit

Permalink
Remove null coalescing operators (#1020)
Browse files Browse the repository at this point in the history
* Remove null coalescing operators

* Add credit where credit is due
  • Loading branch information
tsadpbb authored Feb 3, 2025
1 parent af36041 commit 2706fa7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 40 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Nagios Core 4 Change Log
4.5.10 - 2025-XX-XX
-------------------
* Update quickstart and documentations links (Aaron Cieslicki)
* Remove null coalescing operators and fix some php errors (Dylan Anderson and Robert Högberg)

4.5.9 - 2024-12-19
------------------
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ wrong, please let me know.
* Rob Remus
* Robert August Vincent II
* Robert Gash
* Robert Högberg
* Robert Thompson
* Roberto Marrodan
* Robin Kearney
Expand Down
60 changes: 22 additions & 38 deletions html/includes/utils.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,26 @@ function get_update_information(){
);

// first read CGI config file to determine main file location
$ccfc=read_cgi_config_file();
//print_r($ccfc);
$ccf=read_cgi_config_file();
//print_r($ccf);

// read main config file to determine file locations
if(isset($ccf['main_config_file']))
$mcf=$ccf['main_config_file'];
else
$mcf="";
$mcfc=read_main_config_file($mcf);
//print_r($mcfc);
$mcf = isset($ccf['main_config_file']) ? $ccf['main_config_file'] : "";

if(isset($mcf['status_file']))
$sf=$mcf['status_file'];
else
$sf="";
$mcf=read_main_config_file($mcf);
//print_r($mcf);

if(isset($mcf['state_retention_file']))
$rf=$mcf['state_retention_file'];
else
$rf="";
$sf = isset($mcf['status_file']) ? $mcf['status_file'] : "";

$rf = isset($mcf['state_retention_file']) ? $mcf['state_retention_file'] : "";


///////////////////////////////////////////////
// GET PROGRAM VARIABLES FROM MAIN CONFIG FILE
///////////////////////////////////////////////

// are update checks enabled?
if(isset($mcfc['check_for_updates']) && $mcfc['check_for_updates']=="0")
if(isset($mcf['check_for_updates']) && $mcf['check_for_updates'] == "0")
$updateinfo["update_checks_enabled"]=false;


Expand All @@ -68,20 +60,17 @@ function get_update_information(){
if(isset($sfc['info']['last_update_check'])){
$updateinfo["last_update_check"]=$sfc['info']['last_update_check'];
$updateinfo["found_update_info"]=true;
}
}

// update available
if(isset($sfc['info']['update_available'])){
if($sfc['info']['update_available']=="1")
$updateinfo["update_available"]=true;
else
$updateinfo["update_available"]=false;
}
$updateinfo["update_available"] = $sfc['info']['update_available'] == "1";
}

// update version
if(isset($sfc['info']['new_version'])){
$updateinfo["update_version"]=$sfc['info']['new_version'];
}
}

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

// last update time
if(isset($rfc['info']['last_update_check'])){
$updateinfo["last_update_check"]=$rfc['info']['last_update_check'];
$updateinfo["found_update_info"]=true;
}
if(isset($rfc['info']['last_update_check'])) {
$updateinfo["last_update_check"] = $rfc['info']['last_update_check'];
$updateinfo["found_update_info"] = true;
}

// update available
if(isset($rfc['info']['update_available'])){
if($rfc['info']['update_available']=="1")
$updateinfo["update_available"]=true;
else
$updateinfo["update_available"]=false;
}
if(isset($rfc['info']['update_available'])) {
$updateinfo["update_available"] = $rfc['info']['update_available'] == "1";
}

// update version
if(isset($rfc['info']['new_version'])){
$updateinfo["update_version"]=$rfc['info']['new_version'];
}
}


return $updateinfo;
}


}


////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion html/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$this_version = '4.5.9';
$this_year = '2024';
$theme = $cfg['theme'] ?? 'dark';
$theme = isset($cfg['theme']) ? $cfg['theme'] : 'dark';
if ($theme != 'dark' && $theme != 'light') {
$theme = 'dark';
}
Expand Down
2 changes: 1 addition & 1 deletion html/side.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$this_version = '4.5.9';
$link_target = 'main';
$theme = $cfg['theme'] ?? 'dark';
$theme = isset($cfg['theme']) ? $cfg['theme'] : 'dark';
if ($theme != 'dark' && $theme != 'light') {
$theme = 'dark';
}
Expand Down

0 comments on commit 2706fa7

Please sign in to comment.