Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294542

Importing (deploying) REST resource config entities should automatically do the necessary route rebuilding

$
0
0

Problem/Motivation

While working on #2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method, I noticed it was unfortunately necessary to rebuild the router whenever you imported (i.e. deployed) RestResourceConfig config entities. This should happen automatically thanks to a ConfigEvents::SAVE event subscriber.

Worse, you actually even need to call drupal_flush_all_caches(): just calling $this->container->get('router.builder')->rebuild() is insufficient! (I have no idea why yet.)

When doing an import through the UI, this means you need to go to /admin/config/development/performance and click the Clear all caches button. If a developer forgets this step, then their REST routes won't work.

Proposed resolution

  1. Routing system:
    1. Add http_response cache tag to all cacheable responses.
    2. Let route rebuilder invalidate the http_response_ cache tag after every rebuild.
  2. REST module:
    1. Make RestResourceConfig::post(Save|Delete) mark the router as needing a rebuild.
    2. Implement a REST config save event subscriber (for the rest.settings config) that marks the router as needing a rebuild.

Together this means that:

  1. every router rebuild will now invalidate all responses. Cached 404 responses may become 200s, 200s may become 403s, 404s may become 403s, and so on. Hence all cached responses need to be rebuilt.
  2. whenever RestResourceConfig config entities or rest.settings simple config change, mark the router as needing a rebuild, which will trigger the above.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.


Viewing all articles
Browse latest Browse all 294542


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>