diff --git a/changelog.d/8357.issue b/changelog.d/8357.issue new file mode 100644 index 000000000..b4ab3f3ab --- /dev/null +++ b/changelog.d/8357.issue @@ -0,0 +1 @@ +Resolve PHPStan 2.3 diagnostics while preserving poller cleanup, remote replication, log filtering, and sensor output diff --git a/cmd.php b/cmd.php index 27b5095e4..d20633c01 100755 --- a/cmd.php +++ b/cmd.php @@ -594,7 +594,7 @@ if (cacti_sizeof($poller_items) && read_config_option('poller_enabled') == 'on') 'POLLER'); } - if ($using_proc_function && $script_server_calls > 0) { + if ($using_proc_function) { // close php server process @fwrite($pipes[0], "quit\r\n"); fclose($pipes[0]); diff --git a/composer.lock b/composer.lock index f0853f6e6..26e3f7bdc 100644 --- a/composer.lock +++ b/composer.lock @@ -6478,11 +6478,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.2.17", + "version": "2.3.1", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e676a49fa70cee9f5bf6ff4796186b928a08673f", - "reference": "e676a49fa70cee9f5bf6ff4796186b928a08673f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6155239b488e95d26d1ebd95c6b4bb294d7f09db", + "reference": "6155239b488e95d26d1ebd95c6b4bb294d7f09db", "shasum": "" }, "require": { @@ -6538,7 +6538,7 @@ "type": "github" } ], - "time": "2026-10-04T19:40:09+00:00" + "time": "2026-10-08T21:09:11+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7609,21 +7609,21 @@ }, { "name": "rector/rector", - "version": "2.6.7", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "f4aa224edb9b0630fb43826d4cb6a49b62e48d4c" + "reference": "4d6a39b7fff302cac0ce90cd959a53c2f6a32776" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/f4aa224edb9b0630fb43826d4cb6a49b62e48d4c", - "reference": "f4aa224edb9b0630fb43826d4cb6a49b62e48d4c", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/4d6a39b7fff302cac0ce90cd959a53c2f6a32776", + "reference": "4d6a39b7fff302cac0ce90cd959a53c2f6a32776", "shasum": "" }, "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.2.14" + "phpstan/phpstan": "^2.3.0" }, "conflict": { "rector/rector-doctrine": "*", @@ -7654,7 +7654,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.6.7" + "source": "https://github.com/rectorphp/rector/tree/2.7.0" }, "funding": [ { @@ -7662,7 +7662,7 @@ "type": "github" } ], - "time": "2026-09-13T20:17:44+00:00" + "time": "2026-10-06T08:46:45+00:00" }, { "name": "sebastian/cli-parser", diff --git a/lib/api_device.php b/lib/api_device.php index 668eadf9a..092a2c827 100644 --- a/lib/api_device.php +++ b/lib/api_device.php @@ -855,27 +855,21 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'host_snmp_query', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'host_snmp_query', $poller_id); $data = db_fetch_assoc_prepared('SELECT pi.* FROM poller_item AS pi WHERE pi.host_id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'poller_item', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'poller_item', $poller_id); $data = db_fetch_assoc_prepared('SELECT h.* FROM host AS h WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'host', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'host', $poller_id); $data = db_fetch_assoc_prepared('SELECT hsc.* FROM host_snmp_cache AS hsc @@ -884,9 +878,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'host_snmp_cache', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'host_snmp_cache', $poller_id); $data = db_fetch_assoc_prepared('SELECT hsc.* FROM host_value_cache AS hsc @@ -895,9 +887,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'host_value_cache', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'host_value_cache', $poller_id); $data = db_fetch_assoc_prepared('SELECT pri.* FROM poller_reindex AS pri @@ -906,9 +896,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'poller_reindex', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'poller_reindex', $poller_id); $data = db_fetch_assoc_prepared('SELECT dl.* FROM data_local AS dl @@ -917,9 +905,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'data_local', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'data_local', $poller_id); $data = db_fetch_assoc_prepared('SELECT gl.* FROM graph_local AS gl @@ -928,9 +914,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'graph_local', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'graph_local', $poller_id); $data = db_fetch_assoc_prepared('SELECT dtd.* FROM data_template_data AS dtd @@ -941,9 +925,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'data_template_data', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'data_template_data', $poller_id); $data = db_fetch_assoc_prepared('SELECT dtr.* FROM data_template_rrd AS dtr @@ -954,9 +936,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'data_template_rrd', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'data_template_rrd', $poller_id); $data = db_fetch_assoc_prepared('SELECT gti.* FROM graph_templates_item AS gti @@ -967,9 +947,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'graph_templates_item', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'graph_templates_item', $poller_id); $data = db_fetch_assoc_prepared('SELECT did.* FROM data_input_data AS did @@ -982,9 +960,7 @@ function api_device_replicate_out(int $device_id, int $poller_id = 1) : bool { WHERE h.id = ?', [$device_id]); - if ($poller_id > 1) { - replicate_table_to_poller($rcnn_id, $data, 'data_input_data', $poller_id); - } + replicate_table_to_poller($rcnn_id, $data, 'data_input_data', $poller_id); api_plugin_hook_function('replicate_out', ['remote_poller_id' => $poller_id, 'rcnn_id' => $rcnn_id, 'class' => 'all']); diff --git a/lib/clog_webapi.php b/lib/clog_webapi.php index ce8870533..4bda47ba1 100644 --- a/lib/clog_webapi.php +++ b/lib/clog_webapi.php @@ -402,7 +402,7 @@ function clog_view_logfile() : void { } // respect the exclusion filter - if ($exclude_regex != '' && !$clogAdmin) { + if ($exclude_regex != '') { if (validate_is_regex($exclude_regex)) { if (preg_match($exclude_regex, $new_item)) { continue; diff --git a/scripts/ss_netsnmp_lmsensors.php b/scripts/ss_netsnmp_lmsensors.php index 62bab460d..fbf94c1be 100644 --- a/scripts/ss_netsnmp_lmsensors.php +++ b/scripts/ss_netsnmp_lmsensors.php @@ -275,7 +275,11 @@ function ss_netsnmp_lmsensors(int $host_id = 0, string $sensor_type = '', string return null; } else { - $sensor_array[$sensor_count]['index'] = $scratch[1]; + $sensor_array[$sensor_count] = [ + 'index' => $scratch[1], + 'name' => '', + 'reading' => '' + ]; } $sensor_count++; @@ -285,9 +289,7 @@ function ss_netsnmp_lmsensors(int $host_id = 0, string $sensor_type = '', string // requests for data other than index values require additional processing // if ($data_request != 'sensordevice' && cacti_sizeof($sensor_array)) { - $sensor_count = 0; - - foreach ($sensor_array as $sensor) { + foreach ($sensor_array as $sensor_key => $sensor) { switch ($data_request) { case 'sensordevice': // @@ -337,7 +339,7 @@ function ss_netsnmp_lmsensors(int $host_id = 0, string $sensor_type = '', string // // store the sensor name // - $sensor_array[$sensor_count]['name'] = $scratch; + $sensor['name'] = $scratch; break; case 'sensorreading': @@ -378,15 +380,12 @@ function ss_netsnmp_lmsensors(int $host_id = 0, string $sensor_type = '', string // // store the sensor reading // - $sensor_array[$sensor_count]['reading'] = $scratch; + $sensor['reading'] = $scratch; break; } - // - // increment the sensor counter - // - $sensor_count++; + $sensor_array[$sensor_key] = $sensor; } }