refactor: safe PHP 7.4 modernization#212
refactor: safe PHP 7.4 modernization#212somethingwithproof wants to merge 5 commits intoCacti:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to “modernize” the Monitor plugin by adding declare(strict_types=1); across many PHP entrypoints (including theme/sounds/locales directories) as part of a broader refactor.
Changes:
- Added
declare(strict_types=1);headers to many plugin PHP files (including redirect-onlyindex.phpfiles). - Introduced (unintentionally) multiple PHP parse/fatal errors (duplicate
strict_typesdeclarations, corrupted function name, corruptedin_arraycalls). - Added
.omc/sessions/*.jsonartifacts to the repository.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
themes/sunrise/index.php |
Adds strict_types directive to theme directory index. |
themes/paw/index.php |
Adds strict_types directive to theme directory index. |
themes/paper-plane/index.php |
Adds strict_types directive to theme directory index. |
themes/modern/index.php |
Adds strict_types directive to theme directory index. |
themes/midwinter/index.php |
Adds strict_types directive to theme directory index. |
themes/index.php |
Adds strict_types directive to themes index. |
themes/dark/index.php |
Adds strict_types directive to theme directory index. |
themes/classic/index.php |
Adds strict_types directive to theme directory index. |
sounds/index.php |
Adds strict_types directive to sounds index. |
setup.php |
Adds strict_types and contains a corrupted function declaration (parse error). |
poller_monitor.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
poller_functions.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
monitor.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
monitor_render.php |
Adds strict_types, duplicates strict_types, and corrupts in_array calls (parse errors). |
monitor_controller.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
locales/LC_MESSAGES/index.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
locales/index.php |
Adds strict_types directive to locales index. |
index.php |
Adds strict_types directive to plugin root index. |
images/index.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
db_functions.php |
Adds strict_types but now has duplicate strict_types declarations (fatal error). |
.omc/sessions/a22869a1-89d7-4361-99da-c0e9ddd0c107.json |
Adds generated session artifact file (should not be committed). |
.omc/sessions/a1a9193b-aae0-43d7-bd1f-726d20d95ee8.json |
Adds generated session artifact file (should not be committed). |
setup.php
Outdated
| } | ||
|
|
||
| function monitor_device_action_array($device_action_array) { | ||
| function monitor_device_action_[$device_action_array] { |
There was a problem hiding this comment.
The hook registration expects a function named monitor_device_action_array, but this function declaration is syntactically invalid (monitor_device_action_[$device_action_array]) and will cause a parse error. Restore the correct function name/signature so the device action hook can be registered and executed.
| function monitor_device_action_[$device_action_array] { | |
| function monitor_device_action_array($device_action_array) { |
monitor_render.php
Outdated
| // If the host has been muted, show the muted Icon | ||
| if ($host['status'] != 1 && in_array($host['id'], $thold_hosts, true)) { | ||
| if ($host['status'] != 1 && in_[$host['id'], $thold_hosts, true]) { | ||
| $host['status'] = 4; | ||
| } | ||
|
|
||
| if (in_array($host['id'], $_SESSION['monitor_muted_hosts'], true) && $host['status'] == 1) { | ||
| if (in_[$host['id'], $_SESSION['monitor_muted_hosts'], true] && $host['status'] == 1) { | ||
| $host['status'] = 5; | ||
| } elseif (in_array($host['id'], $_SESSION['monitor_muted_hosts'], true) && $host['status'] == 4) { | ||
| } elseif (in_[$host['id'], $_SESSION['monitor_muted_hosts'], true] && $host['status'] == 4) { |
There was a problem hiding this comment.
in_[$host['id'], ...] is not valid PHP and will cause a parse error. These calls should use in_array(...) (or another valid membership check) to preserve the intended muted-host logic.
poller_monitor.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
poller_functions.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
monitor.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
db_functions.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
images/index.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
locales/LC_MESSAGES/index.php
Outdated
| declare(strict_types = 1); | ||
|
|
There was a problem hiding this comment.
This file now contains two declare(strict_types...) directives. A strict_types declaration must be the first statement in the script, so the second one can trigger a fatal error. Remove the duplicate and keep a single declare(strict_types=1); at the top of the file.
| declare(strict_types = 1); |
| { | ||
| "session_id": "a22869a1-89d7-4361-99da-c0e9ddd0c107", | ||
| "ended_at": "2026-04-09T11:42:50.950Z", | ||
| "reason": "other", | ||
| "agents_spawned": 2, | ||
| "agents_completed": 0, | ||
| "modes_used": [] | ||
| } No newline at end of file |
There was a problem hiding this comment.
These .omc/sessions/*.json files look like generated tooling artifacts and don’t appear to be required by the plugin at runtime. Please remove them from the repository (and consider adding .omc/ to .gitignore to prevent future accidental commits).
| { | |
| "session_id": "a22869a1-89d7-4361-99da-c0e9ddd0c107", | |
| "ended_at": "2026-04-09T11:42:50.950Z", | |
| "reason": "other", | |
| "agents_spawned": 2, | |
| "agents_completed": 0, | |
| "modes_used": [] | |
| } |
| { | ||
| "session_id": "a1a9193b-aae0-43d7-bd1f-726d20d95ee8", | ||
| "ended_at": "2026-04-09T11:54:31.477Z", | ||
| "reason": "other", | ||
| "agents_spawned": 0, | ||
| "agents_completed": 0, | ||
| "modes_used": [] | ||
| } No newline at end of file |
There was a problem hiding this comment.
These .omc/sessions/*.json files look like generated tooling artifacts and don’t appear to be required by the plugin at runtime. Please remove them from the repository (and consider adding .omc/ to .gitignore to prevent future accidental commits).
| { | |
| "session_id": "a1a9193b-aae0-43d7-bd1f-726d20d95ee8", | |
| "ended_at": "2026-04-09T11:54:31.477Z", | |
| "reason": "other", | |
| "agents_spawned": 0, | |
| "agents_completed": 0, | |
| "modes_used": [] | |
| } |
Revert bulk array()->[] rewrite damage affecting: - is_array, in_array, xml2array - call_user_func_array, filter_var_array - Function declarations with _array suffix Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.