Support

Home Forums Event Espresso Premium Error with get_most_recent_registration_for_event after update.

Error with get_most_recent_registration_for_event after update.

Posted: April 12, 2023 at 6:23 pm

Viewing 4 reply threads


twcassidy14

April 12, 2023 at 6:23 pm

Hello,

I just updated to 5.0.3.p and I am getting an error on a custom function on my function.php file.

The issue is with this line below:

$registration = $contact->get_most_recent_registration_for_event($post->ID);

The error is this:

Fatal error: Uncaught Error: EE_Attendee::get_most_recent_registration_for_event(): Return value must be of type EE_Registration, null returned
in /occlive-dev-www/wp-content/plugins/event-espresso-core-reg/core/db_classes/EE_Attendee.class.php on line 579

Call stack:

EE_Attendee::get_most_recent_registration_for_event()
wp-content/themes/Mind Works/functions.php:612
my_add_content_event_if_logged_in_registered()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/class-wp-hook.php:332
WP_Hook::do_action()
wp-includes/plugin.php:517
do_action()
wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/content-espresso_events-details.php:48
include()
wp-content/plugins/event-espresso-core-reg/core/helpers/EEH_Template.helper.php:403
EEH_Template::display_template()
wp-content/plugins/event-espresso-core-reg/core/helpers/EEH_Template.helper.php:320
EEH_Template::locate_template()
wp-content/plugins/event-espresso-core-reg/modules/event_single/EED_Event_Single.module.php:349
EED_Event_Single::use_filterable_display_order()
wp-content/plugins/event-espresso-core-reg/modules/event_single/EED_Event_Single.module.php:303
EED_Event_Single::event_details()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-includes/post-template.php:255
the_content()
wp-content/themes/Mind Works/single.php:133
include()
wp-includes/template-loader.php:106
require_once()
wp-blog-header.php:19
require()
index.php:17

I am assuming that this function has changed on the most recent version, but I am not sure how to modify it with the proper parameters for it to work as previously.

Thank you for your help.


Tony

  • Support Staff

April 13, 2023 at 7:38 am

Hi there,

I’ve created a ticket for our developers to investigate this.

In the meantime you can change:

/event-espresso-core-reg/core/db_classes/EE_Attendee.class.php

Line 575 should be something like:

public function get_most_recent_registration_for_event(int $event_id): EE_Registration

Change it to be:

public function get_most_recent_registration_for_event(int $event_id): ?EE_Registration

The ? before the return type allows for it to be null.

Generally, we don’t recommend editing core files at all. However, we will likely include a fix for this in the next update so on this occasion it should be fine.


twcassidy14

April 13, 2023 at 10:25 am

Hi Tony,

Thank you for the prompt response; I went ahead and changed the core code even if it is not recommended. Hopefully, this will be patched in the next update.

Thanks for helping with this!


twcassidy14

April 13, 2023 at 10:25 am

Hi Tony,

Thank you for the prompt response; I went ahead and changed the core code even if it is not recommended. Hopefully, this will be patched in the next update.

Thanks for helping with this!


Tony

  • Support Staff

April 13, 2023 at 2:31 pm

You’re most welcome 🙂

Viewing 4 reply threads

The support post ‘Error with get_most_recent_registration_for_event after update.’ 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