Skip to content

refactor: safe PHP 7.4 modernization#54

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

refactor: safe PHP 7.4 modernization#54
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.

Guard against non-string $page and non-array $selected_items
at the function boundary to prevent unexpected behavior from
malformed caller data.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Copilot AI review requested due to automatic review settings April 9, 2026 21:15
Copy link
Copy Markdown

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 modernizes the Cacti Audit plugin’s PHP sources by enabling strict typing and updating some legacy array syntax, with the goal of safer/cleaner PHP 7.4-era code.

Changes:

  • Added declare(strict_types=1); to multiple PHP entrypoint files.
  • Converted some array(...) usages to short array syntax [...].
  • Introduced additional input/type guarding in audit_process_page_data().

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
setup.php Adds strict types and short array syntax; currently contains a PHP parse error in audit_utilities_array declaration.
audit.php Adds strict types and short array syntax; currently contains PHP parse errors in is_array checks.
audit_functions.php Adds strict types, short array syntax, and new guard logic; currently contains a PHP parse error in the guard clause.
index.php Adds strict types to plugin index redirect.
locales/index.php Adds strict types to locales index redirect.
locales/LC_MESSAGES/index.php Adds strict types to LC_MESSAGES index redirect.
.omc/sessions/*.json Adds session metadata files that appear unrelated to plugin runtime and should not be committed.

Comment thread setup.php Outdated
}

function audit_utilities_array() {
function audit_utilities_[] {
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.

audit_utilities_array is registered as a hook, but the function definition here is syntactically invalid (function audit_utilities_[] {). This will cause a PHP parse error and prevent the plugin from loading. Rename/restore the function declaration to audit_utilities_array() (and keep the audit_ prefix).

Suggested change
function audit_utilities_[] {
function audit_utilities_array() {

Copilot uses AI. Check for mistakes.
Comment thread audit.php Outdated
}

if (is_array($content)) {
if (is_[$content]) {
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 condition is syntactically invalid: is_[$content] will cause a PHP parse error. It looks like this should be is_array($content) to match the previous behavior when rendering attribute values.

Suggested change
if (is_[$content]) {
if (is_array($content)) {

Copilot uses AI. Check for mistakes.
Comment thread audit.php Outdated
$poster = '';
foreach($post as $var => $value) {
if (is_array($value)) {
if (is_[$value]) {
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 condition is syntactically invalid: is_[$value] will cause a PHP parse error during CSV export. It appears the intent was to keep the prior is_array($value) check.

Suggested change
if (is_[$value]) {
if (is_array($value)) {

Copilot uses AI. Check for mistakes.
Comment thread audit_functions.php Outdated
$objects = array();
$objects = [];

if (!is_string($page) || $page === '' || !is_[$selected_items]) {
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 new guard clause uses !is_[$selected_items], which is syntactically invalid and will cause a PHP parse error. This should be an array check (e.g., !is_array($selected_items)) so audit_process_page_data() can safely early-return when unserialize() fails.

Suggested change
if (!is_string($page) || $page === '' || !is_[$selected_items]) {
if (!is_string($page) || $page === '' || !is_array($selected_items)) {

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "e795e842-5b52-4c4f-a301-d0c076c145ec",
"ended_at": "2026-04-09T20:40:09.532Z",
"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.

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "e795e842-5b52-4c4f-a301-d0c076c145ec",
"ended_at": "2026-04-09T20:40:09.532Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "d67358a1-81fd-4c38-8750-7175bf018252",
"ended_at": "2026-04-09T20:46:21.611Z",
"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.

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "d67358a1-81fd-4c38-8750-7175bf018252",
"ended_at": "2026-04-09T20:46:21.611Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "865e7e69-4115-4c88-a9ea-8264b75b1cfc",
"ended_at": "2026-04-09T20:42:25.246Z",
"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.

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "865e7e69-4115-4c88-a9ea-8264b75b1cfc",
"ended_at": "2026-04-09T20:42:25.246Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "426d31d2-5007-4a69-94e9-7171c89be435",
"ended_at": "2026-04-09T20:39:23.599Z",
"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.

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "426d31d2-5007-4a69-94e9-7171c89be435",
"ended_at": "2026-04-09T20:39:23.599Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "0ad57977-0b9b-4712-bf0c-d8591161a6c5",
"ended_at": "2026-04-09T20:58:25.835Z",
"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.

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "0ad57977-0b9b-4712-bf0c-d8591161a6c5",
"ended_at": "2026-04-09T20:58:25.835Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Revert corrupted function calls introduced by refactoring tool:
- is_[$x] -> is_array($x)
- in_[$x, ...] -> in_array($x, ...)
- xml2[$x] -> xml2array($x)

Also remove accidentally committed .omc session files and add
.omc/ to .gitignore.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof marked this pull request as draft April 11, 2026 00:09
@somethingwithproof
Copy link
Copy Markdown
Author

Converted to draft to serialize the stack in this repo. Blocked by #51; will un-draft after that merges to avoid cross-PR merge conflicts.

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