Skip to content

Conveniently disable auto tagging proposal#43

Open
jan888adams wants to merge 16 commits intoconveniently-disable-auto-taggingfrom
conveniently-disable-auto-tagging-proposal
Open

Conveniently disable auto tagging proposal#43
jan888adams wants to merge 16 commits intoconveniently-disable-auto-taggingfrom
conveniently-disable-auto-tagging-proposal

Conversation

@jan888adams
Copy link
Copy Markdown
Contributor

@jan888adams jan888adams commented Mar 1, 2026

Summary by CodeRabbit

  • Documentation

    • Added comprehensive guide for suppressing automatic cache tagging behavior with usage examples and state restoration guarantees.
  • New Features

    • Enhanced cache control to allow disabling automatic tagging with selective manual tag management during request processing.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 1, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch conveniently-disable-auto-tagging-proposal

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 and usage tips.

@jan888adams jan888adams changed the base branch from main to setup-claude-code March 1, 2026 08:23
Jan Adams and others added 6 commits March 1, 2026 10:08
…internal

- Fix 0-based index in error message (was 1-based due to pre-increment)
- Use separate accumulator so partial tags are never applied on invalid yield
- Guard tag() call in finally with !isEmpty() to avoid unnecessary FOSHttpCache calls
- Fix PHPDoc Generator key type from int to array-key
- Add @internal to CacheType interface to signal it is not for external implementation
- Update CacheActivatorTest: fix broken constructor, add ProphecyTrait, add 10 tests
  covering all withoutAutomaticTagging() code paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Make TraceableResponseTagger::$recordedTags private, expose via getRecordedTags()
- Fix missing declare(strict_types=1) inline style (blank line after <?php)
- Rename $collectTagsResponseTagger to $traceableResponseTagger in test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CacheTags is immutable and TraceableResponseTagger is final,
so a getter adds ceremony with no encapsulation benefit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jan888adams jan888adams force-pushed the conveniently-disable-auto-tagging-proposal branch from f3f5a7d to 823ab45 Compare March 1, 2026 09:08
@jan888adams jan888adams changed the base branch from setup-claude-code to conveniently-disable-auto-tagging March 1, 2026 09:15
…sage

The generator key already identifies the problematic yield sufficiently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jan888adams jan888adams marked this pull request as ready for review March 1, 2026 09:47
Copilot AI review requested due to automatic review settings March 1, 2026 09:47
Copy link
Copy Markdown

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

This PR refines the CacheActivator::withoutAutomaticTagging() behavior to avoid partial tag application on generator failure, fixes a PHPDoc generator key type, aligns file header formatting with project conventions, and expands unit test coverage for withoutAutomaticTagging().

Changes:

  • Prevent partial tag application by accumulating yielded tags and applying them only after successful generator iteration.
  • Fix PHPDoc generator key type from int to array-key and simplify the invalid-yield error message.
  • Add/extend unit tests for withoutAutomaticTagging() and adjust test naming.

Reviewed changes

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

File Description
src/CacheActivator.php Accumulates generator yields before applying tags; updates PHPDoc and error message.
tests/Unit/CacheActivatorTest.php Adds unit coverage for withoutAutomaticTagging() including invalid-yield scenarios.
tests/Unit/Cache/ResponseTagger/TraceableResponseTaggerTest.php Renames the test subject property (but currently inconsistently applied).
src/Cache/ResponseTagger/TraceableResponseTagger.php Adjusts header formatting to <?php declare(strict_types=1); on one line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/CacheActivator.php Outdated
Comment thread tests/Unit/Cache/ResponseTagger/TraceableResponseTaggerTest.php
Comment thread src/CacheActivator.php Outdated
Comment thread src/Cache/CacheType.php Outdated
Comment thread src/CacheActivator.php Outdated
Jan Adams and others added 2 commits March 1, 2026 11:01
…tentional

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to traceableResponseTagger

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread src/CacheActivator.php Outdated
Jan Adams and others added 2 commits March 1, 2026 11:15
…ield

The generator key alone is ambiguous — a key of 1 could mean the first or
second yield depending on whether keys are explicit. The position counter
(0-based iteration count) provides unambiguous location information independent
of the generator key.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread src/CacheActivator.php
Jan Adams and others added 5 commits March 1, 2026 11:24
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover:
- Asset loaded inside the block is not automatically tagged
- Tag manually yielded inside the block does appear in the response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, int cast

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@doc/8-disable-caching-behavior.md`:
- Line 55: The sentence describing state restoration uses "afterwards" but
should use US English "afterward"; update the wording in the doc sentence that
mentions the caching state being restored after the block completes (the line
referencing withoutAutomaticTagging()) to replace "afterwards" with "afterward"
so the sentence reads "...it remains disabled afterward."

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12bc556 and f1c9e9b.

📒 Files selected for processing (8)
  • doc/8-disable-caching-behavior.md
  • src/Cache/ResponseTagger/TraceableResponseTagger.php
  • src/CacheActivator.php
  • tests/Integration/Fixtures/without_automatic_tagging_route.php
  • tests/Integration/Tagging/WithoutAutomaticTaggingTest.php
  • tests/Unit/Cache/ResponseTagger/TraceableResponseTaggerTest.php
  • tests/Unit/CacheActivatorTest.php
  • tests/app/src/Controller/WithoutAutomaticTaggingController.php


### State restoration

The previous caching state is always restored after the block completes, even if an exception is thrown. If caching was already disabled before calling `withoutAutomaticTagging()`, it remains disabled afterwards.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use “afterward” for US English consistency.

Replace “afterwards” with “afterward”.

✏️ Proposed wording fix
-...it remains disabled afterwards.
+...it remains disabled afterward.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The previous caching state is always restored after the block completes, even if an exception is thrown. If caching was already disabled before calling `withoutAutomaticTagging()`, it remains disabled afterwards.
The previous caching state is always restored after the block completes, even if an exception is thrown. If caching was already disabled before calling `withoutAutomaticTagging()`, it remains disabled afterward.
🧰 Tools
🪛 LanguageTool

[locale-violation] ~55-~55: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...utomaticTagging()`, it remains disabled afterwards.

(AFTERWARDS_US)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@doc/8-disable-caching-behavior.md` at line 55, The sentence describing state
restoration uses "afterwards" but should use US English "afterward"; update the
wording in the doc sentence that mentions the caching state being restored after
the block completes (the line referencing withoutAutomaticTagging()) to replace
"afterwards" with "afterward" so the sentence reads "...it remains disabled
afterward."


## Suppress automatic tagging for a specific code block

Sometimes you need to load Pimcore elements for business logic without tagging the current response with those elements. For example, loading related products to calculate a price should not cause the response to be tagged with all those products.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess this isn’t the best example..

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