From 2f8a172a896f5b6b57364386c636e27018ec4e3e Mon Sep 17 00:00:00 2001 From: Rakesh Kumar Regar <59994-rakesh.regar@users.noreply.drupalcode.org> Date: Tue, 10 Oct 2023 10:38:08 +0000 Subject: [PATCH] Issue #3392844: Changes not reflacting for anonymous user --- advance_script_manager.module | 7 ------- src/Form/ListScriptsFormDeleteMultiple.php | 1 + src/Form/ListscriptsForm.php | 1 + src/Form/ScriptsForm.php | 1 + src/Form/ScriptsFormDelete.php | 1 + src/Form/ScriptsOrderForm.php | 1 + 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/advance_script_manager.module b/advance_script_manager.module index 3949c82..916fe26 100644 --- a/advance_script_manager.module +++ b/advance_script_manager.module @@ -34,7 +34,6 @@ function advance_script_manager_help($route_name, RouteMatchInterface $route_mat */ function advance_script_manager_page_attachments_alter(array &$attachments) { $scripts = fetch_scripts('Header'); - $renderer = \Drupal::service('renderer'); foreach ($scripts as $key => $header_section) { // Get paths from DB. $paths = []; @@ -102,7 +101,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) { 'advance-script-manager-scripts-' . $i, ]; if (!empty($script_attr)) { - $renderer->addCacheableDependency($attachments, $value); $attachments['#attached']['html_head'][$i][0]['#attributes'] = $script_attr; } $i++; @@ -157,7 +155,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) { } } if ($add_to_header) { - $renderer->addCacheableDependency($attachments, $value); $attachments['#attached']['html_head'][$i][0] = [ '#type' => 'html_tag', '#tag' => $style_tag, @@ -183,8 +180,6 @@ function advance_script_manager_page_attachments_alter(array &$attachments) { function advance_script_manager_page_top(array &$page_top) { $scripts = fetch_scripts('Body'); $html = adv_get_content($scripts); - $renderer = \Drupal::service('renderer'); - $renderer->addCacheableDependency($page_top, $html); if ($html) { $page_top['adv_code'] = [ '#markup' => t($html), @@ -201,8 +196,6 @@ function advance_script_manager_page_top(array &$page_top) { function advance_script_manager_page_bottom(array &$page_bottom) { $scripts = fetch_scripts('Footer'); $html = adv_get_content($scripts); - $renderer = \Drupal::service('renderer'); - $renderer->addCacheableDependency($page_bottom, $html); if ($html) { $page_bottom['adv_code'] = [ '#markup' => t($html), diff --git a/src/Form/ListScriptsFormDeleteMultiple.php b/src/Form/ListScriptsFormDeleteMultiple.php index 7d79b9f..5239a89 100644 --- a/src/Form/ListScriptsFormDeleteMultiple.php +++ b/src/Form/ListScriptsFormDeleteMultiple.php @@ -94,6 +94,7 @@ class ListScriptsFormDeleteMultiple extends ConfirmFormBase { ->condition('id', $id, 'IN') ->execute(); if ($res) { + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); $this->messenger()->addMessage($this->t('Script has been deleted.')); $form_state->setRedirect('advance_script_manager.advance_script_controller_build'); } diff --git a/src/Form/ListscriptsForm.php b/src/Form/ListscriptsForm.php index fae9b02..5609dd7 100644 --- a/src/Form/ListscriptsForm.php +++ b/src/Form/ListscriptsForm.php @@ -245,6 +245,7 @@ class ListscriptsForm extends FormBase { # code... break; } + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); } diff --git a/src/Form/ScriptsForm.php b/src/Form/ScriptsForm.php index 4134f5c..67df2d4 100644 --- a/src/Form/ScriptsForm.php +++ b/src/Form/ScriptsForm.php @@ -234,6 +234,7 @@ class ScriptsForm extends ConfigFormBase { $this->messenger->addMessage($this->t('Script config saved.')); } } + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); $url = Url::fromRoute('advance_script_manager.advance_script_controller_build'); $form_state->setRedirectUrl($url); } diff --git a/src/Form/ScriptsFormDelete.php b/src/Form/ScriptsFormDelete.php index d550bd1..d8c144c 100644 --- a/src/Form/ScriptsFormDelete.php +++ b/src/Form/ScriptsFormDelete.php @@ -92,6 +92,7 @@ class ScriptsFormDelete extends ConfirmFormBase { ->condition('id', $id, '=') ->execute(); if ($res) { + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); $this->messenger()->addMessage($this->t('Script has been deleted.')); $form_state->setRedirect('advance_script_manager.advance_script_controller_build'); } diff --git a/src/Form/ScriptsOrderForm.php b/src/Form/ScriptsOrderForm.php index c6d37b2..9bfdbfd 100644 --- a/src/Form/ScriptsOrderForm.php +++ b/src/Form/ScriptsOrderForm.php @@ -153,6 +153,7 @@ class ScriptsOrderForm extends FormBase { ->condition('id', $id, '=') ->execute(); } + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); $this->messenger()->addMessage($this->t('Order saved')); } -- GitLab