-
Notifications
You must be signed in to change notification settings - Fork 201
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
Leaking result cache metadata #588
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ede8eac
Added test case for leaking cache metadata.
pmelab e1727f2
Properly collecting leaked cache metadata.
pmelab 04b6a29
Update FieldPluginBase.php
fubhy 9e343c6
Let's try this ...
fubhy 9bc38cb
Collect leaked cache metadata also for deferred results
fubhy fc4b14b
Update FieldPluginBase.php
fubhy f638886
Update FieldPluginBase.php
fubhy 2a33e5f
Revert "Update FieldPluginBase.php"
pmelab 37033df
Revert "Update FieldPluginBase.php"
pmelab 04dcd6d
Revert "Collect leaked cache metadata also for deferred results"
pmelab 7618a43
Revert "Let's try this ..."
pmelab 02f1e13
Revert "Update FieldPluginBase.php"
pmelab fb40140
Added test case that leaks cache metadata before returning a deferred…
pmelab 447d96b
Attempt to solve leaking cache metadata without cowboy-hipshots that …
pmelab d5ed2a3
Merge branch '8.x-3.x' into test-leaking-cache-metadata
pmelab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,18 +152,26 @@ protected function isLanguageAwareField() { | |
* {@inheritdoc} | ||
*/ | ||
protected function resolveDeferred(callable $callback, $value, array $args, ResolveContext $context, ResolveInfo $info) { | ||
$result = $this->getRenderer()->executeInRenderContext(new RenderContext(), function () use ($callback, $value, $args, $context, $info) { | ||
return $callback($value, $args, $context, $info); | ||
$renderContext = new RenderContext(); | ||
|
||
$result = $this->getRenderer()->executeInRenderContext($renderContext, function () use ($callback, $value, $args, $context, $info) { | ||
$result = $callback($value, $args, $context, $info); | ||
if ($result instanceof \Generator) { | ||
$result = iterator_to_array($result); | ||
} | ||
return $result; | ||
}); | ||
|
||
if (!$renderContext->isEmpty() && $info->operation->operation === 'query') { | ||
$context->addCacheableDependency($renderContext->pop()); | ||
} | ||
|
||
if (is_callable($result)) { | ||
return new Deferred(function () use ($result, $value, $args, $context, $info) { | ||
return $this->resolveDeferred($result, $value, $args, $context, $info); | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. build fails for syntax error ... I think you're missing |
||
|
||
$result = iterator_to_array($result); | ||
|
||
// Only collect cache metadata if this is a query. All other operation types | ||
// are not cacheable anyways. | ||
if ($info->operation->operation === 'query') { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add
$callback
and$renderContext
to the use statement.