From 8b77f79a0d8a348ff9bd8215eae30e928ade2d9f Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Fri, 3 Nov 2023 15:25:15 +1100 Subject: [PATCH 1/7] Updated quant_purger README with factory setting. --- modules/quant_purger/README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/quant_purger/README.md b/modules/quant_purger/README.md index 057c26c8..a58b781a 100644 --- a/modules/quant_purger/README.md +++ b/modules/quant_purger/README.md @@ -1,8 +1,34 @@ # Quant cache tag purger -Adds a cache tag plugin which listen to invalidation events to queue Quant repopulation. This allows node_saves to update the main page but also trigger updates for pages that might be affected by the content update (eg. views pages). These will be added to the queue for the next core cron run to publish the updates. +Adds a cache tag plugin which listens to Drupal invalidation events in order to +queue Quant updates for related content. + +For example, this allows node edits to trigger the main (`/node`) page to update +along with any other pages associated with the node through cache tags (e.g. +views pages, taxonomy term pages, etc). + +This also works with other entities. For example, if a term is associated with +several nodes, those nodes will be queued for updates when the term is edited. + +The associated content is added to the Quant queue and will be processed during +the next core cron run. You can run the cron manually or wait for the site's +cron to run on its regular schedule. For the latter, note that the static +content will be out-of-sync with the Drupal site until the cron runs, which may +cause confusion in some cases. Thus, it is recommended that cron is run right +after content is edited if there are key pages that show the updated content. + +See [Quant Purger documentation](https://docs.quantcdn.io/docs/integrations/drupal/purger) +for additional information. ## Requirements - quant - purge + +## Recommendations + +For the best performance, it is highly recommended that your settings include: + +``` +$settings['queue_service_quant_seed_worker'] = 'quant.queue_factory'; +``` From bae81d19678e7f156683637de3e90fc1d99ffd94 Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Fri, 3 Nov 2023 18:21:23 +1100 Subject: [PATCH 2/7] Added warning if queue factory is not set. --- quant.module | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/quant.module b/quant.module index 7beea3fc..5feecaab 100644 --- a/quant.module +++ b/quant.module @@ -6,15 +6,28 @@ */ use Drupal\Core\Access\AccessResult; -use Drupal\Core\Session\AccountInterface; -use Drupal\node\NodeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Site\Settings; use Drupal\Core\Url; +use Drupal\node\NodeInterface; use Drupal\quant\Exception\TokenValidationDisabledException; use Drupal\quant\Plugin\QueueItem\RouteItem; -use Drupal\quant\Seed; use Drupal\quant\QuantQueueFactory; +use Drupal\quant\Seed; + +/** + * Implements hook_preprocess_page(). + */ +function quant_preprocess_page(&$variables) { + + // Add warning on Quant admin pages if queue factory is not set. + $current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo(); + if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") { + \Drupal::messenger()->addWarning(t("For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.")); + } +} /** * Implements hook_menu_local_tasks_alter(). From c03cb4e41509181e1875eda8b6b19719bb2e46ed Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Fri, 3 Nov 2023 18:23:28 +1100 Subject: [PATCH 3/7] Fixed typo. --- quant.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quant.module b/quant.module index 5feecaab..c0b72044 100644 --- a/quant.module +++ b/quant.module @@ -25,7 +25,7 @@ function quant_preprocess_page(&$variables) { // Add warning on Quant admin pages if queue factory is not set. $current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo(); if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") { - \Drupal::messenger()->addWarning(t("For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.")); + \Drupal::messenger()->addWarning(t("For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.")); } } From ee60dba8122a31242c1b41c6c10644713f9d3fda Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Fri, 3 Nov 2023 18:28:32 +1100 Subject: [PATCH 4/7] Fix linting. --- quant.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quant.module b/quant.module index c0b72044..2291d9d9 100644 --- a/quant.module +++ b/quant.module @@ -25,7 +25,7 @@ function quant_preprocess_page(&$variables) { // Add warning on Quant admin pages if queue factory is not set. $current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo(); if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") { - \Drupal::messenger()->addWarning(t("For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.")); + \Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.')); } } From 4352d51883972e33f18b26eb3f846bae3796a76e Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Sat, 4 Nov 2023 22:22:21 +1100 Subject: [PATCH 5/7] Remove debugging message in queue. --- src/QuantQueue.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/QuantQueue.php b/src/QuantQueue.php index 06389f82..ecd8fe70 100644 --- a/src/QuantQueue.php +++ b/src/QuantQueue.php @@ -44,7 +44,6 @@ public function doCreateItem($data) { return $query->execute(); } catch (IntegrityConstraintViolationException $err) { - var_dump('skipping cause exists'); return FALSE; } } From df7dda699d68b7963fd45cdbd18a72072e448676 Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Sat, 6 Jan 2024 16:59:39 -0800 Subject: [PATCH 6/7] Updated Quant Purger README cron info. --- modules/quant_purger/README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/quant_purger/README.md b/modules/quant_purger/README.md index a58b781a..d57b0926 100644 --- a/modules/quant_purger/README.md +++ b/modules/quant_purger/README.md @@ -10,12 +10,9 @@ views pages, taxonomy term pages, etc). This also works with other entities. For example, if a term is associated with several nodes, those nodes will be queued for updates when the term is edited. -The associated content is added to the Quant queue and will be processed during -the next core cron run. You can run the cron manually or wait for the site's -cron to run on its regular schedule. For the latter, note that the static -content will be out-of-sync with the Drupal site until the cron runs, which may -cause confusion in some cases. Thus, it is recommended that cron is run right -after content is edited if there are key pages that show the updated content. +To ensure that queued content is processed in a timely manner, you can set up a +Quant cron process that is separate from the core cron which just processes the +Quant queue. This Quant cron can be run more regularly than the core cron. See [Quant Purger documentation](https://docs.quantcdn.io/docs/integrations/drupal/purger) for additional information. From 1c9a80d7cee88f6f504470f37c1772698cd6e29d Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Sat, 6 Jan 2024 17:07:16 -0800 Subject: [PATCH 7/7] Consolidated quant_preprocess_page logic. --- quant.module | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/quant.module b/quant.module index 4548245b..21521e93 100644 --- a/quant.module +++ b/quant.module @@ -18,18 +18,6 @@ use Drupal\quant\QuantQueueFactory; use Drupal\quant\Seed; use Drupal\quant\Utility; -/** - * Implements hook_preprocess_page(). - */ -function quant_preprocess_page(&$variables) { - - // Add warning on Quant admin pages if queue factory is not set. - $current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo(); - if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") { - \Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.')); - } -} - /** * Implements hook_menu_local_tasks_alter(). */ @@ -448,10 +436,15 @@ function quant_preprocess_page(&$variables) { // Show the Quant page info block for non-admin pages if enabled. $config = \Drupal::configFactory()->getEditable('quant.settings'); $enabled = $config->get('quant_show_page_info_block'); - if ($enabled && !\Drupal::service('router.admin_context')->isAdminRoute()) { $variables['page']['content']['#prefix'] = Utility::getPageInfo() . ($variables['page']['content']['#prefix'] ?? ''); } + + // Add warning on Quant admin pages if queue factory is not set. + $current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo(); + if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") { + \Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update queue_service_quant_seed_worker in your settings. See the Drupal docs for setup information.')); + } } /**