Skip to content

Conversation

@bmfmancini
Copy link
Member

This pull request primarily refactors the code in maint.php and functions.php to improve code readability and maintainability. The main changes involve converting block comments to line comments, reformatting code for consistency, and updating the style to modern PHP conventions (such as moving opening braces to the same line as function declarations). No functional logic was changed.

The most important changes include:

Code style and readability improvements:

  • Converted block comments (/* ... */) to single-line comments (// ...) throughout maint.php and functions.php for better readability and consistency. [1] [2] [3] [4] [5]
  • Reformatted code by removing unnecessary blank lines and aligning indentation, making the codebase cleaner and easier to follow. [1] [2] [3] [4] [5] [6]

Function declaration updates:

  • Updated function declarations to use the modern PHP style by placing opening braces on the same line as the function name in both maint.php and functions.php. [1] [2] [3] [4] [5] [6] [7]

Minor string and array improvements:

  • Standardized array syntax from double quotes to single quotes where applicable, and improved string handling for input sanitization.

UI and messaging consistency:

  • Updated button and error message rendering to use single quotes for HTML attributes and improved consistency in UI markup. [1] [2] [3]

No logic changes:

  • All changes are non-functional and aimed solely at improving code clarity and maintainability—there are no changes to the underlying business logic or application behavior. (All references)

TheWitness
TheWitness previously approved these changes Jan 29, 2026
Copy link
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

Style-focused refactor across the maint plugin PHP files to improve readability/consistency (brace placement, indentation, and comment formatting), while keeping behavior intended to remain the same.

Changes:

  • Reformat PHP functions/blocks for consistent brace placement and indentation.
  • Convert/standardize comments and string quoting in several UI/controller sections.
  • Minor markup adjustments within action confirmation/filters.

Reviewed changes

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

File Description
setup.php Reformats plugin hooks/DB setup code to consistent modern PHP style.
maint.php Large-scale formatting changes across schedule CRUD/actions and tab UIs; includes updated markup strings.
functions.php Reformats maintenance-check helper functions for consistency/readability.

Comment on lines 477 to +524

$list .= '<li><b>' . html_escape($description) . '</b></li>';
$array[] = $matches[1];
}
}
$list .= '<li><b>' . html_escape($description) . '</b></li>';
$array[] = $matches[1];
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The "$save_html" string for the WebSeer empty-selection case has malformed HTML: there is a stray ">" before the onClick attribute ("class='...'> onClick=..."). This makes the onclick handler an orphaned text node and the button won’t work as intended.

Copilot uses AI. Check for mistakes.
Comment on lines 587 to 588
FROM plugin_servcheck_test
WHERE id = ?',
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

In the Servcheck disassociate confirmation, the submit control is rendered as but then concatenated with inner text and closed with . This is invalid HTML and likely breaks the Continue button. Use either a Continue or an without a closing tag.

Copilot uses AI. Check for mistakes.
Comment on lines +1264 to 1265
$sql_statement = "SELECT ht.id, ht.name
FROM host_template AS ht
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The element has an extra trailing quote in the id attribute (id='rows''). This is invalid HTML and can break jQuery selectors like $('#rows'). Remove the stray quote.

Copilot uses AI. Check for mistakes.
Comment on lines +1566 to +1567
if ($schedule_created) {
print "<tr><td colspan='8'><em>" . __('No Associated Devices Found', 'maint') . '</em></td></tr>';
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The element has an extra trailing quote in the id attribute (id='rows''). This is invalid HTML and can break jQuery selectors like $('#rows'). Remove the stray quote.

Copilot uses AI. Check for mistakes.
Comment on lines +2009 to +2011
'%' . get_request_var('filter') . '%',
'%' . get_request_var('filter') . '%',
];
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The table header includes a "Path" column, but the row rendering outputs hostname twice. This results in the Path column showing the wrong data. Render $test['path'] (or the correct path field) for the Path column instead of repeating hostname.

Copilot uses AI. Check for mistakes.
/**
* Install the maintenance plugin
*
* Registers all hooks, realms, and creates database tables.
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The realm name "Maintenance Schedules" is user-facing but is not wrapped in a translation function. For consistency with other plugin UI strings (e.g., setup.php:62), wrap it with __('Maintenance Schedules', 'maint') so it can be localized.

Copilot uses AI. Check for mistakes.
Comment on lines +384 to +386
),
)
. '</b></li>';
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The generated "$save_html" Return button markup is missing the closing ">" for the tag, which results in invalid HTML and can break the action confirmation UI. Close the button tag properly.

Copilot uses AI. Check for mistakes.
Comment on lines +1865 to +1866
* - Filter by search term
* - Toggle between associated/all tests
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The element has an extra trailing quote in the id attribute (id='rows''). This is invalid HTML and can break jQuery selectors like $('#rows'). Remove the stray quote.

Copilot uses AI. Check for mistakes.
Comment on lines +1585 to 1586
form_end();
}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

This section uses __esc('Set/Refresh Filters') / __('Go') without the plugin text domain, while other UI strings in this file consistently pass 'maint' (e.g., maint.php:1246 and maint.php:1888). This can lead to missing translations for these labels; pass the 'maint' domain consistently.

Copilot uses AI. Check for mistakes.
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