Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Aug 11, 2025

Summary by CodeRabbit

  • New Features

    • Allow selectively disabling specific filters for a single operation via an optional filter list while retaining the existing "disable all" scoped behavior.
  • Bug Fixes

    • Decoding now bypasses filters that were temporarily disabled.
    • Filter state is reliably restored after scoped operations, including when errors occur.

cursoragent and others added 4 commits August 11, 2025 06:39
Co-authored-by: jakeb994 <jakeb994@gmail.com>
Co-authored-by: jakeb994 <jakeb994@gmail.com>
Co-authored-by: jakeb994 <jakeb994@gmail.com>
…tion safety

Co-authored-by: jakeb994 <jakeb994@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Walkthrough

Adds per-filter skipping to Database: a protected disabledFilters map, skipFilters(callable, ?array) to selectively disable filters with try/finally state save/restore, and decodeAttribute early-returns when a relevant filter is disabled.

Changes

Cohort / File(s) Summary of Changes
Filter control API & state
src/Database/Database.php
Added protected ?array $disabledFilters = []; and changed skipFilters signature to skipFilters(callable $callback, ?array $filters = null). Implemented selective disabling when filter names provided, full-disable when null, saved/restored filter state and disabledFilters map with try/finally. Updated decodeAttribute to check disabledFilters and return the original value when the corresponding filter is disabled.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Database
  participant Filters

  Caller->>Database: skipFilters(callback, filterNames = null)
  alt No specific filters
    Database->>Database: Save current filter state
    Database->>Filters: Disable all filters
    Database->>Database: Execute callback
    Database->>Filters: Restore all filters
  else Specific filters list
    Database->>Database: Save filter state + disabledFilters
    Database->>Database: Set disabledFilters = {names}
    Database->>Database: Execute callback
    Database->>Database: Restore filter state + disabledFilters
  end
Loading
sequenceDiagram
  participant Caller
  participant Database
  participant FilterX

  Caller->>Database: decodeAttribute(attr, value)
  Database->>Database: Check disabledFilters for FilterX
  alt FilterX disabled
    Database-->>Caller: return value (unchanged)
  else Active
    Database->>FilterX: decode(value)
    FilterX-->>Database: decodedValue
    Database-->>Caller: decodedValue
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Poem

I twitch my ears at filters’ fate,
Some I skip, some I await.
With careful paws I save the state,
Try, then finally, navigate.
Decoders rest when told to wait—
Hippity-hop, our data’s straight! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 768306f and a76fcb6.

📒 Files selected for processing (1)
  • src/Database/Database.php (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Database/Database.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Adapter Tests (SharedTables/MySQL)
  • GitHub Check: Adapter Tests (Mirror)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/skipfilters-optional-list

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/Database/Database.php (3)

351-352: Tighten type and clarify semantics for disabledFilters

Current nullable type isn’t used (never set to null). Prefer a non-nullable map with clear key/value intent.

-    protected ?array $disabledFilters = [];
+    /** @var array<string, bool> map of filter-name => true to disable selectively */
+    protected array $disabledFilters = [];

820-852: Refine skipFilters: remove unnecessary state handling and simplify map build

  • Capturing/restoring $this->filter in the selective branch is unnecessary (it’s never changed there).
  • Build the disabled map via array_fill_keys for clarity.
  • Consider documenting the new parameter in the docblock.
-    public function skipFilters(callable $callback, ?array $filterNames = null): mixed
+    public function skipFilters(callable $callback, ?array $filterNames = null): mixed
     {
         if (\is_null($filterNames)) {
             $initial = $this->filter;
             $this->disableFilters();

             try {
                 return $callback();
             } finally {
                 $this->filter = $initial;
             }
         }

-        $previousFilter = $this->filter;
         $previousDisabledFilters = $this->disabledFilters;

-        if (\count($filterNames) === 0) {
-            $this->disabledFilters = [];
-        } else {
-            $disabledFilters = [];
-            foreach ($filterNames as $filterName) {
-                $disabledFilters[$filterName] = true;
-            }
-            $this->disabledFilters = $disabledFilters;
-        }
+        // Empty list => disable none (empty map)
+        $this->disabledFilters = \array_fill_keys($filterNames, true) ?: [];

         try {
             return $callback();
         } finally {
-            $this->filter = $previousFilter;
             $this->disabledFilters = $previousDisabledFilters;
         }
     }

Docblock nit (outside changed lines): please add

  • @param array|null $filterNames Optional filter names to disable; null disables all filters.”

6652-6655: Simplify disabled-filter check and align with non-nullable map

Since disabledFilters is an array (see suggestion above), the is_null check can be dropped.

-        if (!\is_null($this->disabledFilters) && isset($this->disabledFilters[$filter])) {
+        if (isset($this->disabledFilters[$filter])) {
             return $value;
         }

Also, confirm intent: selective skipping currently applies only to decode. If you want parity for encode as well, we can add the same check in encodeAttribute.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d78413f and 768306f.

📒 Files selected for processing (1)
  • src/Database/Database.php (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Database/Database.php (1)
src/Database/Adapter.php (1)
  • filter (1127-1136)

@abnegate abnegate merged commit 39c6140 into main Aug 11, 2025
15 checks passed
@abnegate abnegate deleted the feat/skipfilters-optional-list branch August 11, 2025 08:03
abnegate added a commit that referenced this pull request Aug 11, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 14, 2025
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