Skip to content

fix: guard multiple accounts query context - #1714

Merged
superdav42 merged 2 commits into
mainfrom
feature/auto-20260810-110431
Aug 10, 2026
Merged

fix: guard multiple accounts query context#1714
superdav42 merged 2 commits into
mainfrom
feature/auto-20260810-110431

Conversation

@superdav42

@superdav42 superdav42 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Guard the Multiple Accounts compatibility query filter when wpdb func_call is unset or null.
  • Add regression coverage for fix_user_query() receiving a null function-call context.

Verification

  • php -l inc/compat/class-multiple-accounts-compat.php
  • php -l tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php
  • vendor/bin/phpcs inc/compat/class-multiple-accounts-compat.php tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php
  • vendor/bin/phpunit --filter Multiple_Accounts_Compat_Test
  • Pre-commit hook: PHPCS + PHPStan on staged PHP files

Summary by CodeRabbit

  • Bug Fixes

    • Improved compatibility when processing queries if the database function-call value is unavailable or null.
    • Queries are now preserved correctly in this scenario.
  • Tests

    • Added coverage to verify safe handling of missing database function-call values and restoration of the original state.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

fix_user_query() now safely handles a null or unavailable $wpdb->func_call value. A test verifies that the query remains unchanged and that the original global value is restored.

Changes

Multiple accounts compatibility

Layer / File(s) Summary
Safe func_call handling and coverage
inc/compat/class-multiple-accounts-compat.php, tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php
fix_user_query() defaults $wpdb->func_call to an empty string before checking its prefix. The test verifies query preservation for a null value and restores the original global state.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: guarding the Multiple Accounts query context against unset or null function-call data.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260810-110431

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php (1)

23-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for an unset func_call property.

This test assigns null to $wpdb->func_call. It does not exercise the unset-property path handled by the new ?? fallback.

Add a separate test or data-provider case that calls unset($wpdb->func_call) and verifies that fix_user_query() returns the original query. Preserve the existing finally cleanup.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php` around lines 23 - 29, Add
a separate test or data-provider case alongside
test_fix_user_query_tolerates_null_func_call that unsets $wpdb->func_call before
calling fix_user_query(), asserts the original query is returned, and preserves
the existing finally-based restoration cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php`:
- Around line 23-29: Add a separate test or data-provider case alongside
test_fix_user_query_tolerates_null_func_call that unsets $wpdb->func_call before
calling fix_user_query(), asserts the original query is returned, and preserves
the existing finally-based restoration cleanup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9233096e-6805-4602-80ef-078b532447b1

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0e7b8 and eea6e52.

📒 Files selected for processing (2)
  • inc/compat/class-multiple-accounts-compat.php
  • tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42
superdav42 merged commit 75e3b0e into main Aug 10, 2026
11 checks passed
@superdav42

Copy link
Copy Markdown
Collaborator Author

Summary

  • Guard the Multiple Accounts compatibility query filter when wpdb func_call is unset or null.
  • Add regression coverage for fix_user_query() receiving a null function-call context.

Verification

  • php -l inc/compat/class-multiple-accounts-compat.php
  • php -l tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php
  • vendor/bin/phpcs inc/compat/class-multiple-accounts-compat.php tests/WP_Ultimo/Multiple_Accounts_Compat_Test.php
  • vendor/bin/phpunit --filter Multiple_Accounts_Compat_Test
  • Pre-commit hook: PHPCS + PHPStan on staged PHP files


Merged via PR #1714 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).

@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Aug 11, 2026
@superdav42

Copy link
Copy Markdown
Collaborator Author

DISPATCH_CLAIM nonce=486e293e840cad1691619180ce2ed2fd runner=superdav42 ts=2026-08-11T19:08:13Z max_age_s=120 version=3.32.251 opencode_version=1.18.9 lease_token=486e293e840cad1691619180ce2ed2fd device=device-1783824528-2609248-26808 session=issue-1714 phase=prelaunch expires_at=1786475415

@superdav42

Copy link
Copy Markdown
Collaborator Author

REVIEW_FOLLOWUP_CREATED source_pr=1714 issue=1722 fingerprint=source-pr-1714 runner=superdav42 ts=2026-08-11T19:08:35Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant