-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
BUGFIX: Flush node caches when asset has changed #4788
Conversation
Linting errors are unrelated to this PR, they are already in 9.0 branch |
We need to check if this also works for Nodes that are not cached directly. E.g some uncached elements in a cached collection. |
@kitsunet I fixed the parent-propagation of the cache flush. But it's still broken, as the AssetUsageStrategie will atm just return on node of a random contentstream. We need to fix this separately as this also effects the media module. |
30abcb3
to
b994e5f
Compare
48af637
to
b353adc
Compare
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.
Love it, +1 by 👁️
Just a mini nitpick-comment. Feel free to ignore :)
protected function deserializeProperties(array $properties): PropertyValuesToWrite | ||
{ | ||
$properties = array_map( | ||
$this->loadFlowObjectsRecursive(...), | ||
$properties | ||
); | ||
|
||
return $this->deserializePropertiesCrTestSuiteTrait($properties); | ||
} | ||
|
||
public function loadFlowObjectsRecursive(mixed $value): mixed | ||
{ | ||
if (is_array($value) && isset($value['__flow_object_type'])) { | ||
return $this->persistenceManager->getObjectByIdentifier($value['__identifier'], $value['__flow_object_type'], true); | ||
} elseif (is_array($value)) { | ||
return array_map( | ||
$this->loadFlowObjectsRecursive(...), | ||
$value | ||
); | ||
} | ||
return $value; | ||
} |
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.
nice trick to fully allow the flow object syntax {"__flow_object_type":"Neos\\Media\\Domain\\Model\\Asset","__identifier":"an-asset-to-change"}
i would slightly prefer the use of a custom synax to not confuse it with the final serialization format like
{
"uriPathSegment": "a1-1",
"title": "Node a1-1",
"asset": "Asset:an-asset-to-change"
}
like we do in
Lines 98 to 115 in d0f4ecc
Scenario: Create a node aggregate with complex initial and default values | |
When the command CreateNodeAggregateWithNode is executed with payload: | |
| Key | Value | | |
| nodeAggregateId | "nody-mc-nodeface" | | |
| nodeTypeName | "Neos.ContentRepository.Testing:Node" | | |
| parentNodeAggregateId | "lady-eleonode-rootford" | | |
| initialPropertyValues | {"dayOfWeek":"DayOfWeek:https://schema.org/Friday","postalAddress":"PostalAddress:anotherDummy", "date":"Date:2021-03-13T17:33:17+00:00", "uri":"URI:https://www.neos.io", "price":"PriceSpecification:anotherDummy"} | | |
And the graph projection is fully up to date | |
Then I expect a node identified by cs-identifier;nody-mc-nodeface;{} to exist in the content graph | |
And I expect this node to have the following properties: | |
| Key | Value | | |
| dayOfWeek | DayOfWeek:https://schema.org/Friday | | |
| array | {"givenName":"Nody", "familyName":"McNodeface"} | | |
| postalAddress | PostalAddress:anotherDummy | | |
| now | Date:now | | |
| date | Date:2021-03-13T17:33:17+00:00 | | |
| uri | URI:https://www.neos.io | | |
| price | PriceSpecification:anotherDummy | |
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 was thinking about that.... But why creating a new syntax if we already have one? And how would you handle arrays of assets?
{
"uriPathSegment": "a1-1",
"title": "Node a1-1",
"assets": "Assets:an-asset-to-change,some-other-asset"
}
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.
yeah exactly that are the things that speak against this ;) only by using a know serialisation format one might think by reading the tests that we write directly to the db which is the opposite.
In the end its fine either way, we have tests now so 🥳
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.
But why creating a new syntax if we already have one?
The one we have is an implementation detail of the Flow persistence really.
Since Behat tests are also meant to be read by humans, I agree to @mhsdesign
And the following CreateNodeAggregateWithNode commands are executed:
| nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | nodeName |
| a | root | Neos.Neos:Site | {} | site |
| a1 | a | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1", "title": "Node a1", "asset": {"__flow_object_type":"Neos\\Media\\Domain\\Model\\Asset","__identifier":"an-asset-to-change"}} | a1 |
| a1-1 | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1-1", "title": "Node a1-1", "assets": [{"__flow_object_type":"Neos\\Media\\Domain\\Model\\Asset","__identifier":"an-asset-to-change"}]} | a1-1 |
| a1-2 | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1-2", "title": "Node a1-2", "asset": {"__flow_object_type":"Neos\\Media\\Domain\\Model\\Asset","__identifier":"some-other-asset"}} | a1-2 |
| a2 | a | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a2", "title": "Node a2", "text": "Link to asset://an-asset-to-change."} | a2 |
| a3 | a | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a2", "title": "Node a2", "text": "Link to asset://some-other-asset."} | a3 |
is much harder to read than
And the following CreateNodeAggregateWithNode commands are executed:
| nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | nodeName |
| a | root | Neos.Neos:Site | {} | site |
| a1 | a | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1", "title": "Node a1", "asset": "Asset:an-asset-to-change"} | a1 |
| a1-1 | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1-1", "title": "Node a1-1", "assets": ["Asset:an-asset-to-change"]} | a1-1 |
| a1-2 | a1 | Neos.Neos:Test.DocumentType1 | {"uriPathSegment": "a1-2", "title": "Node a1-2", "asset": "Asset:some-other-asset"} | a1-2 |
| a2 | a | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a2", "title": "Node a2", "text": "Link to asset://an-asset-to-change."} | a2 |
| a3 | a | Neos.Neos:Test.DocumentType2 | {"uriPathSegment": "a2", "title": "Node a2", "text": "Link to asset://some-other-asset."} | a3 |
But obviously this could be done in a follow-up
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.
Another point that speaks for this is that when its easier to find where the custom Asset:an-asset-to-change
logic is implemented. As theres likely a regex or string reference to /Asset:[0-9a-z-]+/
in the behat code base.
The way i see it the ClassName:identifier
is our special syntax that means insert a real php object instance in here, but i can only use json in behat ^^
so +1 for a followup ;)
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.
Ok ok, I'll provide a change for this.
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.
return $this->deserializePropertiesCrTestSuiteTrait($properties); | ||
} | ||
|
||
public function loadFlowObjectsRecursive(mixed $value): mixed |
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.
public function loadFlowObjectsRecursive(mixed $value): mixed | |
private function loadFlowObjectsRecursive(mixed $value): mixed |
Ooopsi, you are quite fast... I'll change at least the visibility of |
no dont worry i deliberately didnt wait as this is just testing infrastructure, its purely cosmetic :D |
Come on. You suggest a change and then ignore your own suggestion? |
Clears the caches when asset has changed.
Also removed adding the "AssetDynamicTag" cache tag, as the occurance of assets within texts is also covered by new AssetUsage projection:
https://github.com/neos/neos-development-collection/blob/207a86d9025ff26c669c678f1[…]eos.Neos/Classes/AssetUsage/Projection/AssetUsageProjection.php
Added behat tests for content cache flushing on asset changes and also for content cache flushing on node and convertUri changes.
Fixes: #4707