Support

Home Forums Event Espresso Premium Issues after upgrading from 4.8.25.p to 4.9.56.p

Issues after upgrading from 4.8.25.p to 4.9.56.p

Posted: February 7, 2018 at 7:47 pm


Lyon

February 7, 2018 at 7:47 pm

I’ve just updated the EE4 plugin on my website and the following message appeared in a floating box in front of the “50 rows written to csv…” messages.

[weird message start]
The following errors have occurred:
There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.
There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.
[weird message end]

It only appeared once during the first time I tried to perform a Registration details export. Subsequently, it didn’t show up again. I checked the Plugins page and found that EE was not deactivated like the weird message said.

I’ve been going around testing the various functions we use most often and they seem to be working ok so far.

1) Is there any way to know what exactly happened that made those messages appear? WP_DEBUG was not true as this is our live website.
2) How do I find out if there is an actual problem with the database tables that will cause issues down the road?
3) Checking the exported CSV file, it was found that the UTF8 encoding bytes are missing. The resulting file opens up in Excel but all unicode characters are rendered as ‘garbage’. Manually adding the UTF8 encoding bytes into the file makes it open properly. What would cause this?
4) Regarding the same exported CSV file, a custom column I added is missing it’s header name now. It worked perfectly before upgrading but now the header name refuses to show up. The data for the custom (post meta) column is still exported just fine, though. Code used is as follows:

add_filter( ‘FHEE__EE_Export__report_registrations__reg_csv_array’, ‘espresso_add_course_id_csv’, 10, 2);
function espresso_add_course_id_csv( $reg_csv_array, $reg_row ) {
// get the event’s ID
$event_id = $reg_row[ ‘Registration.EVT_ID’ ];
// example of getting the post meta
$my_course_id = get_post_meta( $event_id, ‘my_course_id’, true );
if ( $my_course_id != ” ) {
$reg_csv_array[ ‘Course ID’ ] = $my_course_id;
}
return $reg_csv_array;
}

PLEASE HELP!


Lyon

February 8, 2018 at 1:05 am

Does anyone know how to fix the issue of missing UTF8 bytes in the CSV export file?


Tony

  • Support Staff

February 8, 2018 at 4:28 am

Hi there,

1) Is there any way to know what exactly happened that made those messages appear? WP_DEBUG was not true as this is our live website.

If your server logs errors (it should) then you may find the error within that.

Usually, your host will have a section to view the error logs within your control panel, or if you have FTP access look for an error_log file within the root directory for your site.

2) How do I find out if there is an actual problem with the database tables that will cause issues down the road?

We need the error to know if there is actually a problem but EE will attempt to fix any issues with the DB as it finds them anyway, if there is a problem that couldn’t be fixed you would see an error on each request made.

If your server is not logging error you can temporarily add this snippet:

https://eventespresso.com/wiki/troubleshooting-checklist/#wpdebug

To your wp-config.php file and re-run some tests on the system (try exporting the registrations again), any errors will be logged to /wp-content/debug.log and not shown directly on the site.

(Note don’t leave that enabled on your live server, just run some tests and see if you find any errors from EE in the log, then remove it again or set WP_Debug back to false)

3) Checking the exported CSV file, it was found that the UTF8 encoding bytes are missing. The resulting file opens up in Excel but all unicode characters are rendered as ‘garbage’. Manually adding the UTF8 encoding bytes into the file makes it open properly. What would cause this?

Are you filtering the CSV using the FHEE__EE_CSV__begin_sending_csv__start_writing at all?

The first output sent to the CSV uses this:

echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" );

Which should set the file to UTF-8, what are you adding to the beginning of the CSV to force it to work?

4) Regarding the same exported CSV file, a custom column I added is missing it’s header name now. It worked perfectly before upgrading but now the header name refuses to show up. The data for the custom (post meta) column is still exported just fine, though.

I’d recommend you set the column on each row regardless of whether or not you actually assign a value to it.


$reg_csv_array[ 'Course ID' ] = '';
$my_course_id = get_post_meta( $event_id, 'my_course_id', true );
if ( $my_course_id != '') {
$reg_csv_array[ 'Course ID' ] = $my_course_id;
}

Have you confirmed that get_post_meta() is pulling in a value?


Lyon

February 8, 2018 at 6:24 am

Hello,

Usually, your host will have a section to view the error logs within your control panel, or if you have FTP access look for an error_log file within the root directory for your site.

I’ve had a look at the error_log file and the last entry seems to be in Nov 2017 so I’m not sure if it is actively logging or not.

Are you filtering the CSV using the FHEE__EE_CSV__begin_sending_csv__start_writing at all?

I’m not using that filter. Just the one in the code snippet I pasted.

Which should set the file to UTF-8, what are you adding to the beginning of the CSV to force it to work?

I have not added anything to the CSV at all. The CSV export used to work just fine before I upgraded to 4.9.56.p. The old EE4 produced CSV files with the UTF8 marker intact. The only custom code in my site plugin to do with CSV is what I pasted in my original post.

I’d recommend you set the column on each row regardless of whether or not you actually assign a value to it.

I don’t understand this part of your reply. Can you explain it?

Have you confirmed that get_post_meta() is pulling in a value?

The upgraded EE4 gives me CSV files with the values I expect for each row in the custom column. So I assume get_post_meta() is doing its job.

It’s just the custom column header that’s missing. It used to export complete with “Course ID” as the header, but not now after upgrade.


Tony

  • Support Staff

February 8, 2018 at 7:30 am

I’ve had a look at the error_log file and the last entry seems to be in Nov 2017 so I’m not sure if it is actively logging or not.

Unfortunately, without the error, we don’t know what happened. You can check over the database to confirm all of the required tables/columns have been created, but, as mentioned EE will attempt to fix it anyway so its unlikely any will be missing otherwise you’d still be getting the errors above.

I have not added anything to the CSV at all.

You mentioned above you’re manually adding the amending the CSV to make it work, I’m assuming you’re adding the same as the filter above?

I don’t understand this part of your reply. Can you explain it?

In your code, you only set $reg_csv_array[ ‘Course ID’ ] if you have a value for $my_course_id;

In 4.8.25 EE pulled all of the registrations in a single request and then built the CSV, this is fine for smaller registrations but not larger groups, so we introduced a ‘batch’ method that pulls in smaller groups (default 50) of registrations into a temp file and build out the CSV as we go.

So let’s say the first batch of registrations don’t have a value for $my_course_id, you’ve just built out the temp file containing all of the details without a Course ID header. The next batch doesn’t know where to include the data. Whereas if you use the code example I gave you above, the column is always created for each registration row, but it’s empty if you don’t have a value.

Try this code:

https://gist.github.com/Pebblo/5c829126cdc85ab942db3d880e84cc91


Lyon

February 11, 2018 at 10:36 pm

Thanks for the tip regarding the new batch method and the code sample. I’ve modified my site specific code to add in the Course ID header successfully!

You mentioned above you’re manually adding the amending the CSV to make it work, I’m assuming you’re adding the same as the filter above?

I mean I was modifying the downloaded CSV file and inserting the bytes manually. I just assumed that since the EE4.8.25.p generated CSV files opened up properly before, and I haven’t changed my site specific code, that the CSV files generated by EE4.9.56.p should still work fine.

I dug around the EE4 code a bit and found that EE4.9.56.p doesn’t seem to be using the EE_Export & EE_CSV classes to output the Registrations report any longer (at least this is true for exporting All Registrations). It seems to just use WP_Filesystem_Base classes via EEH_File to output the CSV directly without the UTF8 BOM.


Tony

  • Support Staff

February 12, 2018 at 2:19 pm

Hmm, yeah you’re right.

We’ll need to do some investigating into this, but for the time being what you can do is switch EE back to the ‘old’ export system.

To do that you just need to add:

define('EE_USE_OLD_CSV_REPORT_CLASS', true);

To your wp-config.php file, somewhere above the /* That's all, stop editing! Happy blogging. */ line. Having that in your config file tells EE to use exactly the same process you were using before and ignores the batch method (your new custom code above should still work absolutely fine).

The support post ‘Issues after upgrading from 4.8.25.p to 4.9.56.p’ 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