-
Notifications
You must be signed in to change notification settings - Fork 203
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
EZP-26297: REST embedding http cache integration #1789
EZP-26297: REST embedding http cache integration #1789
Conversation
Makes it easier to enable HttpCache controllers, and increases extensibility.
Meant as a proxy of REST controllers. If a method returns a CachedValue object, it logs a deprecation notice, and unwraps the value from the cached object.
9be4a0b
to
6dcd26f
Compare
…lue object fixup! EZP-25696: Allow 'path' cache tag in CachedValue object
When a resource is embedded: - adds the X-eZ-Embed-Value header - adds the cache tags from the embedded object to the response
Allows multiple run of the REST tests without resetting the database.
6dcd26f
to
7b42078
Compare
This Pull Request does not respect PSR-2 Coding Standards, please, see the suggested diff below: Loaded config from "/jenkins/jenkins.std/jobs/PAPI-Pull-Request-code-sniffer/workspace/.php_cs"
..............................................................F..FF............................................................................................................................................................................................................................................................................................................................................................................................
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
1) eZ/Bundle/EzPublishRestBundle/Tests/Functional/ContentTypeTest.php (multiline_array_trailing_comma, return, braces)
---------- begin diff ----------
--- Original
+++ New
@@ @@
);
-
@@ @@
);
+
@@ @@
'identifier' => $row['identifier'],
- 'fieldDefinitions' => []
+ 'fieldDefinitions' => [],
@@ @@
);
+
@@ @@
'id' => $struct['ContentTypeGroup']['id'],
- 'identifier' => $struct['ContentTypeGroup']['identifier']
+ 'identifier' => $struct['ContentTypeGroup']['identifier'],
@@ @@
'identifier' => $struct['ContentType']['identifier'],
- 'fieldDefinitions' => []
+ 'fieldDefinitions' => [],
]
);
}
private function parseContentTypeListFromRespose($response)
{
}
}
---------- end diff ----------
2) eZ/Bundle/EzPublishRestBundle/Tests/Functional/UrlAliasTest.php (multiline_array_trailing_comma, parenthesis, elseif)
---------- begin diff ----------
--- Original
+++ New
@@ @@
- self::assertHttpResponseCodeEquals( $response, 204 );
+ self::assertHttpResponseCodeEquals($response, 204);
@@ @@
$responseStruct['UrlAliasRefList']['UrlAlias']
- )
+ ),
@@ @@
$id = $part;
- } else if (isset($id)) {
+ } elseif (isset($id)) {
return $id;
}
}
}
/**
* @param Response $response
* @return URLAlias
*/
private function parseUrlAliasFromResponse(Response $response)
{
$responseStruct = json_decode($response->getContent(), true);
return new URLAlias(
[
'id' => $responseStruct['UrlAlias']['_id'],
'destination' => new Location(['id' => $this->extractLastIdFromHref($responseStruct['UrlAlias']['location']['_href'])]),
]
);
}
}
---------- end diff ----------
3) eZ/Bundle/EzPublishRestBundle/Tests/Functional/BinaryContentTest.php (return, unused_use)
---------- begin diff ----------
--- Original
+++ New
@@ @@
use eZ\Bundle\EzPublishRestBundle\Tests\Functional\TestCase as RESTFunctionalTestCase;
-use eZ\Publish\SPI\Variation\Values\ImageVariation;
@@ @@
XML;
+
return $this->createContent($xml);
}
}
---------- end diff ----------
Fixed all files in 494.045 seconds, 26.250 MB memory used |
Replaced by http://github.com/ezsystems/ezplatform-http-cache. do not delete the branch yet |
Closing PR as obsolete. eZ Platform 2.5 has reached EOM, so please reopen PR in ezsystems/ezplatform-kernel (bug fixes) or ibexa/core (features/improvements) if issue is still valid for v3.3 / v4.x and you are willing to work on it. |
This change integrates HTTP cache multi-tagging to the eZ Platform REST API. Multi-tagging allows responses to be tagged (ex:
content-42
,location-300
,content-type-15
, ...). Those tags can be used to purge cached resources matching a given tag. This is done by the Public API when an operation modifies the repository.The REST controllers return
CachedValue
objects, with cache tags.The main challenge is to make sure that the tags of any embedded resource are part of the main response's answer. The
ResourceLink
visitor, used by REST embedding, loads embedded content using the controllers, and adds any cache tag to the response.Implementation changes
HttpCache layer refactored to proxy controllers
Generation of
CachedValue
objects is moved out of the REST controllers. They got pretty large already. Instead, caching is implemented as for the persistence layer. Each controller has anHttpCache
equivalent. They forward every action to the actual controller, and wrap the response in aCachedValue
object, with the tags.The cache controllers are enabled in
EzPublishRestExtension
.As some actions were already returning
CachedValue
objects, aCachedValueUnwrapperController
has been added:REST\Server\HttpCache\LocationController
REST\Server\HttpCache\CachedValueUnwrapperController
REST\Server\Controller\Location
It will any wrapped value
CachedValue
, and if it did, throw a deprecation notice about it.TODO