Skip to content

Upb. Refactoring .SQL queries optimized.#684

Open
Glomberg wants to merge 6 commits into
devfrom
Upb-Refactoring-SQL-queries-optimized-VI
Open

Upb. Refactoring .SQL queries optimized.#684
Glomberg wants to merge 6 commits into
devfrom
Upb-Refactoring-SQL-queries-optimized-VI

Conversation

@Glomberg

@Glomberg Glomberg commented Jul 3, 2026

Copy link
Copy Markdown
Member

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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(), but FileEditorDisabler::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.

Comment thread lib/CleantalkSP/SpbctWP/FileEditorDisabler/FileEditorDisabler.php
Comment thread lib/CleantalkSP/SpbctWP/Variables/Cookie.php Outdated
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.

3 participants