Skip to content

Commit 70b2147

Browse files
fix: add PHPDoc blocks to execute helpers, tighten test assertion
Add PHPDoc to syslog_execute_ticket_command() and syslog_execute_alert_command() to match the documentation convention used by surrounding helpers. Narrow the test assertion from a broad substring that matched the function definition to the full call signature with trailing semicolon, so the check correctly detects missing call sites. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 62f54cf commit 70b2147

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

functions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,15 @@ function syslog_array2xml($array, $tag = 'template') {
10811081
return $xml;
10821082
}
10831083

1084+
/**
1085+
* syslog_execute_ticket_command - run the configured ticketing command for an alert
1086+
*
1087+
* @param array $alert The alert row from syslog_alert table
1088+
* @param array $hostlist Hostnames matched by the alert
1089+
* @param string $error_message sprintf template used if exec() returns non-zero
1090+
*
1091+
* @return void
1092+
*/
10841093
function syslog_execute_ticket_command($alert, $hostlist, $error_message) {
10851094
$command = read_config_option('syslog_ticket_command');
10861095

@@ -1108,6 +1117,15 @@ function syslog_execute_ticket_command($alert, $hostlist, $error_message) {
11081117
}
11091118
}
11101119

1120+
/**
1121+
* syslog_execute_alert_command - run the per-alert shell command for a matched result
1122+
*
1123+
* @param array $alert The alert row from syslog_alert table
1124+
* @param array $results The matched syslog result row
1125+
* @param string $hostname Resolved hostname for the source device
1126+
*
1127+
* @return void
1128+
*/
11111129
function syslog_execute_alert_command($alert, $results, $hostname) {
11121130
$command = alert_replace_variables($alert, $results, $hostname);
11131131

tests/regression/issue278_command_execution_refactor_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
exit(1);
1818
}
1919

20-
if (substr_count($functions, 'syslog_execute_ticket_command($alert, $hostlist') < 2) {
20+
if (substr_count($functions, 'syslog_execute_ticket_command($alert, $hostlist, $error_message);') < 2) {
2121
fwrite(STDERR, "syslog_process_alerts() is not consistently using the ticket command helper.\n");
2222
exit(1);
2323
}

0 commit comments

Comments
 (0)