Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning and info for queue factory. #194

Merged
merged 8 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion modules/quant_purger/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# 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.

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.

## 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';
```
8 changes: 7 additions & 1 deletion quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Drupal\Core\Access\AccessResult;
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;
Expand Down Expand Up @@ -435,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 <em>queue_service_quant_seed_worker</em> in your settings. See the <a href="https://docs.quantcdn.io/docs/integrations/drupal">Drupal docs</a> for setup information.'));
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/QuantQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function doCreateItem($data) {
return $query->execute();
}
catch (IntegrityConstraintViolationException $err) {
var_dump('skipping cause exists');
return FALSE;
}
}
Expand Down
Loading