Giter Club home page Giter Club logo

craft-nocache's People

Contributors

benjamminf avatar ttempleton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

craft-nocache's Issues

nocache breaks after Craft 3.1.29 upgrade

Description

After upgrading to Craft 3.1.29, I get an error message. Looks like it might be an issue with Twig?

Steps to reproduce

  1. Upgrade Craft
  2. Load page with nocache in template
  3. Get error

Additional information

  • No-Cache version: 2.0.3
  • Craft CMS version: 3.1.29
  • PHP version: 7.2.19

Here's my stack trace:

yii\base\ErrorException: Undefined property: __NoCacheTemplate_wV8vkIHXCbNb7qLynbvwRgxV::$macros in /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/nocache/nocache_wV8vkIHXCbNb7qLynbvwRgxV.php:32
Stack trace:
#0 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(8, 'Undefined prope...', '/Users/trav/Web...', 32)
#1 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/nocache/nocache_wV8vkIHXCbNb7qLynbvwRgxV.php(32): craft\web\ErrorHandler->handleError(8, 'Undefined prope...', '/Users/trav/Web...', 32, Array)
#2 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __NoCacheTemplate_wV8vkIHXCbNb7qLynbvwRgxV->doDisplay(Array, Array)
#3 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#4 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#5 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#6 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(380): craft\web\twig\Template->display(Array)
#7 /Users/trav/Websites/louderthanten/vendor/ttempleton/craft-nocache/src/Service.php(125): Twig\Template->render(Array)
#8 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/56/560f6ac0d16afa691ecdacb7bafd36a4e23b8a8a07646d4ca8855efdb7a81ba0.php(90): ttempleton\nocache\Service->render('wV8vkIHXCbNb7qL...', Array)
#9 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __TwigTemplate_80ce25d036746c5a80f6401c4f8735cd12058c891c02d669c400142ece8bf670->doDisplay(Array, Array)
#10 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#11 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#12 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#13 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/92/92d653e32be8eb6b3ed31d399e71d47f0ece64471626f756fe99ee1ff496d1a5.php(53): craft\web\twig\Template->display(Array)
#14 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __TwigTemplate_5b9f84f560fb5f0542739f5bfee351b2cf5bd5b7a8ccbdadefae5aa15e374e62->doDisplay(Array, Array)
#15 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#16 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#17 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#18 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/ff/ffcba3b586bb42e969a8e1b04f69a88ffafd42c2c35b7c45d74d472c1ecd1ae1.php(78): craft\web\twig\Template->display(Array)
#19 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(184): __TwigTemplate_b9e3fbcfbb122ca9bf67081a9d023b6de676f892a77adbab0dc237ae71032856->block_content(Array, Array)
#20 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/7a/7a14dbf2b7f4193a070b9d4b8617b1d154b3ff47a4c9d82ae70d5083999ceb95.php(290): Twig\Template->displayBlock('content', Array, Array)
#21 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __TwigTemplate_c0c92959ea4a89bede0eb72f898a172d1b8a35402145337e09ca3998f13a5fdd->doDisplay(Array, Array)
#22 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#23 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#24 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#25 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/ff/ffcba3b586bb42e969a8e1b04f69a88ffafd42c2c35b7c45d74d472c1ecd1ae1.php(43): craft\web\twig\Template->display(Array, Array)
#26 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __TwigTemplate_b9e3fbcfbb122ca9bf67081a9d023b6de676f892a77adbab0dc237ae71032856->doDisplay(Array, Array)
#27 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#28 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#29 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#30 /Users/trav/Websites/louderthanten/storage/runtime/compiled_templates/4a/4a8efde7b19e4467ac443070da971fdd513ce5499ee15b9cd302851e58150797.php(42): craft\web\twig\Template->display(Array)
#31 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(395): __TwigTemplate_949213e301cec562e111d67922ec5fe90b30a8b71f8f1e9b22048afa7b39296a->doDisplay(Array, Array)
#32 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(52): Twig\Template->displayWithErrorHandling(Array, Array)
#33 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(372): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#34 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/twig/Template.php(34): Twig\Template->display(Array, Array)
#35 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Template.php(380): craft\web\twig\Template->display(Array)
#36 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#37 /Users/trav/Websites/louderthanten/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#38 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/View.php(343): Twig\Environment->render('index', Array)
#39 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/View.php(393): craft\web\View->renderTemplate('index', Array)
#40 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Controller.php(161): craft\web\View->renderPageTemplate('index', Array)
#41 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('index', Array)
#42 [internal function]: craft\controllers\TemplatesController->actionRender('index', Array)
#43 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#44 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#45 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('render', Array)
#46 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#47 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('templates/rende...', Array)
#48 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#49 /Users/trav/Websites/louderthanten/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#50 /Users/trav/Websites/louderthanten/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#51 /Users/trav/Websites/louderthanten/public/index.php(21): yii\base\Application->run()
#52 /Users/trav/.composer/vendor/laravel/valet/server.php(158): require('/Users/trav/Web...')
#53 {main}

<no-cache> cached

Description

With HTML Cache enabled, even with none of it's option enabled,

{% nocache %}{{ getCsrfInput() }}{% endnocache %}

renders correctly the first time, but as:

3HkJuIQdEFS4Rvv50KnpVs3s-fIhF5j7S

on all subsequent page loads. With HTML Cache disabled the form works fine.

Additional information

No-Cache version: Latest craft-2 commit.
Craft CMS version: 2.8.0.1
PHP version: 7.2.24
Also using HTML Cache 1.0.4.1

Minor (new) bug in Craft 2 version

I know you're probably barely supporting the Craft 2 version, but just wanted to let you know that a brand new bug has been introduced by a recent version of Craft 2.

Fatal error: Uncaught TypeError: Argument 1 passed to __NoCacheTemplate_okg3IDPFLZ6ciU7ZHH8N0N6H::__construct() must be an instance of Environment, instance of Craft\TwigEnvironment given, called in /.../craft/plugins/nocache/services/NoCacheService.php on line 98 and defined in /.../craft/storage/runtime/compiled_templates/nocache/nocache_okg3IDPFLZ6ciU7ZHH8N0N6H.php:6

Stack trace:
#0 /.../craft/plugins/nocache/services/NoCacheService.php(98): __NoCacheTemplate_okg3IDPFLZ6ciU7ZHH8N0N6H->__construct(Object(Craft\TwigEnvironment))
#1 /.../craft/plugins/nocache/NoCachePlugin.php(116): Craft\NoCacheService->render('okg3IDPFLZ6ciU7...', 'xwy4NJxt')
#2 [internal function]: Craft\NoCachePlugin->Craft\{closure}(Array)
#3 /.../craft/plugins/nocache/NoCachePlugin.php(123): preg_replace_callback('/<no-cache>([a-...', Object(Closure), '<!doctype html>...')
#4 [ in /.../craft/storage/runtime/compiled_templates/nocache/nocache_okg3IDPFLZ6ciU7ZHH8N0N6H.php on line 6

I'll try to hack the plugin in the meantime.

Additional information

  • No-Cache version: 1.0.3
  • Craft CMS version: 2.7.10

Pass macros into nocache

How would I have to write the nocache tag when using a Macro?

{% nocache %}
  {% for asset in header.headerBild.order('RAND()').limit('1') %}
    {{ docMacro.headerImage(asset) }}
  {% endfor %}
{% endnocache %}

I just imported the macro file again:
But is there another sollution like { with: docMacros } or something?

{% nocache %}
  {% import '_incl/docMacros' as docMacro %}
  {% for asset in header.headerBild.order('RAND()').limit('1') %}
    {{ docMacro.headerImage(asset) }}
  {% endfor %}
{% endnocache %}

Error: mkdir(): Permission denied

I have my storage folder above the craft folder like this:

  • config
  • craft
  • public
  • plugins
  • storage
  • templates

After installing the plugin and enabling it in the template files the plugin gives me this error: mkdir(): Permission denied.

I tried creating a nocache folder inside de runtime folder with the right permissions. But still same error.

PHP warning

mkdir(): Permission denied

/Volumes/HDD/Sites/myredlight/craft/app/helpers/IOHelper.php(734)

722     {
723         if ($permissions == null)
724         {
725             $permissions = craft()->config->get('defaultFolderPermissions');
726         }
727 
728         $path = static::normalizePathSeparators($path);
729 
730         if (!static::folderExists($path, false, $suppressErrors))
731         {
732             $oldumask = $suppressErrors ? @umask(0) : umask(0);
733 
734             if ($suppressErrors ? !@mkdir($path, $permissions, true) : !mkdir($path, $permissions, true))
735             {
736                 Craft::log('Tried to create a folder at '.$path.', but could not.', LogLevel::Error);
737                 return false;
738             }
739 
740             // Because setting permission with mkdir is a crapshoot.
741             $suppressErrors ? @chmod($path, $permissions) : chmod($path, $permissions);
742             $suppressErrors ? @umask($oldumask) : umask($oldumask);
743             return new Folder($path);
744         }
745 
746         Craft::log('Tried to create a folder at '.$path.', but the folder already exists.', LogLevel::Error);

Stack Trace
#0  
–  /Volumes/HDD/Sites/myredlight/craft/app/etc/web/WebApp.php(688): CApplication->handleError(2, "mkdir(): Permission denied", "/Volumes/HDD/Sites/myredlight/craft/app/helpers/IOHelper.php", 734)
683         if (version_compare(PHP_VERSION, '7', '>=') && $code === 2 && strpos($message, 'should be compatible with') !== false)
684         {
685             return;
686         }
687 
688         parent::handleError($code, $message, $file, $line);
689     }
690 
691     // Private Methods
692     // =========================================================================
693 
#1  
 unknown(0): Craft\WebApp->handleError(2, "mkdir(): Permission denied", "/Volumes/HDD/Sites/myredlight/craft/app/helpers/IOHelper.php", 734, ...)
#2  
–  /Volumes/HDD/Sites/myredlight/craft/app/helpers/IOHelper.php(734): mkdir("../../storage/runtime/", 509, true)
729 
730         if (!static::folderExists($path, false, $suppressErrors))
731         {
732             $oldumask = $suppressErrors ? @umask(0) : umask(0);
733 
734             if ($suppressErrors ? !@mkdir($path, $permissions, true) : !mkdir($path, $permissions, true))
735             {
736                 Craft::log('Tried to create a folder at '.$path.', but could not.', LogLevel::Error);
737                 return false;
738             }
739 
#3  
–  /Volumes/HDD/Sites/myredlight/craft/app/helpers/IOHelper.php(1502): Craft\IOHelper::createFolder("../../storage/runtime/", 509, false)
1497      */
1498     public static function ensureFolderExists($folderPath, $suppressErrors = false)
1499     {
1500         if (!IOHelper::folderExists($folderPath, false, $suppressErrors))
1501         {
1502             IOHelper::createFolder($folderPath, craft()->config->get('defaultFolderPermissions'), $suppressErrors);
1503         }
1504     }
1505 
1506     /**
1507      * Cleans a filename.
#4  
–  /Volumes/HDD/Sites/myredlight/craft/app/services/PathService.php(81): Craft\IOHelper::ensureFolderExists("../../storage/runtime/")
76      * @return string The path to the craft/storage/runtime/ folder.
77      */
78     public function getRuntimePath()
79     {
80         $path = $this->getStoragePath().'runtime/';
81         IOHelper::ensureFolderExists($path);
82 
83         if (!IOHelper::fileExists($path.'.gitignore'))
84         {
85             IOHelper::writeToFile($path.'.gitignore', "*\n!.gitignore\n\n", true);
86         }
#5  
+  /Volumes/HDD/Sites/myredlight/craft/app/services/PathService.php(354): Craft\PathService->getRuntimePath()
#6  
+  /Volumes/HDD/Sites/myredlight/plugins/nocache/services/NoCacheService.php(20): Craft\PathService->getCompiledTemplatesPath()
#7  
+  /Volumes/HDD/Sites/myredlight/plugins/nocache/services/NoCacheService.php(90): Craft\NoCacheService->getCompilePath("o7Yyxd8CkaPY72PV4Fnu6LhS")
#8  
+  /Volumes/HDD/Sites/myredlight/plugins/nocache/NoCachePlugin.php(107): Craft\NoCacheService->render("o7Yyxd8CkaPY72PV4Fnu6LhS", "mwm9BRFP")
#9  
 unknown(0): Craft\NoCachePlugin->Craft\{closure}(array("<!--nocache-o7Yyxd8CkaPY72PV4Fnu6LhS-mwm9BRFP-->", "o7Yyxd8CkaPY72PV4Fnu6LhS", "mwm9BRFP"))
#10 
+  /Volumes/HDD/Sites/myredlight/plugins/nocache/NoCachePlugin.php(109): preg_replace_callback("/<!--nocache-([a-z0-9]+)-([a-z0-9]+)-->/i", Closure, " <!DOCTYPE html> <!--[if IE 9]><html class="lt-ie10" lang="en" >...")
#11 
 unknown(0): Craft\NoCachePlugin->Craft\{closure}()

Issue with PHP OPCache?

I've had issues where, in production running OPCache, I've cleared the template cache from the Admin Control Panel, gone back to the front-end of the site and my no-cache blocks are completely empty and breaking quite a lot of the site.

This is only cleared by restarting PHP, thus restarting OPCache.

Is this something you're aware of, or know a better way of dealing with clearing template caches with OPCache enabled?

breaking change with Craft 2.7.7+

Description

We've updated a Craft 2 site from 2.7.6 -> 2.7.7 (and above) and it seems to be introducing breaking changes with the nocache plugin. It's giving us the following error anywhere we use this plugin within the Twig templates.

We noticed starting in Craft 2.7.7 that Twig was updated to 1.38.4. Based on the error in the screenshot attached, we believe that may be the issue.

Steps to reproduce

  1. Update to Craft 2.7.7 or later
  2. Attempt to open any page that uses {% nocache % } tags.
  3. Receive the following error:

Screen Shot 2019-04-29 at 2 25 20 PM

Additional information

  • No-Cache version: 1.0.3
  • Craft CMS version: 2.7.7
  • PHP version: tested on 5.6,7.0,7.1, and 7.2.x

Serialization of 'Closure' is not allowed

Description

I am having a setup, where I cache a whole entry page. Within certain pages, I have a form field, which I want to exclude from cache.

My code looks basically like this:

_entry.twig

<div class="entry-page-contact">
    {% cache %}
        {% include 'voan/_includes/breadcrumb' %}
        {% include 'voan/_includes/_fields/form' %}
    {% endcache %}
</div>

form.twig

{% if entry.form %}
    {% nocache with {entry: entry} %}
        <div class="field-form">
        ...
        </div>
    {% endnocache %}
{% endif %}

While having this setup, I get an Exception Serialization of 'Closure' is not allowed: in /var/www/vendor/yiisoft/yii2/caching/Cache.php at line 249 – serialize([['entry' => benf\neo\elements\Block], null])

Additional information

  • No-Cache version: 2.0.6
  • Craft CMS version: 3.4.22.1
  • PHP version: 7.2

{% js %} not outputting when inside nocache

I have an include file which contains JS via {% js %} tags

This include file is inside {% nocache %} tags

The JS is not being output on the page. It was all fine before using nocache

Can it be linked to this?

Things Inside of nocache becomes cached.

Description

I have the problem that things inside the nocache tag becomes cached.
It's a onepager, every section is a entry and inside of that i have a neo field.

Additional information

  • No-Cache version: 2.0.4
  • Craft CMS version: 3.2.7
  • PHP version: 7.1

The Code

{% cache globally using key "home-" ~ craft.app.request.pathInfo %}
{%- minify -%}

	{% for entry in entry.siteSection.all() %}
	    <section id="{{ entry.navTitle | kebab }}">
			
			{% if entry.bodyMain is defined and entry.bodyMain | length %}
				{% for block in entry.bodyMain.all() %}
					{% switch block.type.handle %}
			
						{% case 'callTeam' %}	
							
							{% nocache %}
								{% set team = craft.entries.section('team').order('RAND()').all() %}
							
								{% for entry in team %}
									{% switch entry.type %}
										{% case 'team' %}
											Code
									    
									    {% case 'job' %}
									    	Code
									    	
									    {% case 'default' %}
									    
								    {% endswitch %}
								{% endfor %}
							{% endnocache %}

							
					{% endswitch %}
				{% endfor %}
			{% endif %}
			
	    </section>
	{% endfor %}
	
{%- endminify -%}
{% endcache %}

Entry does not exist when in between no cache tags

Description

In my template: {{ entry.url }} outputs the url.

If I write:

{% nocache %}
  {{ entry.url }}
{% endnocache %}

I get

Variable "entry" does not exist in "_pages/index" at line 16.

Steps to reproduce

  1. install no cache
  2. add no cache tag
  3. add something in between the tags

Additional information

  • No-Cache version: 1.0.4
  • Craft CMS version: 3.2.3
  • PHP version: 7.2.14

{% nocache %} seems incompatible with {% embed %}

Description

Using the {% nocache %} around an {% embed %} tag throws a yii\base\ErrorException:

Cannot declare class __TwigTemplate_58ca26ca050e28ccd1000e621e244e86d4395a3d535ac28fb668ef8f85a11918, because the name is already in use

Steps to reproduce

To reproduce, create the following templates and navigate to /nocache.

templates/nocache/index.twig:

{% nocache %}
    {% embed 'nocache/_list.twig' with { heading: 'Drinks' } %}
        {% block listItems %}
            {% include 'nocache/_item.twig' with { name: 'Beer' } %}
            {% include 'nocache/_item.twig' with { name: 'Orange juice' } %}
            {% include 'nocache/_item.twig' with { name: 'Water' } %}
        {% endblock %}
    {% endembed %}
{% endnocache %}

_templates/nocache/list.twig:

<h1>{{ heading }}</h1>
<ul>
    {% block listItems %}{% endblock %}
</ul>

_templates/nocache/item.twig:

<li>{{ name }}</li>

Additional information

  • No-Cache version: 2.0.6
  • Craft CMS version: 3.5.16
  • PHP version: 7.4

PHP notice on logout from frontend

Users get logged out (path: domain.com/logout) but are being presented with a PHP notice:

Notice: ob_clean(): failed to delete buffer of zlib output compression (1) in /var/www/virtual/user/craft/app/framework/base/CErrorHandler.php on line 112

in

ob_get_clean(): failed to discard buffer of zlib output compression (1)

/var/www/virtual/user/craft/plugins/nocache/NoCachePlugin.php(101)

089         // 1. Only enable the plugin's functionality if template caching is enabled
090         // 2. Watch for `nocache` blocks only if it's a site request
091         if(craft()->noCache->isCacheEnabled() && craft()->request->isSiteRequest())
092         {
093             // Working directory may change during `register_shutdown_function`, so let's deal with that by caching the
094             // current working directory to a constant
095             define('NOCACHEPLUGIN_CWD', getcwd());
096 
097             // Capture the raw request output right before it's sent to the requester
098             register_shutdown_function(function()
099             {
100                 $devMode = craft()->config->get('devMode');
101                 $output = ob_get_clean();

(…)

Happens in devMode, did not test in production.

Uncaught Type error

Description

Fatal error: Uncaught TypeError: Argument 1 passed to __NoCacheTemplate_cmEum55xsrZjI4i7Hc2xwioM::__construct() must be an instance of Environment, instance of Craft\TwigEnvironment given

Steps to reproduce

  1. Add {% nocache %}text here{% endnocache %} to the template and load the page.

Additional information

  • No-Cache version: 1.0.3
  • Craft CMS version: 2.8.0.1
  • PHP version: 7.2.24

Also using HTML Cache 1.0.4.1

Importing macros from a different template file works, but from _self does not

Description

I've found that importing a macro using _self inside a nocache tag throws an error.

For example, if you have template_example.twig with a macro defined at the top, then this fails.

{% macro rendyEntry(entry) %}
    ...macro code here
{% endmacro %}

{% nocache %}
{% import _self as macros %}
...

However, importing them from a different file works as expected.

{% nocache %}
{% import "_partials/macros" as macros %}
...

Additional information

  • No-Cache version: 2.07
  • Craft CMS version: 3.7.7
  • PHP version: 7.3.28

Handy plugin! 👍

Adding parameter ?token=[any], nocache returns the cache token ID

Description

When viewing a page that uses the nocache plugin, user can add a invalid token to the URL to change the output chunk to a number string.

Steps to reproduce

  1. View a page that uses the nocache plugin but does not have valid x-craft-preview and token
  2. Update the URL to include the parameter token set to anything (e.g., "token=1"). For instance, www.example.com has a news feed with nocache. Update url to www.example.com?token=test
  3. Nocache chunk will be replaced with ID or file name matching /craftcms/storage/runtime/compiled_templates/nocache

Additional information

  • No-Cache version: 3.0.0
  • Craft CMS version: Craft Pro 4.5.10
  • PHP version: 8.0.24

Array values not getting passed into nocache block

Description

In some circumstances, array values are not getting passed into the nocache block (scalar values seem to be working fine), and array-related Twig filters (like |merge) inside the nocache block are complaining about the input not being an array.

Steps to reproduce

I'm not able to reproduce this consistently right now, but the following steps should be a starting point. Will add updates as soon as I can.

  1. Create a nocache block that uses array values from outside it.
  2. Apply the merge filter on the array value inside the nocache block (can even be something like set arr = arr|merge('[]')).

Additional information

  • No-Cache version: 2.0.7
  • Craft CMS version: 3.5.19.1
  • PHP version: 7.4.19

No cache disables forms

Description

If I add nochache around the craft form plugin. It disapears completely:

{% nocache %}
       {% include "_organisms/form/contactForm" %}
{% endnocache %}

Steps to reproduce

  1. Install no cache
  2. Wrap form.
  3. the form is no longer rendered.

Additional information

  • No-Cache version: 2.0.4
  • Craft CMS version: 3.2.2
  • PHP version: 7.1.3

Error with Craft 3.1.24 / Twig 2.8

Description

After upgrading to Craft 3.1.24, attempting to compile a No-Cache template will cause an error.

Thanks to @pvldigital for alerting me to this!

Steps to reproduce

  1. Update to Craft 3.1.24
  2. Clear template caches
  3. Load a front-end page that uses No-Cache

Additional information

  • No-Cache version: 2.0.2
  • Craft CMS version: 3.1.24
  • PHP version: n/a

nocache for Craft 3

nocache is a really helpful plugin to get more flexibility with caching in Craft. Are there any plans to create a version for Craft 3?

Can't use cache key with no cache?

Hiya,

Take the following

{% cache globally using key 'cache__key' for 1 month %}
   Cache me

    {% nocache %}
      Do not cache me
    {% endnocache %}
  {% endcache %}

This caches in craft_templatecaches as cache__key with a body of cache me <no-cache>3HkJuIQdEFS4Rvv50KnpVs3s-fIhF5j7S</no-cache>, which seems correct to me.

However, if I update the 'Do not cache me' text, the nocache block doesn't update. If I do not use a key then it updates correctly.

So this leads me to believe that it is not possible to use key parameter with no cache?

Thanks

TypeError on Craft 3.1.19

Description

After upgrading to Craft 3.1.19 from an earlier 3.1 release, I receive the following error related to No-Cache:

Argument 1 passed to __NoCacheTemplate_ZE9TbMSaN1OaMzFMumUHIwPo::__construct() must be an instance of Environment, instance of craft\web\twig\Environment given, called in /app/vendor/ttempleton/craft-nocache/src/Service.php on line 112

I am guessing that this is related to the recent Twig 2.7.x changes.

Any help or direction is much appreciated!

Additional information

  • No-Cache version: 2.0.0
  • Craft CMS version: 3.1.19
  • PHP version: 7.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.