Skip to content

refactor: safe PHP 7.4 modernization#212

Open
somethingwithproof wants to merge 5 commits intoCacti:developfrom
somethingwithproof:refactor/modernization
Open

refactor: safe PHP 7.4 modernization#212
somethingwithproof wants to merge 5 commits intoCacti:developfrom
somethingwithproof:refactor/modernization

Conversation

@somethingwithproof
Copy link
Copy Markdown

This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.

Copilot AI review requested due to automatic review settings April 9, 2026 21:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-only index.php files).
  • Introduced (unintentionally) multiple PHP parse/fatal errors (duplicate strict_types declarations, corrupted function name, corrupted in_array calls).
  • Added .omc/sessions/*.json artifacts 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] {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
function monitor_device_action_[$device_action_array] {
function monitor_device_action_array($device_action_array) {

Copilot uses AI. Check for mistakes.
Comment on lines +672 to +679
// 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) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
monitor.php Outdated
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
db_functions.php Outdated
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
images/index.php Outdated
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
Comment on lines 5 to 6
declare(strict_types = 1);

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
declare(strict_types = 1);

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"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
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
{
"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": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"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
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
{
"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": []
}

Copilot uses AI. Check for mistakes.
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants