Skip to content

[feature request] Add the option to skip on-demand revalidation under certain circumstances #507

Open
@jean-louis

Description

@jean-louis

Hi, sorry for my bad english.

There are cases where it would be nice to have the option to skip the on-demand revalidation of front end pages.

For example, it would be useful to have:

  • a global skip in case you have to do batch operations on the drupal side (massive content saving)
  • a selective skip for content type in case the content change is done via php cli (like recurring migrations launched with drush)

I'm currently using the following patch to skip revalidation if the php process is launched via cli, but probably add some configuration to decide these behaviors could be useful for others as well.

diff --git a/src/Plugin/Next/Revalidator/Path.php b/src/Plugin/Next/Revalidator/Path.php
index fce7e5c..16f73dc 100644
--- a/src/Plugin/Next/Revalidator/Path.php
+++ b/src/Plugin/Next/Revalidator/Path.php
@@ -72,6 +72,11 @@ class Path extends ConfigurableRevalidatorBase implements RevalidatorInterface {
       return FALSE;
     }
 
+    // If the current PHP process runs on CLI, skip revalidation.
+    if (PHP_SAPI === 'cli') {
+      return FALSE;
+    }
+
     $paths = [];
     if (!empty($this->configuration['revalidate_page'])) {
       $paths[] = $event->getEntityUrl();

next-skip_on_demand_revalidation_if_is_cli.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions