Support

Home Forums Event Espresso Premium Database error related to locales

Database error related to locales

Posted: January 16, 2013 at 8:43 pm

Viewing 8 reply threads


Jim Schuyler

January 16, 2013 at 8:43 pm

We have a web app built around EE that manages calendars of events for our stores. We have a number of “Espresso Regional Manager” accounts. Each one creates EE events and manages her own store’s event calendar. Each store is a “region” and “locale” in EE terms. So each manager sets up only events for her own locale.

The issue is that when a store manager creates a new event, clicking to create generates a “Database error” from MySQL right after clicking to create the event. The event appears on the calendar for the locale, but does not appear in the manager’s list of events so she can’t manage it. (Obviously because of the MySQL error, which I will paste below.)

We very recently upgraded to WP 3.5 and most recent versions of EE and calendar. We left slightly older versions of some components in place. As follows:
“Current”
EE version 3.1.29.1.P
EE Calendar 2.0.4
“Not current”
EE Members addon 1.9.3
EE Permissions 1.5.1
EE Recurring Events 1.1.7
EE Roles and Permissions Pro 2.0.3-beta

I have a staging site as well, but when I upgrade all of the components to most recent versions, things pretty much fall apart and I get lots of errors. I’m going to try to debug that.

Any rough ideas would be appreciated.

Here’s the error ( you can see it’s related to “locale”):

(SELECT e.id event_id, e.event_name, e.event_identifier, e.reg_limit, e.registration_start, e.start_date, e.is_active, e.recurrence_id, e.registration_startT, e.wp_user , v.name AS venue_title, v.address AS venue_address, v.address2 AS venue_address2, v.city AS venue_city, v.state AS venue_state, v.zip AS venue_zip, v.country AS venue_country , lc.name AS locale_name, e.wp_user FROM wp_events_detail e LEFT JOIN wp_events_venue_rel vr ON vr.event_id = e.id LEFT JOIN wp_events_venue v ON v.id = vr.venue_id LEFT JOIN wp_events_locale_rel l ON l.venue_id = vr.venue_id LEFT JOIN wp_events_locale lc ON lc.id = l.locale_id WHERE e.event_status = ‘A’ AND l.locale_id IN () ) UNION (SELECT e.id event_id, e.event_name, e.event_identifier, e.reg_limit, e.registration_start, e.start_date, e.is_active, e.recurrence_id, e.registration_startT, e.wp_user , v.name AS venue_title, v.address AS venue_address, v.address2 AS venue_address2, v.city AS venue_city, v.state AS venue_state, v.zip AS venue_zip, v.country AS venue_country , lc.name AS locale_name, e.wp_user FROM wp_events_detail e LEFT JOIN wp_events_venue_rel vr ON vr.event_id = e.id LEFT JOIN wp_events_venue v ON v.id = vr.venue_id LEFT JOIN wp_events_locale_rel l ON l.venue_id = vr.venue_id LEFT JOIN wp_events_locale lc ON lc.id = l.locale_id WHERE e.event_status = ‘A’ AND e.wp_user = ’22’ ) ORDER BY start_date DESC LIMIT 50 OFFSET 0 /* From [stores.athleta.net/wp-admin/admin.php?page=events&action=add_new_event] in [/nas/wp/www/cluster-1063/stores/wp-content/plugins/event-espresso/includes/event-management/event_list.php:222] */


Jim Schuyler

January 16, 2013 at 9:37 pm

I see something that may be helpful. It seems that after upgrading the EE code, there is a variable $group in at least a couple of EE’s PHP files that is created by this inquiry:

$group = get_user_meta(espresso_member_data(‘id’), “espresso_group”, TRUE);

and in our database this variable is a ‘serialized’ string.

At this point $group is a string with this value
a:1:{i:24;s:2:”24″;}

The upgraded EE code expects it to be an array. If I unserialize it, the code runs better.

$group = get_user_meta(espresso_member_data(‘id’), “espresso_group”, TRUE);
if (is_string($group)) {
group = unserialize($group);
}

I did this several places in queries.php and one place in event_list.php and on my staging site I can now create and edit events.

SO: I’m not going to guess at how to fix it. Can you give me some guidance about what might be wrong and how to unmess this situation?


Jim Schuyler

January 16, 2013 at 9:57 pm

One final piece of info here. I see that in “Espresso Permissions Pro” 2.0.5-beta you are unserializing the group data after fetching from the database, so I probably have spotted the issue and can put my fix into EE 3.1.29.P manually. It looks like EE 3.1.29.1.P doesn’t know about the group info being serialized. And perhaps these two versions of the EE plugin and Permissions component cannot coexist?

But it’s a bit of a mystery to me how my group membership data got serialized in the first place…


Jim Schuyler

January 16, 2013 at 10:15 pm

Code correctly unserializes in these files:
/event-espresso/includes/admin-files/functions.php
/event-espresso/includes/admin-reports/event_list_attendees.php
/espresso-permissions-pro/espresso-permissions-pro.php
/espresso-permissions-pro/includes/edit-groups.php

#

Code does not unserialize in:
/event-espresso/includes/admin-files/venue-management/index.php
/event-espresso/includes/event-management/event_list.php
/event-espresso/includes/event-management/queries.php

#

Code uses a function “maybe_unserialize($group)” in:
/event-espresso/includes/functions/export.php

#

Note that this is not a complete list because I don’t use all of the EE plugins. Any anyway, you will be able to grep your entire development code, which I can’t do here.


Josh

  • Support Staff

January 17, 2013 at 8:18 am

Hi Jim,

Thanks for reporting this. I’ve raised a ticket with the dev team.

It’s probably not related to the issue you are reporting here, but the WP user integration version you have installed is several point releases back and should be updated to be compatible with the current version of Event Espresso.

Also if you have the time, I would recommend downloading and checking out the pre-release versions of Event Espresso and the Roles and Permissions add-ons. You can opt in for access to the pre-release versions on your account page, and there is more information about them here:

https://eventespresso.com/topic/announcing-the-pre-release-channel/


Jim Schuyler

January 17, 2013 at 9:36 am

I don’t have a module named “WP user integration” — which one is that? Is it “Espresso-members”? If so, the version I am using today is 1.9.6. I agree it is unrelated, as it does not access the user_meta “espresso_group” at all.

FYI, I went back to look at the 3.1.25.P version of “/event-espresso/includes/event-management/queries.php” in the primary “event-espresso” plugin, and it DOES have the proper unserialize() calls. Same for /event-espresso/includes/event-management/event_list.php” the calls ARE there too in the earlier version. They seem to have been dropped out of version 3.1.29.P.

We were using .25 in our production versions, and upgraded to .29 when we upgraded WP to 3.5 early last week. That’s when this broke.


Jim Schuyler

January 17, 2013 at 10:03 am

The .30 prerelease still has this issue. Since your developers are actively using this code every day, I wonder if there is something wrong with my database? To be more specific, my data has gotten serialized in the database and some of your code is expecting this, but the main plugin is not expecting it. Is it possible that the espresso-members “beta” plugin has serialized it and the .29 and .30 cannot handle it?

I checked our production database and the espresso_group user meta data are all serialized. Like this one:

s:18:”a:1:{i:3;s:1:”3″;}”;


Brent Christensen

  • Support Staff

January 17, 2013 at 10:07 am

Hi Jim,

I haven’t had a chance yet to dig through the EE code to look into this matter but just wanted to drop you a line regarding the “maybe_unserialize” function. That is a WordPress function that takes care of testing whether the passed variable is indeed serialized or not before attempting to unserialize it.

So you can replace :

if (is_string($group)) {
    group = unserialize($group);
}

with:

$group = maybe_unserialize($group);

and you will receive an unserialized array.


Jim Schuyler

January 17, 2013 at 10:37 am

Thanks, yes I looked up the function because I thought it might be useful and found it in WP core. Will use that when I make my local fixes to our production systems tonight.

Viewing 8 reply threads

The support post ‘Database error related to locales’ 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.

Event Espresso