Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: exp:speedy:clear rendering InvalidArgumentException Caught message

Status Resolved
Add-on / Version Speedy 1.7
Severity
EE Version 6.4.4

John Derrick

May 21, 2023

On our site, we have a hidden URL that allows our publishing team to click a button to clear the cache of any given page. For example, the button will link to a page like this: https://DOMAIN.com/tools/clear-cache-EE6-speedy/26944/maui/maui

On that above page we have this Speedy clear tag:

{exp:speedy:clear tags="{last_segment}|{segment_5}-{last_segment}|{segment_3}-{segment_4}"}

That should render in theory a clear for the tags: maui|maui-maui|26944-maui

The tags for the entries are set as:

tags="{stash:entry_id}-{stash:url_title}|{segment_1}"

resulting in “26944-maui|maui” for the Speedy cached entry.

Thus given that tag is provided to the clear tag, it should work. I am using the redis cache, but I’ve tried with file caching too.

In our previous use of CECache, this worked but I am receiving an error when attempting to do the same with Speedy now. Something about the cache key must be at least 1 character. I might be doing something wrong, but I wanted to check and get your feedback.

Below is the entirety of the error I’m receiving:

InvalidArgumentException Caught
[Speedy] The cache key must be at least 1 character.
user/addons/speedy/Service/CacheItem.php:105

Stack Trace: Please include when reporting this error
#0 user/addons/speedy/Service/Drivers/AbstractFilesystemDriver.php(119): BoldMinded\Speedy\Service\CacheItem::validateKey(’‘)
#1 user/addons/speedy/Service/Drivers/FilesystemDriver.php(35): BoldMinded\Speedy\Service\Drivers\AbstractFilesystemDriver->getFilename(’‘)
#2 user/addons/speedy/Service/CacheBreaker.php(303): BoldMinded\Speedy\Service\Drivers\FilesystemDriver->deleteItem(’‘)
#3 user/addons/speedy/mod.speedy.php(246): BoldMinded\Speedy\Service\CacheBreaker->clearItems(Array)
#4 ee/legacy/libraries/Template.php(1763): Speedy->clear()
#5 ee/legacy/libraries/Template.php(1439): EE_Template->process_tags()
#6 ee/legacy/libraries/Template.php(603): EE_Template->tags()
#7 ee/legacy/libraries/Template.php(236): EE_Template->parse(’{!—ra:0000000…’, false, 1, false)
#8 ee/legacy/libraries/Template.php(166): EE_Template->fetch_and_parse(’‘, Array, false)
#9 ee/legacy/libraries/Core.php(784): EE_Template->run_template_engine(’‘, ‘’)
#10 ee/legacy/controllers/ee.php(53): EE_Core->generate_page()
#11 [internal function]: EE->index(‘26944’, ‘maui’, ‘maui’)
#12 ee/ExpressionEngine/Core/Core.php(266): call_user_func_array(Array, Array)
#13 ee/ExpressionEngine/Core/Core.php(122): ExpressionEngine\Core\Core->runController(Array)
#14 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run(Object(ExpressionEngine\Core\Request))
#15 index.php(165): require_once(’...’)
#15 index.php(165): require_once(’...’)

Thanks for your help,
John

#1

BoldMinded (Brian)

Hi, John. This looks like it’s an issue with Stash, not Speedy. If you take Stash out of the equation and hard-code the expected value into the tags parameter in Speedy and it still doesn’t work then I’ll take another look at this, but this looks like certainly a parsing issue with Stash.

#2

John Derrick

How can I test if the tags are properly being assigned to the entries? I am using the exact same method of inserting the tags in Speedy I was using in CECache, so I’m not sure why it would be an issue with Stash now. I will try hard coding a tag however and see if the issue persists as you suggested, but if there is a way I can test to see if the tags are actually being inserted as expected using my stash tags, that would be a big help. Thanks

#3

John Derrick

OK, here’s what I tried and still received the same error about the cache key.

{exp:speedy:fragment key="data-entry-vars-v4" ttl="0" tags="{segment_1}-{last_segment}|{segment_1}"}

Page URL from the above code snippet is: https://DOMAIN.com/maui – Thus tags should be rendered as “maui-maui|maui”

So my button that clears the cache was sending this to the page that does the actual clearing: https://DOMAIN.com/tools/clear-cache-EE6-speedy/26944/maui/maui

And on that page linked above, this code should clear the tagged item of ‘maui’ without any issue:

{exp:speedy:clear tags="{last_segment}|{segment_5}-{last_segment}|{segment_3}-{segment_4}"}

So with stash removed, it’s still occurring. I can also try hard coding text values, but that will make clearing the cache difficult for various pages due to the nature of our setup. Do you think the dynamic EE-tagged variables are the issue?

#4

John Derrick

Ah, I figured out where to look for the tags; in the db, of course. I checked and my original method using stash tags was working, the tags were properly recorded as “26944-maui” for example. And in my new case above they were recorded as ‘maui-maui’ as expected.

#5

John Derrick

Sorry for all the follow-up’s, but I just noticed that the speedy items DO appear to be clearing when I visit the clear tags URL. I hadn’t though to actual go check the backend to see if they had disappeard. But even though it’s clearing my tagged items, it’s still throwing this error each visit to the page with the clear tag. But it DOES appear to be working. Not sure why I’m getting the error message, though:

InvalidArgumentException Caught [Speedy] The cache key must be at least 1 character. user/addons/speedy/Service/CacheItem.php:105

Stack Trace: Please include when reporting this error

0 user/addons/speedy/Service/Drivers/AbstractFilesystemDriver.php(119): BoldMinded\Speedy\Service\CacheItem::validateKey(”)

1 user/addons/speedy/Service/Drivers/FilesystemDriver.php(35): BoldMinded\Speedy\Service\Drivers\AbstractFilesystemDriver->getFilename(”)

2 user/addons/speedy/Service/CacheBreaker.php(303): BoldMinded\Speedy\Service\Drivers\FilesystemDriver->deleteItem(”)

3 user/addons/speedy/mod.speedy.php(246): BoldMinded\Speedy\Service\CacheBreaker->clearItems(Array)

4 ee/legacy/libraries/Template.php(1763): Speedy->clear()

5 ee/legacy/libraries/Template.php(1439): EE_Template->process_tags()

6 ee/legacy/libraries/Template.php(603): EE_Template->tags()

7 ee/legacy/libraries/Template.php(236): EE_Template->parse(‘{!– ra:0000000…’, false, 1, false)

8 ee/legacy/libraries/Template.php(166): EE_Template->fetch_and_parse(”, Array, false)

9 ee/legacy/libraries/Core.php(784): EE_Template->run_template_engine(”, ”)

10 ee/legacy/controllers/ee.php(53): EE_Core->generate_page()

11 [internal function]: EE->index(‘26944’, ‘maui’, ‘maui’)

12 ee/ExpressionEngine/Core/Core.php(266): call_user_func_array(Array, Array)

13 ee/ExpressionEngine/Core/Core.php(122): ExpressionEngine\Core\Core->runController(Array)

14 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run(Object(ExpressionEngine\Core\Request))

15 index.php(165): require_once(‘…’)

15 index.php(165): require_once(‘…’)

#6

BoldMinded (Brian)

Is there a chance that the template tag is getting called twice, the first time it clears it, and the second time, for whatever reason, does not have a valid tag parameter value?

#7

John Derrick

It shouldn’t be; it’s only included on the page I’m clearing the tags from a single time, and then there is a redirect script that is supposed to take the user back to the original page. It looks like this below, and I’ve never had a problem with this working in the past (using the previous caching module). I did try putting text directly into the clear tag, just to see if that worked, vs the segment variables, and it still threw the error back. I can’t figure out what’s causing that, but at least I know it clears now. I just would have to tell my team to ignore the error and hit the back button to return to the page in question. Ideally, we’d get it so the redirect script would work after the clear tag fires though.

{!-- first, clear the EE cached tag in Speedy --}
{exp:speedy:clear tags="{last_segment}|{segment_5}-{last_segment}|{segment_3}-{segment_4}"}

{!-- now, take the user back to the proper entry page--}
{if segment_8}
 {redirect="{segment_5}/{segment_6}/{segment_7}/{segment_8}?live=ee-cleared"}
{if:elseif segment_7}
 {redirect="{segment_5}/{segment_6}/{segment_7}?live=ee-cleared"}
{if:elseif segment_6}
 {redirect="{segment_5}/{segment_6}?live=ee-cleared"}
{if:elseif '{segment_5}'=='homepage'}
 {redirect="/?live=ee-cleared"}
{if:elseif segment_5}
 {redirect="{segment_5}?live=ee-cleared"}
{if:else}
 {redirect="/?live=ee-cleared"}
{/if}
#8

BoldMinded (Brian)

Are you able to replicate this in a clean/new EE environment with nothing else in the template except for the clear method call?

#9

BoldMinded (Brian)

Closing due to now activity in a month.

Login to reply