refactor: safe PHP 7.4 modernization#71
refactor: safe PHP 7.4 modernization#71somethingwithproof wants to merge 7 commits intoCacti:developfrom
Conversation
There was a problem hiding this comment.
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/*.jsonfiles (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]) { |
There was a problem hiding this comment.
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.
| if (is_[$aFtpRemoteFiles]) { | |
| if (is_array($aFtpRemoteFiles)) { |
| $sql_where = ''; | ||
| if (is_array($values) && cacti_sizeof($values)) { | ||
| if (is_[$values] && cacti_sizeof($values)) { | ||
| foreach($values as $value) { | ||
| // host_id | snmp_index |
There was a problem hiding this comment.
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.
| { | ||
| "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 |
There was a problem hiding this comment.
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.
| { | |
| "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": [] | |
| } |
| { | ||
| "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 |
There was a problem hiding this comment.
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.
| { | |
| "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": [] | |
| } |
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>
This PR adds strict typing, short array syntax, and null coalescing operators across the plugin. Standalone infrastructure files were removed per architectural mandate.