Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Mark Croxton

     

Stash get_list not working after update to 2.8.1

Support Request

Fr. Daniel Triant
Fr. Daniel Triant

Upgraded EE to 2.8.1. Using Stash 2.5.2 and Switchee 2.1.1.

I am setting the categories for my entry in the following snippet:

{exp:stash:set_list:cat 
  name
="entry_categories_{entry_id}" 
  
parse_tags="yes"
  
refresh="1440"
  
replace="yes"
  
save="yes"
  
scope="site"
}
  {categories} 
   {switchee variable
="{channel_short_name}" parse="inward"}
    {case value
="blog_entry|blog_events|blog_deadlines"}
      {stash
:cat_category}<a href="{path=blog}">{category_name}</a>{/stash:cat_category}
    {
/case}
    {case value
="events|event_groups"}
      {stash
:cat_category}<a href="{path=events}">{category_name}</a>{/stash:cat_category}
     {
/case}
   {
/switchee}
  {
/categories}
{
/exp:stash:set_list:cat} 

I am using the following snippet to retrieve the values:

{exp:stash:get_list:cat 
 name
="entry_categories_{entry_id}" 
 
parse_conditionals="yes"
 
prefix="cat"
 
require_prefix="no"
 
scope="site" 
 
trim="yes"
}
 {cat_category}{if cat
:count != cat:total_results},{/if} 
{
/exp:stash:get_list:cat} 

I can see that it’s retrieving the values form the DB correctly, but on the page it prints {cat_category} not the categories for the entry. I’ve removed the switchee statement and I’m still seeing the same issue. I should note that the get is being called inside stash:embed. I’ve see that you made some changes to how the prefix works, but adding require_prefix did not fix the issue.

Any help is appreciated. Thanks.

Mark Croxton
# 1
Developer
Mark Croxton

What happens if you replace {cat_category} with {cat:cat_category}

Also, can you turn on template debugging and see what value the variable {entry_categories_x} is set to? (look for lines beginning Stash: SET…).

Fr. Daniel Triant
# 2
Fr. Daniel Triant

Hey Mark,

Thanks for the quick reply. First, I tried adding {cat:cat_category} however, it still displays {cat_category}. Second, I turned on debugging and I see the following:

(0.264182 25.76MBStashSET entry_categories_158 to value cat_category|=|<a href="http://mjc.dev:8888/blog/category/news">News</a>
(
0.359411 27.48MBStashRETRIEVED entry_categories_158 with value cat_category|=|<a href="http://mjc.dev:8888/blog/category/news">News</a

Also, I am now seeing a bunch of php errors:

A PHP Error was encountered

Severity
Notice

Message
Undefined propertyEE_Template::$layout_conditionals

Filename
libraries/Template.php

Line Number
3375

A PHP Error was encountered

Severity
Warning

Message
array_merge() [function.array-merge]Argument #4 is not an array

Filenamelibraries/Template.php

Line Number
3375

A PHP Error was encountered

Severity
Warning

Message
array_merge() [function.array-merge]Argument #1 is not an array

Filenamelibraries/Functions.php

Line Number
2373

A PHP Error was encountered

Severity
Warning

Message
Cannot modify header information headers already sent by (output started at /Users/dtriant/Sites/_clients/jahariscenter/content/_byzantia537/codeigniter/system/core/Exceptions.php:170)

Filenamecore/Common.php

Line Number
446 

I noticed someone else was getting these errors as well, but it seemed like it was related to the IF:ELSE plugin. I don’t use if:else, but use Switchee. Could this be causing an issue?

I have a main template for the blog to differentiate between listing and single-entry in which I have Switchee, then I have a snippet to set_list for either the listing (sn_set_blog_list) or the entry (sn_set_blog_entry) and then display the appropriate partial. The set_list code above is called as a snippet (sn_set_categories) in both of those setters, which is why I am using {switchee} and not {exp:switchee} in the above code. The following is my main template code (with some code removed for brevity sake).

{exp:switchee variable="{segment_2}" parse="inward"}

{
!--  ============================================
LISTINGS
================================================== --}
{case value
="''|category"}
    {stash
:embed:layouts:index}
    {exp
:stash:set_value name="content" value="{exp:stash:embed:partials:listing}"}
    {sn_set_blog_list}
{
/case}
 
{
!--  ============================================
  
SINGLE ENTRY
================================================== --}
{case 
default="yes"}
    {stash
:embed:layouts:single-entry}
    {exp
:stash:set_value name="content" value="{exp:stash:embed:partials:article}"}
    {sn_set_blog_entry}
{
/case}

{
/exp:switchee} 
Mark Croxton
# 3
Developer
Mark Croxton

It seems to be to do with the prep_conditionals() function which is used by EE to prepare conditionals prior to parsing.

I’d suggest removing the parameter parse_conditionals=“yes” for now that might stop the error.

I’ll look into why the error is generated.

 

Mark Croxton
# 4
Developer
Mark Croxton

Reproduced the bug. It’s arguably an EE bug in that the advanced_conditionals() method of the Template class now assumes the layout_conditionals array exists, even if you are not using layouts in your template. It provides defaults for the other variable arrays (e.g. embeds) so it’s probably because it’s a new feature that this array was missed.

Problem only occurs in Stash embeds or blocks of code parsed after template parsing has completed.

I have a workaround that I’ll push to the repo shortly. Looks like I’ll need to update IfElse too. Switchee is not affected.

Mark Croxton
# 5
Developer
Mark Croxton

Stash updated to 2.5.3

Fr. Daniel Triant
# 6
Fr. Daniel Triant

Mark,

Great, the update fixed my errors.

As for the original problem, it appears as though I’m a bonehead. I had SnippetSync disabled and my snippet wasn’t getting updated when I added the require_prefix parameter and the cat: prefix to the variable. It is all working perfectly now.

Thanks so much for your quick turn around, I appreciate the help. And many thanks for all the work on Stash.