Support

Home Forums Event Espresso Premium EE broken after server was updated to PHP 7.4.27

EE broken after server was updated to PHP 7.4.27

Posted: January 26, 2022 at 5:11 pm


SeaLight

January 26, 2022 at 5:11 pm

I’m getting a critical error on an event page. This only happened after our host SiteGround updated the PHP for all servers from 7.2 to 7.4.27. The website where the error is: https://www.paws-itiveexperience.com/events-and-classes/ The PHP error log says Fatal error: Uncaught Error: [] operator not supported in strings in /home/customer/www/paws-itiveexperience.com/public_html/wp-content/uploads/espresso/templates/espresso-events-table-template.template.php:72

The customer service rep said to reach out to the plugin support and ask if the plugin is configured to work with PHP 7.4 and WP 5.9.


Tony

  • Support Staff

January 27, 2022 at 3:25 am

Hi there,

Yes, Event Espresso is fully compatible with PHP7.

The error you are getting is from a custom template you are loading from /wp-content/uploads/espresso/templates/

The espresso-events-table-template.template.php template, line 72.

That’s likely the same issue as posted here: https://eventespresso.com/topic/fatal-error-ee4-with-php-7-1/

It’s a custom template from an older version of the Table View Template add-on which has been copied to the above location and now needs to be updated as explained in the above thread, that should fix it for you.


SeaLight

January 27, 2022 at 4:35 am

Ok thanks Tony. I’ll give this a try shortly and report back. Hopefully it’s the same adjustment to the line.


Tony

  • Support Staff

January 27, 2022 at 4:36 am

The line numbers are different but it should be the same change.

Depending on what your custom template is doing you may be best grabbing the latest version of that template from the Events Table template and either updating your custom template with any changes from it… or, (again depending on what has changed) alter that version to customize the output to suit.


SeaLight

January 27, 2022 at 5:11 am

Perfect. Thank you for that info!


SeaLight

January 27, 2022 at 7:37 am

On line 72 it had $category_slugs[] = $term->slug; and I changed it to $category_slugs = array(); like the other article said and that fixed it. Thanks so much!


Tony

  • Support Staff

January 27, 2022 at 9:50 am

That doesn’t seem correct.

$category_slugs[] = $term->slug; is setting the $category_slugs[] next array element to be a string from $term-slug;, meaning its setting the value to use later.

That’s ‘fixing’ it because you are no longer using $category_slugs as an array, but setting it as an array.

Somewhere above that line, do you have $category_slugs = ''; (setting up the $category_slugs var up as a string) anywhere?


SeaLight

January 27, 2022 at 9:57 am

Correct. This is what it is:

	<?php
	// Start the Loop.
	while ( have_posts() ) : the_post();
		// Include the post TYPE-specific template for the content.
		global $post;
		//Debug
		//d( $post );
		
		//Get the category for this event
		$event = EEH_Event_View::get_event();
		if ( $event instanceof EE_Event ) {
			if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
				// loop thru terms and create links
				$category_slugs = '';
				foreach ( $event_categories as $term ) {
					$category_slugs = array();
				}
				$category_slugs = implode(' ', $category_slugs);
			} else {
				// event has no terms
				$category_slugs = '';
			}
		}


SeaLight

January 27, 2022 at 9:59 am

Possibly it’s worth it to simply grab the updated template and see if that works better? If so, where can I download the new one you mentioned?

Depending on what your custom template is doing you may be best grabbing the latest version of that template from the Events Table template and either updating your custom template with any changes from it… or, (again depending on what has changed) alter that version to customize the output to suit.


Tony

  • Support Staff

January 27, 2022 at 10:14 am

Changing this line:

<code>$category_slugs = array();</code>

Back to what it was....

<code>$category_slugs[] = $term->slug;</code>

Then change this:

// loop thru terms and create links
$category_slugs = ”;`

To be:

// loop thru terms and create links
$category_slugs = array();

That fixes the problem, your above change stops the error but doesn’t fix it.

Possibly it’s worth it to simply grab the updated template and see if that works better? If so, where can I download the new one you mentioned?

It’s from the Event Tables View Template add-on which you can download from your account.

You already have it installed on the site, although it may not be the latest version (v1.3.9.p) so you can grab the template from there if you want. You open the add-on (either download it or use FTP to view the files on your server) and its in eea-events-table-view-template/templates/

Filename is espresso-events-table-template.template.php


SeaLight

January 27, 2022 at 10:29 am

Excellent thanks! I had some other customization in there for start/end classes that I can’t figure out how to add that to the v1.3.9.p so I just changed out what you said. Thank you.

		//Get the category for this event
		$event = EEH_Event_View::get_event();
		if ( $event instanceof EE_Event ) {
			if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
				// loop thru terms and create links
				$category_slugs = array();
				foreach ( $event_categories as $term ) {
					$category_slugs[] = $term->slug;
				}
				$category_slugs = implode(' ', $category_slugs);
			} else {
				// event has no terms
				$category_slugs = '';
			}
		}


Tony

  • Support Staff

January 28, 2022 at 3:31 am

That’s better 🙂

So if the current template you have is working for you there is no need to pull in the latest version, it does add a couple of additional features to the template but nothing major, so if what you have works for you then it will be fine.


SeaLight

January 31, 2022 at 7:30 am

Ok perfect thank you!


Tony

  • Support Staff

January 31, 2022 at 7:40 am

You’re most welcome 🙂

The support post ‘EE broken after server was updated to PHP 7.4.27’ 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