mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Misc cleanup (#12758)
* Fix Docblock * Misc * Parameter #2 $callback of function array_filter expects (callable(mixed, mixed): bool)|null, 'strlen' given * Parameter #2 $data of function hash_hmac expects string, int given * Unreachable statement - code above always terminates. * Update Device.php
This commit is contained in:
@@ -39,7 +39,7 @@ class Kayako extends Transport
|
||||
$ticket_type = 1;
|
||||
$ticket_status = 1;
|
||||
$ticket_prio = 1;
|
||||
$salt = mt_rand();
|
||||
$salt = bin2hex(random_bytes(20));
|
||||
$signature = base64_encode(hash_hmac('sha256', $salt, $secret, true));
|
||||
|
||||
$protocol = [
|
||||
|
@@ -143,7 +143,9 @@ class Sensu extends Transport
|
||||
'librenms-device-id' => strval($obj['device_id']),
|
||||
'librenms-rule-id' => strval($obj['rule_id']),
|
||||
'librenms-status-reason' => $obj['status_reason'],
|
||||
], 'strlen'); // strlen returns 0 for null, false or '', but 1 for integer 0 - unlike empty()
|
||||
], function (string $s): bool {
|
||||
return (bool) strlen($s); // strlen returns 0 for null, false or '', but 1 for integer 0 - unlike empty()
|
||||
});
|
||||
}
|
||||
|
||||
public static function calculateStatus($state, $severity)
|
||||
|
@@ -717,8 +717,6 @@ class IRCBot
|
||||
return $this->respond('Who are you again?');
|
||||
}
|
||||
}//end if
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//end _auth()
|
||||
|
@@ -58,7 +58,7 @@ class DeviceController extends Controller
|
||||
public function index(Request $request, $device, $current_tab = 'overview', $vars = '')
|
||||
{
|
||||
$device = str_replace('device=', '', $device);
|
||||
$device = is_numeric($device) ? DeviceCache::get($device) : DeviceCache::getByHostname($device);
|
||||
$device = is_numeric($device) ? DeviceCache::get((int) $device) : DeviceCache::getByHostname($device);
|
||||
$device_id = $device->device_id;
|
||||
|
||||
if (! $device->exists) {
|
||||
|
@@ -154,7 +154,8 @@ class DeviceDependencyController extends MapController
|
||||
$devices_by_id = $this->highlightDevices($devices_by_id, $this->parentDeviceIds);
|
||||
}
|
||||
|
||||
array_multisort(array_column($device_list, 'label'), SORT_ASC, $device_list);
|
||||
$device_list_labels = array_column($device_list, 'label');
|
||||
array_multisort($device_list_labels, SORT_ASC, $device_list);
|
||||
|
||||
$group_name = DeviceGroup::where('id', '=', $group_id)->first('name');
|
||||
if (! empty($group_name)) {
|
||||
|
@@ -12,7 +12,7 @@ class PortGroupController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -24,7 +24,7 @@ class PortGroupController extends Controller
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class PortGroupController extends Controller
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ class PortGroupController extends Controller
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\PortGroup $portGroup
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(PortGroup $portGroup)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ class PortGroupController extends Controller
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\PortGroup $portGroup
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(Request $request, PortGroup $portGroup)
|
||||
{
|
||||
|
@@ -38,6 +38,9 @@ class PortGroupController extends SelectController
|
||||
return PortGroup::hasAccess($request->user())->select(['id', 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PortGroup $port_group
|
||||
*/
|
||||
public function formatItem($port_group)
|
||||
{
|
||||
return [
|
||||
|
@@ -38,6 +38,9 @@ class ServiceTemplateController extends SelectController
|
||||
return ServiceTemplate::hasAccess($request->user())->select('id', 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServiceTemplate $template
|
||||
*/
|
||||
public function formatItem($template)
|
||||
{
|
||||
return [
|
||||
|
@@ -110,7 +110,7 @@ class SyslogController extends TableController
|
||||
|
||||
/**
|
||||
* @param int $syslog_priority
|
||||
* @return string|void
|
||||
* @return string
|
||||
*/
|
||||
private function priorityLabel($syslog_priority)
|
||||
{
|
||||
@@ -131,6 +131,8 @@ class SyslogController extends TableController
|
||||
return 'label-danger'; //Alert
|
||||
case 'emerg':
|
||||
return 'label-danger'; //Emergency
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class GlobeController extends WidgetController
|
||||
$location->lat,
|
||||
$location->lng,
|
||||
$location->location,
|
||||
$count ? (1 - $up / $count) * 100 : 0, // percent down
|
||||
(1 - $up / $count) * 100, // percent down
|
||||
$count,
|
||||
$down_items->implode(',<br/> '),
|
||||
]);
|
||||
|
@@ -68,9 +68,7 @@ abstract class WidgetController extends Controller
|
||||
// This might be invoked in getSettingsView() in an extended class
|
||||
// So don't run it before since it's cached.
|
||||
$this->getSettings();
|
||||
}
|
||||
|
||||
if (! $this->show_settings) {
|
||||
if (! empty($this->settings['device_group']) || ! empty($this->settings['port_group'])) {
|
||||
$this->title .= ' (';
|
||||
|
||||
|
@@ -155,7 +155,7 @@ class Device extends BaseModel
|
||||
$query->where('alert_schedulables.alert_schedulable_id', $this->device_id);
|
||||
});
|
||||
|
||||
if ($this->groups) {
|
||||
if ($this->groups->isNotEmpty()) {
|
||||
$query->orWhereHas('deviceGroups', function (Builder $query) {
|
||||
$query->whereIn('alert_schedulables.alert_schedulable_id', $this->groups->pluck('id'));
|
||||
});
|
||||
@@ -322,7 +322,7 @@ class Device extends BaseModel
|
||||
$deleted = (bool) $this->attribs->get($attrib_index)->delete();
|
||||
// only forget the attrib_index after delete, otherwise delete() will fail fatally with:
|
||||
// Symfony\\Component\\Debug\Exception\\FatalThrowableError(code: 0): Call to a member function delete() on null
|
||||
$this->attribs->forget($attrib_index);
|
||||
$this->attribs->forget((string) $attrib_index);
|
||||
|
||||
return $deleted;
|
||||
}
|
||||
|
Reference in New Issue
Block a user