Skip to content

[Cache] Fix decoration of TagAware adapters in dev #22960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2017

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented May 30, 2017

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #22956
License MIT
Doc PR n/a

{
$event = $this->start(__FUNCTION__, $tags);
try {
return $event->result = $this->pool->invalidateTags($tags);
Copy link
Member

Choose a reason for hiding this comment

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

should it throw when the pool doesn't implement TagAwareAdapterInterface itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

I still hesitate, calling invalidateTags() on it would gives the same error as when calling it on the inner directly, right?

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone May 30, 2017
@jvasseur
Copy link
Contributor

jvasseur commented May 30, 2017

Shouldn't we have a separate TagAwareTraceableAdapter to decorate tag aware adapters and keep the current one for non tag aware adapters to prevent having an adapter implementing the TagAwareAdapterInterface when in doesn't?

@chalasr chalasr force-pushed the debug-adapter-tags branch from 358132f to c677879 Compare May 30, 2017 13:55
@chalasr chalasr changed the title [Cache] Make TraceableAdapter TagAware [Cache] Fix decoration of TagAware adapters in dev May 30, 2017
@chalasr
Copy link
Member Author

chalasr commented May 30, 2017

TraceableTagAwareAdapter added and wired to decorate tag aware adapters

@chalasr chalasr force-pushed the debug-adapter-tags branch from c677879 to c369b72 Compare May 30, 2017 14:13
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

/**
* @author Robin Chalas <robin.chalas@gmail.com>
*/
class TraceableTagAwareAdapter implements TagAwareAdapterInterface
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense for this class to extend the TraceableAdapter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of adding a trait? That would require to open the $pool property but I've no strong preference

Copy link
Member

Choose a reason for hiding this comment

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

Else we will need to update CacheDataCollector as its addInstance() method is type hinted with TraceableAdapter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @xabbuh. I don't really understand the trait purpose appart from allowing us to make it @internal while TraceableAdapater is already released as "public".
Using inheritance and adding the protected TraceableAdapter::getPool() method looks a better option to me for this.

Copy link
Member

Choose a reason for hiding this comment

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

makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@chalasr chalasr force-pushed the debug-adapter-tags branch 2 times, most recently from a780213 to 9103167 Compare May 31, 2017 07:56
public function __construct(TagAwareAdapterInterface $pool)
{
parent::__construct($pool);
}
Copy link
Member

Choose a reason for hiding this comment

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

the constructor is not needed

Copy link
Member

Choose a reason for hiding this comment

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

it is: it adds a type hint constraint

Copy link
Member

Choose a reason for hiding this comment

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

oh indeed

@@ -22,7 +22,8 @@
*/
class TraceableAdapter implements AdapterInterface
{
private $pool;
/** @internal */
Copy link
Member

Choose a reason for hiding this comment

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

let's remove that (and the one on the start method)
they are part of the internal api/respo of the class

@chalasr chalasr force-pushed the debug-adapter-tags branch from 9103167 to 28e615a Compare May 31, 2017 08:26
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

@nicolas-grekas
Copy link
Member

Thank you @chalasr.

@nicolas-grekas nicolas-grekas merged commit 28e615a into symfony:3.3 May 31, 2017
nicolas-grekas added a commit that referenced this pull request May 31, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[Cache] Fix decoration of TagAware adapters in dev

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22956
| License       | MIT
| Doc PR        | n/a

Commits
-------

28e615a Fix decorating TagAware adapters in dev
@chalasr chalasr deleted the debug-adapter-tags branch May 31, 2017 09:59
chalasr pushed a commit to chalasr/symfony that referenced this pull request May 31, 2017
…(chalasr)

This PR was merged into the 3.3 branch.

Discussion
----------

[Cache] Fix decoration of TagAware adapters in dev

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony#22956
| License       | MIT
| Doc PR        | n/a

Commits
-------

28e615a Fix decorating TagAware adapters in dev
@tifabien
Copy link
Contributor

tifabien commented Jun 1, 2017

@chalasr, I just pulled the 3.3.x-dev branch and tried your fix. It seems the $definition->getClass() in src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CacheCollectorPass.php:47 always returns null so we always register the TraceableAdapter::class.

@chalasr
Copy link
Member Author

chalasr commented Jun 1, 2017

@tifabien ok I'm looking at it

@chalasr
Copy link
Member Author

chalasr commented Jun 1, 2017

@tifabien Can you please try #23018 on your project?

fabpot added a commit that referenced this pull request Jun 1, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle] Fix CacheCollectorPass priority

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | #22960 (comment)

It was run before optimization, so child definitions were not resolved yet.

Commits
-------

28b253a Fix CacheCollectorPass priority
@fabpot fabpot mentioned this pull request Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants