Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

EZP-26297: REST embedding http cache integration - #1789

Closed
bdunogier wants to merge 15 commits into
ezp26297-rest_embedding_http_cache_mergefrom
ezp26297-rest_embedding_http_cache_integration
Closed

bdunogier wants to merge 15 commits into
ezp26297-rest_embedding_http_cache_mergefrom
ezp26297-rest_embedding_http_cache_integration

Conversation

@bdunogier

@bdunogier bdunogier commented Sep 28, 2016

Copy link
Copy Markdown
Contributor

Implements EZP-26297
Based on the ezp26297-rest_embedding_http_cache_merge branch, that contains both #1741 and #1772

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 an HttpCache equivalent. They forward every action to the actual controller, and wrap the response in a CachedValue object, with the tags.

The cache controllers are enabled in EzPublishRestExtension.

As some actions were already returning CachedValue objects, a CachedValueUnwrapperController 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

  • Describe this pull-request
  • Relation handling (also needs implementation in Signal layer / CachedValue)
  • Extract changes to [WIP] Feature EZP-25696: HTTPCache Multi Tagging/labeling #1772 to separate pull-requests
  • Refresh & add spec
  • Functional test coverage (done: Content)
  •  Merge master to get the fix for content type identifier copy, and revert workaround commit
  •  Re-add caching of VersionList and ContentType (removed lately)
  •  Add caching for ContentTypeGroup

Bertrand Dunogier added 2 commits September 27, 2016 17:11
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.
@bdunogier
bdunogier force-pushed the ezp26297-rest_embedding_http_cache_integration branch 2 times, most recently from 9be4a0b to 6dcd26f Compare September 29, 2016 22:36
@bdunogier
bdunogier force-pushed the ezp26297-rest_embedding_http_cache_integration branch from 6dcd26f to 7b42078 Compare October 4, 2016 15:13
@ezrobot

ezrobot commented Oct 4, 2016

Copy link
Copy Markdown
Contributor

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

@bdunogier

Copy link
Copy Markdown
Contributor Author

Replaced by http://github.com/ezsystems/ezplatform-http-cache. do not delete the branch yet

@adamwojs

Copy link
Copy Markdown
Member

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.

@adamwojs adamwojs closed this Apr 19, 2022
@adamwojs
adamwojs deleted the ezp26297-rest_embedding_http_cache_integration branch April 19, 2022 13:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants