IBX-11776: Fixed invalidating files when the content version didn't change#80
IBX-11776: Fixed invalidating files when the content version didn't change#80Sztig wants to merge 7 commits into
Conversation
…ted but the content version has not changed
6eb6655 to
4960e6e
Compare
|
For browser tests to pass you most likely need to backport the following: https://github.com/ibexa/http-cache/pull/78/changes#diff-6f36e7155819d94620ee9ed91d27e6b0c5f9cc9ff1332031dd6263eb9e51d677. |
| $purged = []; | ||
|
|
||
| foreach ($content->getFields() as $field) { | ||
| $value = $field->value; |
There was a problem hiding this comment.
Please don't use magic where possible.
| $value = $field->value; | |
| $value = $field->getValue(); |
| public function testNoFieldsDoesNotCallPurge(): void | ||
| { | ||
| $this->proxyClient->expects(self::never())->method('purge'); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([])); | ||
| } | ||
|
|
||
| public function testNonBinaryFieldIsSkipped(): void | ||
| { | ||
| $this->proxyClient->expects(self::never())->method('purge'); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([ | ||
| new Field(['value' => new \stdClass()]), | ||
| ])); | ||
| } |
There was a problem hiding this comment.
These can be one test with a data provider
| public function testImageValueWithNullUriIsSkipped(): void | ||
| { | ||
| $imageValue = new ImageValue(); | ||
| $imageValue->uri = null; | ||
|
|
||
| $this->proxyClient->expects(self::never())->method('purge'); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([ | ||
| new Field(['value' => $imageValue]), | ||
| ])); | ||
| } | ||
|
|
||
| public function testImageValueWithEmptyUriIsSkipped(): void | ||
| { | ||
| $imageValue = new ImageValue(); | ||
| $imageValue->uri = ''; | ||
|
|
||
| $this->proxyClient->expects(self::never())->method('purge'); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([ | ||
| new Field(['value' => $imageValue]), | ||
| ])); | ||
| } |
There was a problem hiding this comment.
Seems these could also be attached to the mentioned data provider.
| public function testImageValueWithUriIsInvalidated(): void | ||
| { | ||
| $imageValue = new ImageValue(); | ||
| $imageValue->uri = '/var/site/storage/images/foo.jpg'; | ||
|
|
||
| $this->proxyClient | ||
| ->expects(self::once()) | ||
| ->method('purge') | ||
| ->with('/var/site/storage/images/foo.jpg', []); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([ | ||
| new Field(['value' => $imageValue]), | ||
| ])); | ||
| } | ||
|
|
||
| public function testBinaryFileValueWithUriIsInvalidated(): void | ||
| { | ||
| $binaryValue = new BinaryFileValue(); | ||
| $binaryValue->uri = '/var/site/storage/original/application/foo.pdf'; | ||
|
|
||
| $this->proxyClient | ||
| ->expects(self::once()) | ||
| ->method('purge') | ||
| ->with('/var/site/storage/original/application/foo.pdf', []); | ||
|
|
||
| $this->subscriber->onPublishVersion($this->buildEvent([ | ||
| new Field(['value' => $binaryValue]), | ||
| ])); | ||
| } |
There was a problem hiding this comment.
These are also candidates for another data provider + test
|




Description:
This bug happens when we have a draft and we are making changes in this draft (in our case - the image).
Since the files are served without tagging by default, regular tag invalidation that happens when publishing content is not enough to refresh the changes.
In our logic, since it is still a draft, the content version didn't change ergo the file is presented when published without any changes. Without this fix to see the changes we would need to republish the content once again.
I have added a subscriber
BinaryFileHttpCachePurgeSubscriberthat explicitly purges the URI for ezimage, ezbinaryfile, and ezmedia when publishing the content.