Posted: October 27, 2015 at 4:25 am
Hi, What does this error mean? – *redacted* Thanks.
|
|
Hi, Its means array_shift() was called on a variable (expecting and array) to pull the first element from the array so you can use, but the function was given a string rather than an array. This can happen for multiple reasons, the custom template you are using does not match the default template as that doesn’t contain array_shift() so I can’t say what is actually causing it. Are you passing any parameters over with the shortcode? |
|
Thanks Tony, Here is the shortcode that I’ve used – We just got it working following our previous post here – https://eventespresso.com/topic/ee4-table-template-limit-more-than-10-no-pagination/ We have the template ‘espresso-events-table-template.template.php’ in the uploads/espresso/templates folder. Is the shortcode not right now? Thanks. |
|
Was the template customized by Ben? Does the error go away if you switch to the built in template? It may help to see the actual code that’s throwing the error. Can you post to a pastebin or a gist? |
|
Yes, he’s done an excellent job building our site with event espresso 4. Yes, the error goes away by removing the template, the template has been working fine until today. Could some translation phrases in the .mo file effect the template, as those were the only changes we made yesterday? Here is the actual table template code, that is now causing the error – http://pastebin.com/PqdE9097 |
|
Hi Kim, I checked and do not see any translation phrases in espresso_event_tickets_available(), so I don’t think it’s a case where the translation phrases would affect this. It looks more like events with no tickets though. Like a sold out event. Can you contact Ben and ask him to look into the error in the custom template code he wrote. The code in question appears to be:
He should be able to add an is_array() check before doing the array_shift() to prevent errors. |
|
|
Hi Josh, In regards to this error appearing for the table template; However, this is because we have removed the .mo translation file with 16 translations on it. The moment we re-add the .mo file in the uploads/espresso/languages then the error appears. We made the amendments to the table using Lorenzo’s code for the table from here – Can you explain why we need to add |
Hi Ben, The .mo file isn’t causing the error, it’s more of a symptom. The error will also show up under other conditions. The root cause of the issue is your code assumes there will always be an array of tickets, no matter what. The thing is though, you might get an array, you might get nothing, or even a string (especially if you have debugging turned on). Again, this can happen with or without your .mo file customizations. So to make your code more bulletproof and not fire a warning when you try to run array_shift() on something that’s not an array, you test for an array first. That’s why I suggest using is_array() to check first and make sure that you have an array before you run array_shift(). |
|
|
Thanks Josh, The is_array() has been added now and all working correctly for the table. Let me know if you want the code to share. Thanks! |
The support post ‘table template error ee4’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.