From 108bbf5ae01e6b6131bfa8bd81b99d5c9e70aa98 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 01:00:07 +1000 Subject: [PATCH 01/12] Fix indenting in info.yml. --- .../views_advanced_cache_test.info.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.info.yml b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.info.yml index 568839e..400908a 100644 --- a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.info.yml +++ b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.info.yml @@ -1,12 +1,11 @@ name: Views Advanced Cache Tests type: module description: Test configuration for the views_advanced_cache module. -core_version_requirement: ^8.7.7 || ^9 || ^10 -hidden: true +package: Testing dependencies: -- drupal:node -- drupal:text -- drupal:field -- drupal:menu_ui -- drupal:views -- views_advanced_cache:views_advanced_cache + - drupal:node + - drupal:text + - drupal:field + - drupal:menu_ui + - drupal:views + - views_advanced_cache:views_advanced_cache -- GitLab From 08ccb20a8d41f085aa94911eddb8aaaa3a3723e7 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 02:06:44 +1000 Subject: [PATCH 02/12] Use standard license string. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2460565..73bc275 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "drupal/views_advanced_cache", "type": "drupal-module", "description": "Take more control of views caching with the ability to specify cache tags and contexts.", - "license": "GPL-2.0+", "extra": { "branch-alias": { "dev-8.x-1.x": "1.x-dev" } + "license": "GPL-2.0-or-later", } } -- GitLab From 4d0782b7f02bd208ee06d36bbc29a36cb1011f8f Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 02:07:33 +1000 Subject: [PATCH 03/12] Add links and author to composer. --- composer.json | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 73bc275..0363b5e 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,17 @@ "name": "drupal/views_advanced_cache", "type": "drupal-module", "description": "Take more control of views caching with the ability to specify cache tags and contexts.", - "extra": { - "branch-alias": { - "dev-8.x-1.x": "1.x-dev" - } "license": "GPL-2.0-or-later", - } + "homepage": "http://drupal.org/project/views_advanced_cache", + "support": { + "issues": "http://drupal.org/project/issues/views_advanced_cache", + "source": "https://git.drupalcode.org/project/views_advanced_cache" + }, + "authors": [ + { + "name": "Malcolm Poindexter", + "homepage": "https://www.drupal.org/u/malcolm_p", + "role": "contributor" + } + ] } -- GitLab From dfad2c1c64a6d62ea6369929dacf44337a01878c Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 02:15:52 +1000 Subject: [PATCH 04/12] Inject token instead of \Drupal::token call. --- src/Plugin/views/cache/AdvancedViewsCache.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Plugin/views/cache/AdvancedViewsCache.php b/src/Plugin/views/cache/AdvancedViewsCache.php index 9c3f696..311ef93 100644 --- a/src/Plugin/views/cache/AdvancedViewsCache.php +++ b/src/Plugin/views/cache/AdvancedViewsCache.php @@ -8,6 +8,7 @@ use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\Core\Utility\Token; use Drupal\Core\Link; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\views\Views; @@ -51,6 +52,13 @@ class AdvancedViewsCache extends CachePluginBase { */ protected $time; + /** + * Token service. + * + * @var \Drupal\Core\Utility\Token + */ + protected $token; + protected $lifespans = [60, 300, 900, 1800, 3600, 21600, 43200, 86400, 604800]; public $lifespanOptions = []; @@ -58,9 +66,16 @@ class AdvancedViewsCache extends CachePluginBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, DateFormatterInterface $date_formatter, TimeInterface $datetime_time) { + public function __construct( + array $configuration, + $plugin_id, $plugin_definition, + DateFormatterInterface $date_formatter, + TimeInterface $datetime_time, + Token $token, + ) { $this->dateFormatter = $date_formatter; $this->time = $datetime_time; + $this->token = $token; parent::__construct($configuration, $plugin_id, $plugin_definition); @@ -77,7 +92,8 @@ class AdvancedViewsCache extends CachePluginBase { $plugin_id, $plugin_definition, $container->get('date.formatter'), - $container->get('datetime.time') + $container->get('datetime.time'), + $container->get('token') ); } @@ -387,7 +403,7 @@ class AdvancedViewsCache extends CachePluginBase { $default_cache_tags = parent::getCacheTags(); $cache_tags = array_map(function ($tag) { $value = $this->view->getStyle()->tokenizeValue($tag, 0); - return \Drupal::token()->replace($value); + return $this->token->replace($value); }, $cache_tags); $cache_tags = Cache::mergeTags($cache_tags, $default_cache_tags); } -- GitLab From 4dfab030be02eb6acbb43dc769d72909c1dc9b17 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 02:16:36 +1000 Subject: [PATCH 05/12] CS cleanup. --- src/Plugin/views/cache/AdvancedViewsCache.php | 52 +++++++++++++++---- .../views_advanced_cache_test.module | 1 + tests/src/Functional/PageCacheTest.php | 47 ++++++++++++----- .../src/Functional/ViewsCacheMetadataTest.php | 19 ++++--- 4 files changed, 91 insertions(+), 28 deletions(-) diff --git a/src/Plugin/views/cache/AdvancedViewsCache.php b/src/Plugin/views/cache/AdvancedViewsCache.php index 311ef93..b9dfeb0 100644 --- a/src/Plugin/views/cache/AdvancedViewsCache.php +++ b/src/Plugin/views/cache/AdvancedViewsCache.php @@ -59,8 +59,28 @@ class AdvancedViewsCache extends CachePluginBase { */ protected $token; - protected $lifespans = [60, 300, 900, 1800, 3600, 21600, 43200, 86400, 604800]; + /** + * Seconds used to build select field options for cache lifetime. + * + * @var array + */ + protected $lifespans = [ + 60, + 300, + 900, + 1800, + 3600, + 21600, + 43200, + 86400, + 604800, + ]; + /** + * Select field options array built from lifespans. + * + * @var array + */ public $lifespanOptions = []; /** @@ -68,7 +88,8 @@ class AdvancedViewsCache extends CachePluginBase { */ public function __construct( array $configuration, - $plugin_id, $plugin_definition, + $plugin_id, + $plugin_definition, DateFormatterInterface $date_formatter, TimeInterface $datetime_time, Token $token, @@ -101,21 +122,21 @@ class AdvancedViewsCache extends CachePluginBase { * {@inheritdoc} */ public function summaryTitle() { - // Display a summary of: cache tags, + // Display a summary of: cache tags. $num_cache_tags = count(array_merge($this->options['cache_tags'], $this->options['cache_tags_exclude']) ?: []); $cache_tags = ''; if ($num_cache_tags > 0) { $cache_tags = "$num_cache_tags tags"; } - // cache contexts, + // Cache contexts. $num_cache_contexts = count(array_merge($this->options['cache_contexts'], $this->options['cache_contexts_exclude']) ?: []); $cache_contexts = ''; if ($num_cache_contexts > 0) { $cache_contexts = "$num_cache_contexts contexts"; } - // and max-age. + // And max-age. $results_lifespan = $this->getLifespan('results'); $output_lifespan = $this->getLifespan('output'); $lifetime = ''; @@ -170,7 +191,12 @@ class AdvancedViewsCache extends CachePluginBase { */ public function buildCacheTagOptions(array &$form, FormStateInterface $form_state) { $cache_tags_docs = Link::fromTextAndUrl('documentation', Url::fromUri('https://www.drupal.org/docs/8/api/cache-api/cache-tags'))->toString(); - $cache_tags_exclude = array_map(function ($c) { return "- $c"; }, $this->options['cache_tags_exclude']); + $cache_tags_exclude = array_map( + function ($c) { + return "- $c"; + }, + $this->options['cache_tags_exclude'] + ); // Filter out some of the default cache tags we don't care about. // This should mostly be the entity_type list cache tags ex. node_list. $default_cache_tags = array_diff(parent::getCacheTags(), ['extensions', 'config:views.view.' . $this->view->id()]); @@ -247,11 +273,19 @@ class AdvancedViewsCache extends CachePluginBase { '#open' => TRUE, ]; - $cache_contexts_exclude = array_map(function ($c) { return "- $c"; }, $this->options['cache_contexts_exclude']); + $cache_contexts_exclude = array_map( + function ($c) { + return "- $c"; + }, + $this->options['cache_contexts_exclude'] + ); $form['cache_contexts']['cache_contexts'] = [ '#type' => 'textarea', '#title' => $this->t('Cache Contexts'), - '#default_value' => implode("\n", array_merge($this->options['cache_contexts'], $cache_contexts_exclude)) , + '#default_value' => implode("\n", array_merge( + $this->options['cache_contexts'], + $cache_contexts_exclude + )), '#description' => $this->t('List cache contexts (separated by new lines).'), ]; } @@ -318,7 +352,7 @@ class AdvancedViewsCache extends CachePluginBase { public function validateOptionsForm(&$form, FormStateInterface $form_state) { $lifespan = []; $cache_lifespan = $form_state->getValue(['cache_options', 'cache_lifespan']); - // Validate lifespan format + // Validate lifespan format. foreach (['output_lifespan', 'results_lifespan'] as $field) { $custom = $cache_lifespan[$field] == 'custom'; if ($custom && !is_numeric($cache_lifespan[$field . '_custom'])) { diff --git a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module index 3d383ef..3c496ec 100644 --- a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module +++ b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module @@ -4,6 +4,7 @@ * @file * A test module for views_advanced_cache. */ + use Drupal\node\NodeInterface; use Drupal\Core\Cache\Cache; diff --git a/tests/src/Functional/PageCacheTest.php b/tests/src/Functional/PageCacheTest.php index 00432bf..336cc02 100644 --- a/tests/src/Functional/PageCacheTest.php +++ b/tests/src/Functional/PageCacheTest.php @@ -8,7 +8,7 @@ use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\views\Entity\View; /** - * Class PageCacheTest. + * Test advanced cache tags are applied and removed from view as configured. * * @group views_advanced_cache */ @@ -16,27 +16,39 @@ class PageCacheTest extends BrowserTestBase { use AssertPageCacheContextsAndTagsTrait; - protected static $modules = ['views', 'views_advanced_cache_test']; + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'views', + 'views_advanced_cache_test', + ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; + /** + * {@inheritdoc} + */ protected $strictConfigSchema = FALSE; /** * Test page response cache tags for a view. */ public function testPageCache() { - // Create some test content, + // Create some test content. $nodes = []; - for ($i = 1; $i <= 3; $i++) { - $nodes[] = $this->drupalCreateNode(['title' => "Test $i", 'type' => 'test']); - } $node_cache_tags = []; - foreach ($nodes as $node) { - $node_cache_tags[] = 'node:' . $node->id(); + for ($i = 1; $i <= 3; $i++) { + $test_node = $this->drupalCreateNode([ + 'title' => "Test $i", + 'type' => 'test', + ]); + $node_cache_tags[] = 'node:' . $test_node->id(); + + $nodes[] = $test_node; } // And load the page view with our test cache contexts and tags. @@ -56,13 +68,18 @@ class PageCacheTest extends BrowserTestBase { ]; $url = Url::fromRoute('view.views_advanced_cache_test.page_test', []); - $this->assertPageCacheContextsAndTags($url, $cache_contexts, array_merge($cache_tags, $node_cache_tags)); + $this->assertPageCacheContextsAndTags( + $url, + $cache_contexts, + array_merge($cache_tags, $node_cache_tags) + ); - // Then remove our changes to the contexts and tags, + // Then remove our changes to the contexts and tags. $display_name = 'page_test'; - /** @var Drupal\views\Entity\Vie $view */ + /** @var Drupal\views\Entity\View $view */ $view = View::load('views_advanced_cache_test'); - $cache_options = $view->getDisplay($display_name)['display_options']['cache']['options'] ?? []; + $cache_options = $view + ->getDisplay($display_name)['display_options']['cache']['options'] ?? []; $cache_options['cache_tags'] = []; $cache_options['cache_tags_exclude'] = []; $cache_options['cache_contexts'] = []; @@ -89,7 +106,11 @@ class PageCacheTest extends BrowserTestBase { ]; $url = Url::fromRoute('view.views_advanced_cache_test.page_test', []); - $this->assertPageCacheContextsAndTags($url, $cache_contexts, array_merge($cache_tags, $node_cache_tags)); + $this->assertPageCacheContextsAndTags( + $url, + $cache_contexts, + array_merge($cache_tags, $node_cache_tags) + ); } } diff --git a/tests/src/Functional/ViewsCacheMetadataTest.php b/tests/src/Functional/ViewsCacheMetadataTest.php index 3be6e78..fa1ac94 100644 --- a/tests/src/Functional/ViewsCacheMetadataTest.php +++ b/tests/src/Functional/ViewsCacheMetadataTest.php @@ -9,22 +9,30 @@ use Drupal\views\ViewExecutable; use Drupal\views\Entity\View; /** - * Class ViewsCacheMetadataTest. + * Test manipulating the different caching options for a view using VAC. * * @group views_advanced_cache */ class ViewsCacheMetadataTest extends BrowserTestBase { - protected static $modules = ['views', 'views_advanced_cache_test']; + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'views', + 'views_advanced_cache_test', + ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; + /** + * {@inheritdoc} + */ protected $strictConfigSchema = FALSE; - // # Tests. /** * Test changing the view cache metadata. */ @@ -32,13 +40,13 @@ class ViewsCacheMetadataTest extends BrowserTestBase { $view_name = 'views_advanced_cache_test'; $display_name = 'block_test'; - // Render the view with the default cache tags, + // Render the view with the default cache tags. $view = Views::getView($view_name); $element = $this->render($view, $display_name); // And verify that the default node entity_type list cache tag is present. $this->assertTrue(in_array('node_list', $element['#cache']['tags']), 'The view has the node_list cache tag.'); - // Load the view config entity, + // Load the view config entity. $cacheOptions = $this->getCacheOptions($view->storage, $display_name); // And update its cache tags. $cacheOptions = NestedArray::mergeDeep($cacheOptions, [ @@ -108,7 +116,6 @@ class ViewsCacheMetadataTest extends BrowserTestBase { $this->assertTrue(in_array("node_test:$nid", $element['#cache']['tags']), 'The view has the node_test{nid} cache tag.'); } - // # Helpers. /** * Build a renderable array for the view display. */ -- GitLab From ffe6c0cf0f50ae135c75f98d960e234ecf40bdb4 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Thu, 17 Apr 2025 09:52:36 +1000 Subject: [PATCH 06/12] Spelling corrections. --- README.md | 2 +- src/Plugin/views/cache/AdvancedViewsCache.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bda891d..47f7f67 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ url.query_args:my_custom_filter ``` This can be used to override the default pager caching per all page query arguments instead only considering those -relevent to the view. +relevant to the view. Related Modules =============== diff --git a/src/Plugin/views/cache/AdvancedViewsCache.php b/src/Plugin/views/cache/AdvancedViewsCache.php index b9dfeb0..65e68e4 100644 --- a/src/Plugin/views/cache/AdvancedViewsCache.php +++ b/src/Plugin/views/cache/AdvancedViewsCache.php @@ -183,7 +183,7 @@ class AdvancedViewsCache extends CachePluginBase { * * By prefixing the tag with a "-" it will * be removed from the cache metadata. Removing cache tags should be - * used sparingly but may be useful to resolve issues uneccessary cache tags + * used sparingly but may be useful to resolve issues unnecessary cache tags * added by other modules * (ex. https://www.drupal.org/project/drupal/issues/2352175). * -- GitLab From a509fa4d23e8b7d422db6f342f3b369bac867a9f Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Thu, 17 Apr 2025 09:54:27 +1000 Subject: [PATCH 07/12] Add cspell dictionary for exceptions. --- .cspell-project-words.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .cspell-project-words.txt diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt new file mode 100644 index 0000000..8874eb7 --- /dev/null +++ b/.cspell-project-words.txt @@ -0,0 +1,4 @@ +# Views Advanced Cache dictionary + +# Initialism used in testing. +vact -- GitLab From d7276c3f7f8c5ff4b1a2967cb50604ee07c3f315 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Thu, 17 Apr 2025 10:05:29 +1000 Subject: [PATCH 08/12] Spelling exception for Poindexter. --- .cspell-project-words.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt index 8874eb7..6907d42 100644 --- a/.cspell-project-words.txt +++ b/.cspell-project-words.txt @@ -2,3 +2,6 @@ # Initialism used in testing. vact + +# Author names. +poindexter -- GitLab From fb6de9d74f9fcde7a1e41d4aaa5f4be0bb2461b9 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 01:24:24 +1000 Subject: [PATCH 09/12] Enforce uses sorting coding standard. --- phpcs.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..f09956e --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ruleset name="drupal-views-advanced-cache"> + <description>PHP CodeSniffer configuration for Views Advanced Cache project.</description> + <rule ref="Drupal"/> + <rule ref="DrupalPractice"/> + <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"> + <properties> + <property name="caseSensitive" value="true"/> + </properties> + </rule> + <arg name="extensions" value="php,inc,module,install,info,test,profile,theme"/> +</ruleset> -- GitLab From 560065e994d4cc08eb12af9c54d3d159549e6569 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 09:52:36 +1000 Subject: [PATCH 10/12] Fix uses ordering. --- src/Plugin/views/cache/AdvancedViewsCache.php | 6 +++--- .../views_advanced_cache_test.module | 2 +- tests/src/Functional/PageCacheTest.php | 2 +- tests/src/Functional/ViewsCacheMetadataTest.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Plugin/views/cache/AdvancedViewsCache.php b/src/Plugin/views/cache/AdvancedViewsCache.php index 65e68e4..9a61ad6 100644 --- a/src/Plugin/views/cache/AdvancedViewsCache.php +++ b/src/Plugin/views/cache/AdvancedViewsCache.php @@ -4,16 +4,16 @@ namespace Drupal\views_advanced_cache\Plugin\views\cache; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\Core\Utility\Token; -use Drupal\Core\Link; -use Drupal\Core\Cache\CacheableDependencyInterface; -use Drupal\views\Views; use Drupal\views\Plugin\views\cache\CachePluginBase; use Drupal\views\ResultRow; +use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module index 3c496ec..0e9b5ee 100644 --- a/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module +++ b/tests/modules/views_advanced_cache_test/views_advanced_cache_test.module @@ -5,8 +5,8 @@ * A test module for views_advanced_cache. */ -use Drupal\node\NodeInterface; use Drupal\Core\Cache\Cache; +use Drupal\node\NodeInterface; /** * Invalidate a custom node list cache tag on node save. diff --git a/tests/src/Functional/PageCacheTest.php b/tests/src/Functional/PageCacheTest.php index 336cc02..fe71b1f 100644 --- a/tests/src/Functional/PageCacheTest.php +++ b/tests/src/Functional/PageCacheTest.php @@ -2,8 +2,8 @@ namespace Drupal\Tests\views_advanced_cache\Functional; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\Url; +use Drupal\Tests\BrowserTestBase; use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\views\Entity\View; diff --git a/tests/src/Functional/ViewsCacheMetadataTest.php b/tests/src/Functional/ViewsCacheMetadataTest.php index fa1ac94..9332b80 100644 --- a/tests/src/Functional/ViewsCacheMetadataTest.php +++ b/tests/src/Functional/ViewsCacheMetadataTest.php @@ -2,11 +2,11 @@ namespace Drupal\Tests\views_advanced_cache\Functional; -use Drupal\Tests\BrowserTestBase; use Drupal\Component\Utility\NestedArray; -use Drupal\views\Views; -use Drupal\views\ViewExecutable; +use Drupal\Tests\BrowserTestBase; use Drupal\views\Entity\View; +use Drupal\views\ViewExecutable; +use Drupal\views\Views; /** * Test manipulating the different caching options for a view using VAC. -- GitLab From da165d7b28c1256437212a1eee996aa0e16b20ba Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 09:51:50 +1000 Subject: [PATCH 11/12] Use $this->t() instead of global t() in class. --- src/Plugin/views/cache/AdvancedViewsCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/views/cache/AdvancedViewsCache.php b/src/Plugin/views/cache/AdvancedViewsCache.php index 9a61ad6..ebefbc6 100644 --- a/src/Plugin/views/cache/AdvancedViewsCache.php +++ b/src/Plugin/views/cache/AdvancedViewsCache.php @@ -219,7 +219,7 @@ class AdvancedViewsCache extends CachePluginBase { '#default_value' => implode("\n", array_merge($cache_tags, $cache_tags_exclude)), ]; - $optgroup_arguments = (string) t('Arguments'); + $optgroup_arguments = (string) $this->t('Arguments'); $options = []; // $globalTokens = $this->getAvailableGlobalTokens(FALSE, ['current-user']); -- GitLab From 7d45e76475d29bc3bf567f9d6d8e9daebdac6f86 Mon Sep 17 00:00:00 2001 From: Ted Cooper <elc@784944.no-reply.drupal.org> Date: Sat, 26 Apr 2025 10:00:02 +1000 Subject: [PATCH 12/12] Disable strict config schema for now. --- tests/src/Functional/PageCacheTest.php | 7 ++++++- tests/src/Functional/ViewsCacheMetadataTest.php | 7 ++++++- tests/src/Kernel/ViewsRowCacheTest.php | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/src/Functional/PageCacheTest.php b/tests/src/Functional/PageCacheTest.php index fe71b1f..5543a0d 100644 --- a/tests/src/Functional/PageCacheTest.php +++ b/tests/src/Functional/PageCacheTest.php @@ -30,9 +30,14 @@ class PageCacheTest extends BrowserTestBase { protected $defaultTheme = 'stark'; /** - * {@inheritdoc} + * Disable config schema checking temporarily until schema added. + * + * @var bool + * + * @phpcs:disable DrupalPractice.Objects.StrictSchemaDisabled.StrictConfigSchema */ protected $strictConfigSchema = FALSE; + // phpcs:enable /** * Test page response cache tags for a view. diff --git a/tests/src/Functional/ViewsCacheMetadataTest.php b/tests/src/Functional/ViewsCacheMetadataTest.php index 9332b80..13403a7 100644 --- a/tests/src/Functional/ViewsCacheMetadataTest.php +++ b/tests/src/Functional/ViewsCacheMetadataTest.php @@ -29,9 +29,14 @@ class ViewsCacheMetadataTest extends BrowserTestBase { protected $defaultTheme = 'stark'; /** - * {@inheritdoc} + * Disable config schema checking temporarily until schema added. + * + * @var bool + * + * @phpcs:disable DrupalPractice.Objects.StrictSchemaDisabled.StrictConfigSchema */ protected $strictConfigSchema = FALSE; + // phpcs:enable /** * Test changing the view cache metadata. diff --git a/tests/src/Kernel/ViewsRowCacheTest.php b/tests/src/Kernel/ViewsRowCacheTest.php index bb9cc66..3951413 100644 --- a/tests/src/Kernel/ViewsRowCacheTest.php +++ b/tests/src/Kernel/ViewsRowCacheTest.php @@ -27,13 +27,14 @@ class ViewsRowCacheTest extends ViewsKernelTestBase { use UserCreationTrait; /** - * Turn off strict config schema check. + * Disable config schema checking temporarily until schema added. * * @var bool * - * @todo Add config schema to this module and set this back to TRUE. + * @phpcs:disable DrupalPractice.Objects.StrictSchemaDisabled.StrictConfigSchema */ protected $strictConfigSchema = FALSE; + // phpcs:enable /** * {@inheritdoc} -- GitLab