Extend cache actions beyond ECA

Created on 15 January 2023, almost 2 years ago
Updated 24 September 2023, about 1 year ago

Problem/Motivation

Currently ECA Cache Actions are limited to ECA cache only. Could we open ECA Cache Actions up to all Drupal caching? Use case: Use https://www.drupal.org/project/views_custom_cache_tag β†’ to add a tag to the view, then invalidate it based on an ECA event.

Steps to reproduce

Create an Action with Cache Invalidate.
Use a core cache key in the Action.
Does not invalidate.

Proposed resolution

Add cache keys/bins beyond ECA.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eswiderski

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Assigned to jurgenhaas
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • @jurgenhaas opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This MR keeps all the ECA related cache actions in place and adds 3 equivalent actions for "raw cache" operations.

  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    Back then we had a discussion on what scope ECA should support when dealing with certain backends (cache, state etc.). It's somewhere in the issue queue where I implemented all these actions. We agreed on the limited scope, so that we don't get into unforseen trouble. I advise to not support "just everything". Touching raw data of other components outside of ECA is a high risk on opening a Box of Pandora.

    Since, a developer could access them by creating a custom module anyway.

    For such a case, it makes sense that a developer takes care of it, either with a custom module or a specific custom action that takes care of it properly.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The discussion was at https://www.drupal.org/project/eca/issues/3277898#comment-14516498 β†’ back in May 2022:

    Q: This is caching in an ECA "sandbox", i.e. we do not grant access to other caches in the Drupal instance, correct?

    A: Yes correct, this mechanic is supposed for ECA-related stuff only. Affecting other caches can quickly break a site's performance which may lead to downtimes etc. Touching other caching parts of Drupal should be a developer's task.

    I'd think that we've learned a lot ever since. ECA is here to replace custom code for those who prefer to do that. And most of the stuff in ECA is capable enough to break sites. Especially because it allows to switch to user 1 where it is possible to delete in fact every entity without limitation.

    That said, it might become a requirement to introduce some sort of permission system to protect the usage of certain plugins during the modelling phase, i.e. to only grant access to certain plugins for users with special permissions. Very much like the restrict access: true property on permissions.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    Agree @jurgenhaas.

    @mxh It seems like we'd be limiting ECA's scope just for this use case. If a vision for ECA is to indeed empower non-developers and alleviate custom development, then this would be extremely powerful. Personally, ECA has already allowed me to eliminate 30-40 modules. But also realize the project needs some guardrails.

    That stated, ECA is life-changing without this capability...and completely respect both of your pov's. Just my $0.02.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany danielspeicher Steisslingen

    For me, the features are very helpful.

  • Status changed to Fixed almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Taking this one carefully and being fully aware of the responsibility we take, I think it's reasonable to accept this MR with 3 pro and 1 con advice.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    One test is failing.

  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    Furthermore, no tests were added to the new actions yet. In general, adding automated tests to new plugins is always recommended.

  • Assigned to mxh
  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    Having a look at this.

  • @mxh opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    MR303 fixes the failing test, as the trait had a wrong copy-paste from the previous logic. I had to adjust that accordingly, otherwise our cache configured actions behave differently when using 1.2.x branch (cache invalidation currently doesn't work at all).

    #16 still remains open.

  • Assigned to jurgenhaas
  • Status changed to Needs work almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Oh, I see my mistake. Thanks for finding and fixing this. I've merged this after a small adaption in \Drupal\eca_cache\Plugin\Action\EcaCacheTrait::getCacheKey for better readability.

    Assigning the issue to myself for work on the missing tests.

  • @jurgenhaas opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Tests for the extended cache actions are ready for review.

  • Status changed to RTBC over 1 year ago
  • πŸ‡©πŸ‡ͺGermany danielspeicher Steisslingen

    Test was added, which is pretty nice.

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Great, thanks a lot. This is now also merged and closed.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    Can we merge this into one of the newer dev branches?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @eswiderski this got merged into the latest dev release back in February already. As it is a new feature, it won't go back into 1.1.x, though. If you need to make it available in 1.1.x for one of your installations, you needed to patch your installation.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    Ok, was it merged into 1.1.x-dev and 1.2.x-dev? I'm not seeing any difference behavior in 1.1.x-dev.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    No, it's only merged into 1.2.x (which is now 2.0.x) and won't get into 1.1.x because it's a new feature and not a bug fix.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    Ahh, ok thank you! I was still using 1.2.x-dev.

Production build 0.71.5 2024