commit c6513f3eb373c11ea8e930a0bbc20debb55969be
parent 2e6501f866fb94064654a84e17d4c1ceb0744a59
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Tue, 14 Oct 2025 15:05:16 +0200
try to disable order caching, does not work :-(
Diffstat:
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/contrib/setup-drupal.sh b/contrib/setup-drupal.sh
@@ -69,9 +69,9 @@ ln -sf /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/drupal
rm -f /etc/nginx/sites-enabled/default
echo "===> Restarting services..."
-systemctl restart php8.2-fpm
+systemctl restart php8.3-fpm
systemctl restart nginx
-systemctl enable php8.2-fpm nginx postgresql
+systemctl enable php8.3-fpm nginx postgresql
echo "===> Done!"
echo "Visit http://localhost to finish installing Drupal 10."
diff --git a/contrib/setup-drush.sh b/contrib/setup-drush.sh
diff --git a/turnstile.module b/turnstile.module
@@ -81,6 +81,9 @@ function turnstile_entity_view_alter(array &$build, EntityInterface $entity, Ent
return;
}
+ // Disable page cache, this page is personalized!
+ \Drupal::service('page_cache_kill_switch')->trigger();
+
$node_id = $node->id();
if (_turnstile_has_session_access($node_id)) {
\Drupal::logger('turnstile')->debug('Session has access to this node.');
@@ -92,6 +95,7 @@ function turnstile_entity_view_alter(array &$build, EntityInterface $entity, Ent
$order_info = _turnstile_get_node_order_info ($node_id);
if ($order_info) {
+ \Drupal::logger('turnstile')->debug('Found existing order @ORDER for this session.', [ '@ORDER' => $order_info['order_id'] ]);
// We have an existing order, check if it was paid
$order_id = $order_info['order_id'];
$order_status = $api_service->checkOrderStatus($order_info['order_id']);
@@ -101,10 +105,18 @@ function turnstile_entity_view_alter(array &$build, EntityInterface $entity, Ent
return;
}
if ($order_status &&
- ($order_status['order_expiration'] ?? 0) < time()) {
+ ($order_status['order_expiration'] ?? 0) < time() + 30) {
// If order expired, ignore it!
$order_info = NULL;
}
+ if (!$order_status)
+ {
+ $order_info = NULL;
+ }
+ else
+ {
+ \Drupal::logger('turnstile')->debug('Order expires in @future seconds, not creating new one.', ['@future' => ($order_status['order_expiration'] ?? 0) - time ()] );
+ }
}
if (!$order_info) {
// Need to try to create a new order
@@ -163,17 +175,6 @@ function turnstile_entity_view_alter(array &$build, EntityInterface $entity, Ent
'#weight' => 10,
];
- // Ensure cache contexts are preserved
- $build['#cache']['contexts'] = array_merge(
- $build['#cache']['contexts'] ?? [],
- ['user', 'url.query_args:order_id']
- );
-
- // Add cache tags for the node
- $build['#cache']['tags'] = array_merge(
- $build['#cache']['tags'] ?? [],
- $entity->getCacheTags()
- );
}