diff options
author | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
commit | c2d95ffaeaa289752b4c7b6664b6ca112a02e350 (patch) | |
tree | 2c29b0157d14198aadbdbc9f8c18ded0bd4dadcd /modules-available/locations | |
parent | [rebootcontrol] Remove API prototype (diff) | |
download | slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.gz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.xz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.zip |
Roundup of issues reported by PHPStorm
Mostly redundant checks, logic errors, dead code, etc.
Diffstat (limited to 'modules-available/locations')
-rw-r--r-- | modules-available/locations/inc/location.inc.php | 3 | ||||
-rw-r--r-- | modules-available/locations/inc/locationutil.inc.php | 2 | ||||
-rw-r--r-- | modules-available/locations/pages/details.inc.php | 13 |
3 files changed, 8 insertions, 10 deletions
diff --git a/modules-available/locations/inc/location.inc.php b/modules-available/locations/inc/location.inc.php index db4580be..f68d6821 100644 --- a/modules-available/locations/inc/location.inc.php +++ b/modules-available/locations/inc/location.inc.php @@ -254,8 +254,7 @@ class Location . 'FROM location ' . 'WHERE parentlocationid = :locationid', ['locationid' => $locationid]); $result = $result['isleaf']; - $result = (bool)$result; - return $result; + return (bool)$result; } public static function extractIds($tree) diff --git a/modules-available/locations/inc/locationutil.inc.php b/modules-available/locations/inc/locationutil.inc.php index acdaed2f..907bcc99 100644 --- a/modules-available/locations/inc/locationutil.inc.php +++ b/modules-available/locations/inc/locationutil.inc.php @@ -48,7 +48,7 @@ class LocationUtil if ($overlapOther) { $overlapOther = array(); foreach ($other as $entry) { - if (!isset($locs[$entry['lid1']]) || !isset($locs[$entry['lid2']])) + if (!isset($locs[$entry['lid1']]) && !isset($locs[$entry['lid2']])) continue; if (in_array($entry['lid1'], $locs[$entry['lid2']]['parents']) || in_array($entry['lid2'], $locs[$entry['lid1']]['parents'])) continue; diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php index 77f96221..e75aaf7d 100644 --- a/modules-available/locations/pages/details.inc.php +++ b/modules-available/locations/pages/details.inc.php @@ -57,7 +57,7 @@ class SubPage $mangled = array(); foreach (array_keys($openingTimes) as $key) { $entry = $openingTimes[$key]; - if (!isset($entry['days']) || !is_array($entry['days']) || empty($entry['days'])) { + if (empty($entry['days']) || !is_array($entry['days'])) { Message::addError('ignored-line-no-days'); continue; } @@ -222,8 +222,6 @@ class SubPage if (!User::hasPermission('location.edit.subnets', $locationId)) return false; - $change = false; - // Deletion first $dels = Request::post('deletesubnet', false); $deleteCount = 0; @@ -242,8 +240,9 @@ class SubPage $starts = Request::post('startaddr', false); $ends = Request::post('endaddr', false); if (!is_array($starts) || !is_array($ends)) { - return $change; + return false; } + $change = false; $editCount = 0; $stmt = Database::prepare('UPDATE subnet SET startaddr = :start, endaddr = :end' . ' WHERE subnetid = :id'); @@ -282,12 +281,12 @@ class SubPage if (!User::hasPermission('location.edit.subnets', $locationId)) return false; - $change = false; $starts = Request::post('newstartaddr', false); $ends = Request::post('newendaddr', false); if (!is_array($starts) || !is_array($ends)) { - return $change; + return false; } + $change = false; $count = 0; $stmt = Database::prepare('INSERT INTO subnet SET startaddr = :start, endaddr = :end, locationid = :location'); foreach ($starts as $key => $start) { @@ -537,7 +536,7 @@ class SubPage // $start must lie before range start, otherwise we'd have hit the case above $e = $current[1]; unset($array[$day][$key]); - continue; + //continue; } } $array[$day][] = array($s, $e); |