Upb. Refactoring .SQL queries optimized.#684
Open
Glomberg wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors parts of the WordPress security plugin to reduce repeated DB work by reusing already-computed scanner warning state, and simplifies cookie variable retrieval by consolidating logic into the shared ServerVariables flow.
Changes:
- Updated file-editor disabling “auto mode” to rely on a precomputed “critical files” flag instead of querying the scan-results table directly.
- Refactored WP cookie handling to override
getVariable()and delegate common retrieval to the base cookie implementation. - Adjusted the file-editor disabler unit test to account for the new “critical files” signal.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/lib/CleantalkSP/SpbctWP/FileEditorDisabler/FileEditorDisablerTest.php | Updates tests to reflect the new auto-mode critical-files signal (but still contains now-obsolete DB mocking). |
| lib/CleantalkSP/Variables/Cookie.php | Removes unused parameter from getVariable() for cookie retrieval. |
| lib/CleantalkSP/SpbctWP/Variables/Cookie.php | Moves WP-specific cookie handling into getVariable() and delegates to parent for standard retrieval. |
| lib/CleantalkSP/SpbctWP/FileEditorDisabler/FileEditorDisabler.php | Replaces per-call DB counting with a precomputed “critical files warning” flag to decide auto-mode behavior. |
Comments suppressed due to low confidence (1)
tests/lib/CleantalkSP/SpbctWP/FileEditorDisabler/FileEditorDisablerTest.php:78
- This test still manipulates the scan results table via
mockGetCriticalCount(), butFileEditorDisabler::syncDisallowFileEditBySettings()no longer queries the DB. The DB setup is now unnecessary work and makes the test misleading; it should set the same flag/source that production code uses for auto-mode (e.g.,$spbc->data['display_scanner_warnings']['critical']).
global $spbc;
$spbc->notice_critical_files_warning = true;
$settings = array(
'misc_disable_file_editor' => 2
);
// Mock getCriticalCount to return 3 (critical files exist, so auto mode stays enabled)
$this->mockGetCriticalCount(3);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alexandergull
approved these changes
Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://app.doboard.com/1/task/52524