From ed6f420929792c29b218e5437d14e5656584dc3d Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 9 Jun 2022 20:28:38 +0300 Subject: [PATCH] fix(directives): fix issue with 2x caching of markdown, shortcodes and textile --- .../core/Entries/Directives/MarkdownDirective.php | 9 +++++++++ .../core/Entries/Directives/ShortcodesDirective.php | 9 +++++++++ .../core/Entries/Directives/TextileDirective.php | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/src/flextype/core/Entries/Directives/MarkdownDirective.php b/src/flextype/core/Entries/Directives/MarkdownDirective.php index af43ae96..93c55de9 100644 --- a/src/flextype/core/Entries/Directives/MarkdownDirective.php +++ b/src/flextype/core/Entries/Directives/MarkdownDirective.php @@ -23,6 +23,12 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { return; } + // Save markdown cache state to restore it later + $markdownCacheState = registry()->get('flextype.settings.parsers.markdown.cache'); + + // Set markdown cache to false + registry()->set('flextype.settings.parsers.markdown.cache', false); + $field = entries()->registry()->get('methods.fetch.field'); if (is_string($field['value'])) { @@ -35,4 +41,7 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { entries()->registry()->set('methods.fetch.field.key', $field['key']); entries()->registry()->set('methods.fetch.field.value', $field['value']); + + // Restore markdown cache state + registry()->set('flextype.settings.parsers.markdown.cache', $markdownCacheState); }); \ No newline at end of file diff --git a/src/flextype/core/Entries/Directives/ShortcodesDirective.php b/src/flextype/core/Entries/Directives/ShortcodesDirective.php index 25659f33..fcb56deb 100644 --- a/src/flextype/core/Entries/Directives/ShortcodesDirective.php +++ b/src/flextype/core/Entries/Directives/ShortcodesDirective.php @@ -23,6 +23,12 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { return; } + // Save shortcodes cache state to restore it later + $shortcodesCacheState = registry()->get('flextype.settings.parsers.shortcodes.cache'); + + // Set shortcodes cache to false + registry()->set('flextype.settings.parsers.shortcodes.cache', false); + $field = entries()->registry()->get('methods.fetch.field'); if (is_string($field['value'])) { @@ -35,4 +41,7 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { entries()->registry()->set('methods.fetch.field.key', $field['key']); entries()->registry()->set('methods.fetch.field.value', $field['value']); + + // Restore shortcodes cache state + registry()->set('flextype.settings.parsers.shortcodes.cache', $shortcodesCacheState); }); \ No newline at end of file diff --git a/src/flextype/core/Entries/Directives/TextileDirective.php b/src/flextype/core/Entries/Directives/TextileDirective.php index 59a19a8b..29d86e29 100644 --- a/src/flextype/core/Entries/Directives/TextileDirective.php +++ b/src/flextype/core/Entries/Directives/TextileDirective.php @@ -23,6 +23,12 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { return; } + // Save textile cache state to restore it later + $textileCacheState = registry()->get('flextype.settings.parsers.textile.cache'); + + // Set textile cache to false + registry()->set('flextype.settings.parsers.textile.cache', false); + $field = entries()->registry()->get('methods.fetch.field'); if (is_string($field['value'])) { @@ -35,4 +41,7 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { entries()->registry()->set('methods.fetch.field.key', $field['key']); entries()->registry()->set('methods.fetch.field.value', $field['value']); + + // Restore textile cache state + registry()->set('flextype.settings.parsers.textile.cache', $textileCacheState); }); \ No newline at end of file