Skip to content

refactor: safe PHP 7.4 modernization#71

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

refactor: safe PHP 7.4 modernization#71
somethingwithproof wants to merge 7 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: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 gexport plugin’s PHP code for PHP 7.4 by enabling strict typing and updating legacy array syntax/DB call parameter arrays, while also introducing two new session artifact files under .omc/.

Changes:

  • Added declare(strict_types=1); to multiple PHP entrypoints/index files.
  • Replaced array(...) with [...] in various places (including DB prepared statement parameter arrays).
  • Added .omc/sessions/*.json files (appear to be tooling artifacts).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
setup.php Adds strict types and updates some arrays to short syntax.
gexport.php Adds strict types and updates prepared-statement arg arrays and some other arrays.
functions.php Adds strict types and modernizes arrays, but introduces two parse errors (is_[$var]).
locales/index.php Adds strict types to directory index file.
locales/po/index.php Adds strict types to directory index file.
locales/LC_MESSAGES/index.php Adds strict types to directory index file.
.omc/sessions/50dc249e-8391-4ccd-8092-ddd3dd0e3a65.json New session JSON artifact committed.
.omc/sessions/4bfc95aa-eb89-43b1-af1f-3a9d70edf9bd.json New session JSON artifact committed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

functions.php Outdated
$aFtpRemoteFiles = ftp_nlist($oFtpConnection, $aFtpExport['remotedir']);

if (is_array($aFtpRemoteFiles)) {
if (is_[$aFtpRemoteFiles]) {
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.

is_[$aFtpRemoteFiles] is invalid PHP and will cause a parse error. This should be is_array($aFtpRemoteFiles) (or otherwise correctly validate the ftp_nlist() result) before iterating.

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

Copilot uses AI. Check for mistakes.
Comment on lines 1353 to 1356
$sql_where = '';
if (is_array($values) && cacti_sizeof($values)) {
if (is_[$values] && cacti_sizeof($values)) {
foreach($values as $value) {
// host_id | snmp_index
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.

is_[$values] is invalid PHP and will cause a parse error. This should be is_array($values) (or otherwise correctly validate json_decode() output) before iterating.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "50dc249e-8391-4ccd-8092-ddd3dd0e3a65",
"ended_at": "2026-04-09T20:14:23.610Z",
"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 local tooling/session artifacts and not source code. They should be removed from the repository and the .omc/ directory should be added to .gitignore to prevent accidental commits.

Suggested change
{
"session_id": "50dc249e-8391-4ccd-8092-ddd3dd0e3a65",
"ended_at": "2026-04-09T20:14:23.610Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
{
"session_id": "4bfc95aa-eb89-43b1-af1f-3a9d70edf9bd",
"ended_at": "2026-04-09T20:26:34.016Z",
"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 local tooling/session artifacts and not source code. They should be removed from the repository and the .omc/ directory should be added to .gitignore to prevent accidental commits.

Suggested change
{
"session_id": "4bfc95aa-eb89-43b1-af1f-3a9d70edf9bd",
"ended_at": "2026-04-09T20:26:34.016Z",
"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>
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>
Sites with no hosts produced 'IN()' SQL syntax errors. Return empty
graphs array when device list is empty for site_gt, site_dq, and
site_dqi export types.

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