croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Receiving stash errors for array_key_exists #85

Closed furioursus closed 10 years ago

furioursus commented 10 years ago

I’m running into an error with stash wherein I'm receiving two errors stating that array_key_exists. These errors/warnings are showing up and causing no small amount of grief for me and my client. I'm not quite sure where to begin. I took a look at another issue that was opened, but I'm not quite sure of how to implement the fix. Am I supposed to replace all 521 instances of $this->EE with ee()? I'm running EE 2.7.2 and Stash 2.4.7. The full rundown of addons is below the error message.

A PHP Error was encountered
Severity: Warning  
Message: array_key_exists(): The first argument should be either a string or an integer  
Filename: stash/mod.stash.php  
Line Number: 812

A PHP Error was encountered  
Severity: Warning  
Message: array_key_exists(): The first argument should be either a string or an integer  
Filename: stash/mod.stash.php  
Line Number: 818

Addons:

Add-On Name Type Installed Latest Status
DataGrab $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.8.0 1.8.0 Up-to-date
AJW Export
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
0.9 Version Info Unavailable - Details
Assets $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.2.3 2.2.2 Installed version higher than devot:ee's
Backup Pro(ish)
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.1.2 1.1.2 Up-to-date
CE Cache $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.10.1 1.10.1 Up-to-date
CE Image $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.4.5 2.4.5 Up-to-date
Ce Img Aws
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.1 Not Found - Search
CE Lossless $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2.1 1.2.1 Up-to-date
CE String $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.5 1.5 Up-to-date
CE Tweet $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.3.4 1.3.8 Update Available
Release Notes
  • The themes folder was missing. Many people use the template tags exclusively, but if you were trying to use the Control Panel functionality and it wasn't working as expected, please upgrade to this release.
Channel Images $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
5.4.10 5.4.10 Up-to-date
Channel Videos
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
3.1.0 Version Info Unavailable - Details
ClassEE Body
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.1 2.0 Installed version higher than devot:ee's
Deeploy Helper $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.3 2.0.3 Up-to-date
devot:ee Monitor
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2.4 1.2.4 Up-to-date
Draggable
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.4.2 1.4.2 Up-to-date
DropDate
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.2.0 2.2.0 Up-to-date
Embed video
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2.2 1.2.2 Up-to-date
Entry Data
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.6 1.6 Up-to-date
Export It $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.3.1 1.3.1 Up-to-date
FG Location $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0.4 1.0.4 Up-to-date
Foursquare Venue $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.1 1.1 Up-to-date
Freebie
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
0.2 0.2 Up-to-date
Freeform $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
4.0.12 4.1.3 Update Available
Release Notes
  • Fixed a bug where default fieldtypes might error on install on Windows servers.
  • Fixed a bug where editing a form could show PHP errors in the control panel.
  • Fixed a bug where form entry filtering was failing in IE8 due to the use of an old reserved keyword in javascript.
Helpdesk $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2.3 1.2.3 Up-to-date
Illuminated $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2 1.2 Up-to-date
JSON
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0.2 1.0.0 Installed version higher than devot:ee's
JSON encode tag
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0 Version Info Unavailable - Details
Lonely Cat
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.2 1.2 Up-to-date
Low Replace
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.2 Version Info Unavailable - Details
Low Search $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
3.0.2 3.0.3 Update Available
Low Seg2Cat
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.6.1 Version Info Unavailable - Details
Low Title
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.1.2 Version Info Unavailable - Details
Low Variables $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.4.0 2.4.0 Up-to-date
Matrix $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.5.10 2.5.10 Up-to-date
Minimee
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.1.9 2.1.9 Up-to-date
Missing Link $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.5.1 1.5.1 Up-to-date
Mo’ Variables
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.1.5 1.1.5 Up-to-date
Module Nav
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0 Version Info Unavailable - Details
MX Google Maps
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.5.3 1.5.1 Installed version higher than devot:ee's
NavEE $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.2.8 2.2.8 Up-to-date
NSM Better Meta $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.1.5.1 1.1.4 Installed version higher than devot:ee's
NSM Morphine theme
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.3 Not Found - Search
Page History
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.04 1.04 Up-to-date
Playa $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
4.4.5 4.4.5 Up-to-date
Publish Prefixes
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0 Not Found - Search
Scrub
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
0.1 Version Info Unavailable - Details
Search Fields
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.3 2.0.3 Up-to-date
Sitemap Module $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.6.3 2.6.3 Up-to-date
Social Login $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.4 2.0.4 Up-to-date
Stash
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.4.7 2.4.7 Up-to-date
Superfish EE Control Panel Hide this
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
0.1 0.1 Up-to-date
Switchee
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.0.6 2.0.6 Up-to-date
Custom System Messages $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.5 2.5 Up-to-date
URL Helper
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0.4 1.0 Installed version higher than devot:ee's
VZ Address
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.4.0 1.4.0 Up-to-date
VZ URL extension
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
2.3.1 2.3.1 Up-to-date
Wygwam $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
3.2.2 3.2.2 Up-to-date
Wygwam Super Admin Source Hide this
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.0 Version Info Unavailable - Details
Zenbu $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.9.0 1.9.0 Up-to-date
Zoo Visitor $  
  • MOD
  • EXT
  • PLG
  • FLD
  • ACC
1.3.30 1.3.30 Up-to-date
croxton commented 10 years ago

If it is the same issue then one of your other add-ons must be calling a stash method statically, but not declaring an instance of EE as a property of the class. There's no need to replace every instance of ee(), rather all that is required is to add $this->EE = get_instance(): to the constructor of the third party add-on. Search your third_party folder files for the string 'stash::'

furioursus commented 10 years ago

That wouldn’t be it, then, since there are no third party add ons calling stash, except for switchee, which I would imagine you are fully on top of being compatible in the first place. What else could I provide to help diagnose the issue? On December 18, 2013 at 12:16:12 AM, Mark Croxton (notifications@github.com) wrote:

If it is the same issue then one of your other add-ons must be calling a stash method statically, but not declaring an instance of EE as a property of the class. There's no need to replace every instance of ee(), rather all that is required is to add $this->EE = get_instance(): to the constructor of the third party add-on. Search your third_party folder files for the string 'stash::'

croxton commented 10 years ago

Please could you try that search for "stash::" anyway? Some add-ons have started using Stash internally. Then we can rule it out.

furioursus commented 10 years ago

Sorry, that's what I mean, I did perform the search. Two instances came up in the stash addon files and once in switchee

croxton commented 10 years ago

Before we go any further - please uninstall Stash, remove the files from your system folder, check the tables are no longer in the db. Then grab the latest files from here and reinstall. Make sure both the module and extension are installed.

After that, if you still have a problem, please take a look at your extensions table in the db and see what other extensions are attached to template_fetch_template and template_post_parse and let me know.

furioursus commented 10 years ago

Followed your instructions and still get the same error. I took a look at the extensions table and found the following data:

extension_idclassmethodhooksettingspriorityversionenabled
7Low_variables_exttemplate_fetch_templatetemplate_fetch_templatea:8:{s:11:"license_key";s:36:"[[REDACTED]]";s:10:"can_manage";a:2:{i:0;s:1:"6";i:1;s:1:"1";}s:11:"clear_cache";s:1:"y";s:16:"register_globals";s:1:"y";s:20:"register_member_data";s:1:"y";s:13:"save_as_files";s:1:"y";s:9:"file_path";s:70:"/Users/chris/Repos/gaytravel-new/public_html/assets/template_variables";s:13:"enabled_types";a:23:{i:0;s:12:"low_checkbox";i:1;s:18:"low_checkbox_group";i:2;s:8:"dropdate";i:3;s:14:"fieldpack_list";i:4;s:14:"fieldpack_pill";i:5;s:16:"fieldpack_switch";i:6;s:11:"illuminated";i:7;s:14:"low_reorder_vt";i:8;s:6:"matrix";i:9;s:5:"playa";i:10;s:15:"low_radio_group";i:11;s:10:"low_select";i:12;s:21:"low_select_categories";i:13;s:19:"low_select_channels";i:14;s:18:"low_select_entries";i:15;s:16:"low_select_files";i:16;s:9:"low_table";i:17;s:14:"low_text_input";i:18;s:7:"low_rte";i:19;s:10:"vz_address";i:20;s:6:"vz_url";i:21;s:6:"wygwam";i:22;s:12:"low_textarea";}}22.4.0y
32Ce_cache_exttemplate_pre_parsetemplate_fetch_templatea:0:{}91.9.4y
92Mo_variables_extruntemplate_fetch_templatea:22:{s:4:"ajax";s:1:"1";s:6:"secure";s:1:"1";s:3:"get";s:1:"1";s:12:"defaults_get";s:1:"1";s:8:"get_post";s:1:"1";s:17:"defaults_get_post";s:1:"1";s:4:"post";s:1:"1";s:13:"defaults_post";s:1:"1";s:6:"cookie";s:1:"1";s:15:"defaults_cookie";s:1:"1";s:9:"flashdata";s:1:"1";s:18:"defaults_flashdata";s:1:"1";s:12:"page_tracker";s:1:"1";s:16:"reverse_segments";s:1:"1";s:13:"segments_from";s:1:"1";s:9:"paginated";s:1:"1";s:7:"archive";s:1:"1";s:11:"categorized";s:1:"1";s:22:"reserved_category_word";s:1:"1";s:11:"current_url";s:1:"1";s:16:"member_variables";s:1:"1";s:25:"member_group_conditionals";s:1:"1";}101.1.5y
126Stash_exttemplate_fetch_templatetemplate_fetch_template102.4.7y
42Minimee_exttemplate_post_parsetemplate_post_parsea:18:{s:9:"base_path";s:0:"";s:8:"base_url";s:0:"";s:9:"cachebust";s:0:"";s:10:"cache_path";s:0:"";s:9:"cache_url";s:0:"";s:7:"cleanup";s:2:"no";s:11:"combine_css";s:3:"yes";s:10:"combine_js";s:3:"yes";s:11:"css_library";s:6:"minify";s:16:"css_prepend_mode";s:3:"yes";s:15:"css_prepend_url";s:0:"";s:7:"disable";s:2:"no";s:11:"hash_method";s:4:"sha1";s:10:"js_library";s:5:"jsmin";s:10:"minify_css";s:3:"yes";s:11:"minify_html";s:2:"no";s:9:"minify_js";s:3:"yes";s:11:"remote_mode";s:4:"auto";}102.1.9y
93Mo_variables_extcleanuptemplate_post_parsea:22:{s:4:"ajax";s:1:"1";s:6:"secure";s:1:"1";s:3:"get";s:1:"1";s:12:"defaults_get";s:1:"1";s:8:"get_post";s:1:"1";s:17:"defaults_get_post";s:1:"1";s:4:"post";s:1:"1";s:13:"defaults_post";s:1:"1";s:6:"cookie";s:1:"1";s:15:"defaults_cookie";s:1:"1";s:9:"flashdata";s:1:"1";s:18:"defaults_flashdata";s:1:"1";s:12:"page_tracker";s:1:"1";s:16:"reverse_segments";s:1:"1";s:13:"segments_from";s:1:"1";s:9:"paginated";s:1:"1";s:7:"archive";s:1:"1";s:11:"categorized";s:1:"1";s:22:"reserved_category_word";s:1:"1";s:11:"current_url";s:1:"1";s:16:"member_variables";s:1:"1";s:25:"member_group_conditionals";s:1:"1";}101.1.5y
127Stash_exttemplate_post_parsetemplate_post_parse102.4.7y
furioursus commented 10 years ago

I went ahead and tried disabling every extension that used those methods or hooks, and I'm still getting the same errors, as well. They are no longer in the DB, nor are they in the file system.

croxton commented 10 years ago

Do you see stash_delete or stash_load_template_class being used by an add-on in the extensions table?

Do you get the error with a blank template? If not, you could start adding in tags from another template until you trigger the error, to narrow down what tag is causing the problem.

rsanchez commented 10 years ago

You get this error when the name parameter is blank. What could cause the name parameter to be blank? I discovered this edge case myself. Chris, try opening up mod.stash.php around line 747 where it says:

$name           = $this->EE->TMPL->fetch_param('name');

And add this line after:

$name           = $this->EE->TMPL->fetch_param('name');
if ($name === false) var_dump($this->EE->TMPL->tagproper);

Take a look at the dumped output. Does it have your template tag w/ encoded quotes? Meaning {exp:stash:get name="foo"} as opposed to what you'd expect, {exp:stash:get name="foo"}.

I haven't been able to track down exactly why this quote encoding happens, but I believe it has to do with something introduced in EE 2.6 or 2.7.

croxton commented 10 years ago

Interesting. CKEditor will convert quotes to ". Were either of you using Stash tags in a WYSIWYG custom field? And / or, is it possible you used curly quotes for your parameters instead of straight quotes (can happen when copy-pasting code)?

rsanchez commented 10 years ago

My specific case was Freeform Pro. Specifically they have a hidden fieldtype, where you can set a default value. The default value may contain EE tags, like a stash get tag. This used to work for me on EE 2.5.5, but after updating the value is getting encoded. I've tried to get an answer from Solspace whether they think this is an EE thing or a Freeform issue (I think it's the former). I'll keep you posted if I figure anything out.

furioursus commented 10 years ago

Okay, looks like I'm indeed getting those encoded quotes too. I'm seeing: string(42) "{exp:stash:get name='pagetitle'}" show up now. I don't have any hidden tags here (or so I thought), nor am I using stash tags anywhere other than inside this template. Specifically though, I'm using it inside of an NSM Better Meta tag. Taking the tag out doesn't seem to remove the problem, though.

furioursus commented 10 years ago

Scratch that, removing the entire stash tag pair, as well as the switchee tag around it seems to relieve the initial issue. For reference, here's what I'm working with, and what I'm about to start tweaking and adjusting:

{exp:switchee variable="{host}" parse="iwnard"}
{case value="www.gaytravel.com"}
    {switchee variable="{segment_1}" parse="inward"}
        {case value=""}
            {exp:nsm_better_meta:template
                title="Gay Travel is Your Guide to Gay Vacations, Hotels, and Destinations"
                hide_site_title = "y"
              }
        {/case}
        {case default="yes"}
            {if "{embed:page_entry_id}"}
                {exp:nsm_better_meta:template
                    entry_id="{embed:page_entry_id}"
                }
            {if:else}
                {exp:nsm_better_meta:template
                    title="{exp:stash:get name='pagetitle'}"
                    hide_site_title = "y"
                }
            {/if}
        {/case}
    {/switchee}
{/case}
{case default="yes"}
    {switchee variable="{segment_1}" parse="inward"}
        {case value=""}
            {exp:nsm_better_meta:template
                title="Gay Travel is Your Guide to Gay Vacations, Hotels, and Destinations"
                hide_site_title = "y"
                robots_index="no"
                robots_follow="no"
                robots_archive="no"
              }
        {/case}
        {case default="yes"}
            {if "{embed:page_entry_id}"}
                {exp:nsm_better_meta:template
                    entry_id="{embed:page_entry_id}"
                    robots_index="no"
                    robots_follow="no"
                    robots_archive="no"
                }
            {if:else}
                {exp:nsm_better_meta:template
                    title="{exp:stash:get name='pagetitle'}"
                    hide_site_title = "y"
                    robots_index="no"
                    robots_follow="no"
                    robots_archive="no"
                }
            {/if}
        {/case}
    {/switchee}
{/case}
{/exp:switchee}
croxton commented 10 years ago

parse="iwnard" that's going to screw things right up!

furioursus commented 10 years ago

Well, crap. That looks like the culprit right there. I’m no longer getting any errors, but will update if something weird(er) happens.

On December 31, 2013 at 9:59:09 AM, Mark Croxton (notifications@github.com) wrote:

parse="iwnard" that's going to screw things right up!

— Reply to this email directly or view it on GitHub.

GDmac commented 10 years ago

lol, parse=awkward