Support

Home Forums Event Espresso Premium Event Espresso Core breaks Learndash subscription products

Event Espresso Core breaks Learndash subscription products

Posted: June 13, 2023 at 12:13 pm

Viewing 7 reply threads


aaronsingler

June 13, 2023 at 12:13 pm

Clear detail of issue we are experiencing here: https://www.loom.com/share/5838b743cb5145d683e2a049e3db82e6

We’ve had this site for a few years now. Recently the Event Espresso core plugin has caused woocommerce subscription products to break. Specifically, they are causing Subscription Products with LearnDash group registration to break. Though we have ‘show errors’ turned on, no error is given on the broken page. Turning EventEspress plugin off fixes the product issue. However, trying to turn the plugin fails with error:
“Fatal error: Uncaught Error: Call to undefined method Appsero\Insights::add_plugin_data() in /home/devpwacademy/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/wp-graphql.php:78 Stack trace: #0 /home/devpwacademy/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/wp-graphql.php(81): graphql_init_appsero_telemetry() #1 /home/devpwacademy/public_html/wp-content/plugins/event-espresso-core-reg/espresso.php(98): require_once(‘/home/devpwacad…’) #2 /home/devpwacademy/public_html/wp-admin/includes/plugin.php(2314): include_once(‘/home/devpwacad…’) #3 /home/devpwacademy/public_html/wp-admin/plugins.php(192): plugin_sandbox_scrape(‘event-espresso-…’) #4 {main} thrown in /home/devpwacademy/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/wp-graphql.php on line 78”.

Where can I get older versions of EventEspresso core to test? And how the heck do I fix this issue?


Tony

  • Support Staff

June 13, 2023 at 1:35 pm

Hi there,

So you mentioned you have ‘show_errors’ disabled and that no error is displayed, however when I navigate to the page in your video I can see this:

There has been a critical error on this website.

At the bottom of the page.

That will only happen if a PHP fatal error is thrown and those are usually saved within your PHP error logs. If you open your servers PHP error log and search for ‘Fatal error’ around the same time match when you load the above page it should give you some details.

Or, another option is to use this:

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

That snippet goes within your site’s wp-config.php file and replaces what will likely just be:

define( 'WP_DEBUG', true );

What that will do is then store errors within /wp-content/debug.log

So if you let me know when that has been added to the site I can retest and check for the error.

I can send you a copy of 4.10.46 which should get the site working again within EE but we need the above error know what what is happening on the site to be able to troubleshoot further (otherwise your just stuck on that version).


aaronsingler

June 14, 2023 at 9:58 am

Yes please send me a copy of 4.10.46

For logs:
Fatal errors log –
2023-06-13T15:26:24+00:00 CRITICAL Uncaught TypeError: Argument 4 passed to WPGraphQL\Utils\Preview::filter_post_meta_for_previews() must be of the type bool or null, array given, called in /home/pwaadmin/public_html/wp-includes/class-wp-hook.php on line 310 and defined in /home/pwaadmin/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/src/Utils/Preview.php:23
Stack trace:
#0 /home/pwaadmin/public_html/wp-includes/class-wp-hook.php(310): WPGraphQL\Utils\Preview::filter_post_meta_for_previews(NULL, 4625, ‘ldgr_dynamic_co…’, Array)
#1 /home/pwaadmin/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array)
#2 /home/pwaadmin/public_html/wp-includes/meta.php(633): apply_filters(‘get_post_metada…’, NULL, 4625, ‘ldgr_dynamic_co…’, Array, ‘post’)
#3 /home/pwaadmin/public_html/wp-includes/meta.php(572): get_metadata_raw(‘post’, 4625, ‘ldgr_dynamic_co…’, Array)
#4 /home/pwaadmin/public_html/wp-includes/post.php(2492): get_metadata(‘post’, 4625, ‘ldgr_dynamic_co…’, Array)
#5 /home/pwaadmin/ in /home/pwaadmin/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/src/Utils/Preview.php on line 23

Error is outputing on page now. Is the same:
Fatal error: Uncaught TypeError: Argument 4 passed to WPGraphQL\Utils\Preview::filter_post_meta_for_previews() must be of the type bool or null, array given, called in /home/pwaadmin/public_html/wp-includes/class-wp-hook.php on line 310 and defined in /home/pwaadmin/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/src/Utils/Preview.php:23 Stack trace: #0 /home/pwaadmin/public_html/wp-includes/class-wp-hook.php(310): WPGraphQL\Utils\Preview::filter_post_meta_for_previews(NULL, 4625, ‘ldgr_dynamic_co…’, Array) #1 /home/pwaadmin/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array) #2 /home/pwaadmin/public_html/wp-includes/meta.php(633): apply_filters(‘get_post_metada…’, NULL, 4625, ‘ldgr_dynamic_co…’, Array, ‘post’) #3 /home/pwaadmin/public_html/wp-includes/meta.php(572): get_metadata_raw(‘post’, 4625, ‘ldgr_dynamic_co…’, Array) #4 /home/pwaadmin/public_html/wp-includes/post.php(2492): get_metadata(‘post’, 4625, ‘ldgr_dynamic_co…’, Array) #5 /home/pwaadmin/ in /home/pwaadmin/public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/src/Utils/Preview.php on line 23


Garth

  • Support Staff

June 15, 2023 at 10:08 am

This reply has been marked as private.


aaronsingler

June 15, 2023 at 10:24 am

It seems the error is an issue with the WPGraphQL plugin and its interaction with the EventEspresso plugin. Specifically, it appears that the filter_post_meta_for_previews() method in the WPGraphQL\Utils\Preview class is expecting a boolean or null value for the fourth argument ($single), but an array is being passed instead.

To resolve this error, I modified the code for /public_html/wp-content/plugins/event-espresso-core-reg/vendor/wp-graphql/wp-graphql/src/Utils/Preview.php as follows:

public static function filter_post_meta_for_previews($default_value, int $object_id, ?string $meta_key = null, $single = false)
{
$resolve_revision_meta_from_parent = apply_filters(‘graphql_resolve_revision_meta_from_parent’, true, $object_id, $meta_key, $single);

if (false === $resolve_revision_meta_from_parent) {
return $default_value;
}

$post = get_post($object_id);

if (!$post instanceof \WP_Post) {
return $default_value;
}

if (‘revision’ === $post->post_type) {
$parent = get_post($post->post_parent);
$meta_key = !empty($meta_key) ? $meta_key : ”;

return isset($parent->ID) && absint($parent->ID) ? get_post_meta($parent->ID, $meta_key, (bool)$single) : $default_value;
}

return $default_value;
}

This isn’t ideal as the next updates will wipe it out. Also, further updates may have more conflicts with the changed code. Hopefully, this will help the EE developers come up with a fix. I purchased the ‘support ticket’, but not sure how to communicate directly with them.


aaronsingler

June 15, 2023 at 11:13 am

Also, downgrading back to 4.10.46 fixes the issue as well.


Rio

  • Support Staff

June 15, 2023 at 8:46 pm

Good to hear everything is fine now. If you need anything, feel free to reach us again.

thanks


Tony

  • Support Staff

June 20, 2023 at 4:59 pm

Hi there,

Although the error being thrown is indeed from the WPGraphQL plugin within Event Espresso, the problem here is not with that plugin itself.

The method you’ve mentioned above is indeed setting a type declaration of null or bool on the 4th parameter passed to filter_post_meta_for_previews like so:

public static function filter_post_meta_for_previews( $default_value, int $object_id, ?string $meta_key = null, ?bool $single = false ) {

Then it’s hooking that function into the WP core hook get_post_metadata

That hook is a dynamic hook (get_{$meta_type}_metadata) and whilst the documentation for that hook states its parameter types:

https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/

There is nothing within the WP core code itself to set those:

https://github.com/WordPress/wordpress-develop/blob/6.2/src/wp-includes/meta.php#L633-L633

Notice how that filter is within get_metadata_raw() and whatever is passed to that function’s parameters is just used as is, that means something on your site is calling get_metadata_raw() and passing an array as the 4th parameter which isn’t expected.

So then filter_post_meta_for_previews hooks into that method call and throws a fatal because of its type declarations, which are correct for the WP documentation. So the problem is something is setting $single to be an array, not that WPGraphQL then throws a fatal.

The reason this doesn’t happen with 4.10.46 is v5+ introduced WPGraphQL, it was not used in v4 so then WPGraphQL wasn’t hooking into get_post_metadata etc etc.

Do you have a local copy of the site in which you can open the whole site within an editor/ide and search for a call to get_metadata_raw(? (You shouldn’t get many results as generally get_metadata_raw isn’t called directly)

These kinds of issues are going to come up more and more as plugins introduce stricter typing and proper type declarations. They are a good thing, but because PHP has been so lax with its typing for so long stuff like this happens.

Viewing 7 reply threads

The support post ‘Event Espresso Core breaks Learndash subscription products’ 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