SEO Tools recipe should automatically reapply itself every time a content type is created

Created on 23 January 2025, about 1 month ago

Problem/Motivation

If you apply SEO Tools, you get SEO stuff on all your existing content types. If you create a new content type, it won't have any of the SEO things; you'll have to know to go reapply the recipe. How cool would it be if you didn't have to do that?

Proposed resolution

ECA to the rescue. It just committed Self-reapplying recipes 😈 Active , which would allow SEO Tools to ship an ECA model that, whenever a new content type is created, automatically reapplies the SEO Tools recipe.

Let's see if we can do exactly that, and then see what the implications are, and what (if any) difficulties result from it.

Feature request
Status

Active

Component

Track: SEO

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • 🇮🇳India narendraR Jaipur, India
  • Merge request !474Initial commit → (Open) created by narendraR
  • Pipeline finished with Failed
    30 days ago
    Total: 501s
    #404604
  • Pipeline finished with Failed
    30 days ago
    Total: 944s
    #404645
  • 🇺🇸United States thejimbirch Cape Cod, Massachusetts

    This is awesome @narendrar! I made some minor suggestions.

    I assume this will have to wait until the action is in a full release of ECA, and we'll have to update all the spots that are marked dev in this MR to the new release.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    I assume this will have to wait until the action is in a full release of ECA, and we'll have to update all the spots that are marked dev in this MR to the new release.

    I've just tagged ECA 2.1.2 that contains those new features.

  • 🇺🇸United States phenaproxima Massachusetts

    Some minor dependency stuff, but otherwise this seems great. It will need test coverage; in SEO Tools' ComponentValidationTest, all we really need to do is create a new content type and then assert that it got the appropriate SEO fields attached.

  • Pipeline finished with Failed
    29 days ago
    Total: 945s
    #404837
  • Pipeline finished with Failed
    29 days ago
    Total: 884s
    #404890
  • Pipeline finished with Failed
    29 days ago
    Total: 1206s
    #404923
  • 🇮🇳India narendraR Jaipur, India

    This issue is NR for further feedback. Thanks

  • Pipeline finished with Success
    29 days ago
    Total: 807s
    #404945
  • Pipeline finished with Failed
    27 days ago
    Total: 465s
    #406974
  • Pipeline finished with Success
    27 days ago
    Total: 941s
    #407007
  • Pipeline finished with Success
    27 days ago
    Total: 948s
    #407058
  • 🇺🇸United States thejimbirch Cape Cod, Massachusetts

    Postponed on the forthcoming 2.1.3 release of ECA.

  • 🇺🇸United States tim.plunkett Philadelphia
  • 🇺🇸United States thejimbirch Cape Cod, Massachusetts
  • Pipeline finished with Failed
    18 days ago
    Total: 517s
    #414926
  • Pipeline finished with Success
    18 days ago
    #414938
  • 🇮🇳India narendraR Jaipur, India
  • 🇺🇸United States thejimbirch Cape Cod, Massachusetts

    We met with @alexpott, the lead maintainer of the Recipes initiative. The long term goal of of recipes is that they are unpacked and removed from Drupal in the application process. The fact that the recipes are remaining in Drupal CMS, and this issue to forever re-apply them may lead to the recipes getting updated and havoc unleashed when reapplied.

    Instead of re-applying the recipe, could there be an ECA action to apply config actions? So rather than re-applying a whole recipe, we only list the config entities and config actions we want to apply in the ECA.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    @thejimbirch we can certainly build an action plugin that applies a config action. That may probably even make sense outside of the context of this issue. For the purpose of reapplying certain config actions following some events, we would have to find a way to identify and extract those from recipes when they initially get applied and keep them somewhere so that we can refer to them when needed. Maybe we should either build ECA models manually for that? It would be much easier to implement, but it certainly requires more work and coordination by the recipe author to build and maintain that.

  • 🇺🇸United States thejimbirch Cape Cod, Massachusetts

    For the purpose of reapplying certain config actions following some events, we would have to find a way to identify and extract those from recipes when they initially get applied and keep them somewhere so that we can refer to them when needed.

    I don't think it is necessary for ECA to identify and extract what config actions it wants to re-apply. I think the recipe should leave behind the ECA with the config actions it wants to apply on events. We should put that on the recipe author to create and maintain since we won't want all actions in a recipe to be re-applied.

  • 🇺🇸United States phenaproxima Massachusetts

    So given upstream changes in core (soon to land in 11.1.3), I think the way to proceed here is not for ECA to try to be smart about detecting things.

    Instead, let's take advantage of the new extra section of recipe.yml. Recipes with this in them:

    extra:
      eca:
        auto_reapply: true
    

    Should cause ECA, when it intercepts the RecipeAppliedEvent, to extract only the config actions from the recipe -- all of the config actions, not a subset -- and smush them into a new model that runs every time that same recipe is reapplied.

    The ECA plugin should be pretty dumb -- it should simply take a serialized(?) array of config actions and run them mindlessly through the ConfigActionManager::apply() method.

    This will obviously require upstream changes in ECA but I think we're not far from being able to do this.

  • 🇺🇸United States phenaproxima Massachusetts

    I agree with #15 that we don't want ECA to try and be too smart here. For our immediate needs, it is totally fine if the recipe author has to build the ECA model manually.

    So really, all we need here is an ECA action plugin that can take an array of config actions and apply them (ConfigActionManager::applyAction()), pretty much as dumbly as possible.

    The thing Jim and I agreed on with @alexpott is that we don't want the ECA model to just reapply the recipe wholesale, since the underlying config (i.e., the imported stuff) could change and possibly break things. And we don't want to freeze the recipe in time, for the same reason. The config actions are the main event -- they are also idempotent by design. What they say to do, is what happens. That seems like the correct fit for ECA.

Production build 0.71.5 2024