Support

Home Forums Event Espresso Premium Fatal Error when Updating a Published Event back to Draft

Fatal Error when Updating a Published Event back to Draft

Posted: September 23, 2022 at 7:12 am

Viewing 19 reply threads


fuzzyminds

September 23, 2022 at 7:12 am

Hello,

We use EE with many of its add-ons, specifically the WP Users add-on as well. All the EE plugins are at the latest version and the PHP version in our prod is 7.4. Whenever we try to revert a Published Event back to Draft status, the page throws the following error:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to EED_WP_Users_Admin::save_wp_user_event_setting() must be an instance of EE_Event, null given, called in /webroot/www/html/wp-content/plugins/event-espresso-core-reg/admin_pages/events/Events_Admin_Page.core.php on line 1054 and defined in /webroot/www/html/wp-content/plugins/eea-wp-user-integration/EED_WP_Users_Admin.module.php:931
Stack trace:
#0 /webroot/www/html/wp-content/plugins/event-espresso-core-reg/admin_pages/events/Events_Admin_Page.core.php(1054): EED_WP_Users_Admin::save_wp_user_event_setting()
#1 /webroot/www/html/wp-content/plugins/event-espresso-core-reg/core/admin/EE_Admin_Page_CPT.core.php(1025): Events_Admin_Page->_insert_update_cpt_item()
#2 /webroot/www/html/wp-includes/class-wp-hook.php(307): EE_Admin_Page_CPT->insert_update()
#3 /webroot/www/html/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#4 /webroot/www/html/wp-includes/plugin.php(476): WP_Hook->do_action()
#5 /webroot/www/html/wp-includes/post.php(4673): do_action()
#6 /webroo in /webroot/www/html/wp-content/plugins/eea-wp-user-integration/EED_WP_Users_Admin.module.php on line 931

Any help regarding this error, would be greatly appreciated. Specially if this error is specific to our environment.


Tony

  • Support Staff

September 26, 2022 at 5:31 am

Hi there,

So, this is a strange error for a couple of reasons.

We hook into the WP core save_post, doa bunch of checks and additional processing, then call an EE Admin page method _insert_update_cpt_item()

Which again does some additional checks and then calls any callback functions we want to run to update various sections. The fact that you are getting the above error means all of the additional processing worked as expected, and apparently the ‘default’ callbacks all worked but the callback for the WP user integration add-on did not have a valid event passed to it.

Now, it works as expected when I test this (on multiple PHP versions) which is why this is odd.

We filter the above callbacks using:

FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks

So my first question is, do you have any custom code hooking into the above?

If I recall correctly from previous threads, either you or someone on your team is comfortable with PHP, correct?


fuzzyminds

September 26, 2022 at 9:39 am

Thank you for the initial explanation Tony.

Yes we do have a full-stack developer who works with PHP, we are not using the hook you mentioned anywhere. These are the hooks we have customized around:

AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful
AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording
AHEE__Single_Page_Checkout__process_reg_step__attendee_information__process_reg_step

Is it possible that this error is due to a faulty or missing value in the Database? And if so, would removing and reinstalling the WP Users help?


Tony

  • Support Staff

September 29, 2022 at 2:27 am

These are the hooks we have customized around

I don’t think any customization on those hooks would cause this.

Is it possible that this error is due to a faulty or missing value in the Database?

Possibly, but it seems unlikely in this case.

And if so, would removing and reinstalling the WP Users help?

Not with this specific issue, no.

Is this event published publicly or private?


fuzzyminds

September 29, 2022 at 12:05 pm

The problem is occurring with Published Events. And it’s not just one event, but all of the published events bring up this error.


Tony

  • Support Staff

September 29, 2022 at 12:53 pm

Are the events published privately or public?

In the ‘Update Event’ meta box, does it show ‘Privately Published’?


fuzzyminds

September 30, 2022 at 11:24 am

No, they are all public.


fuzzyminds

October 11, 2022 at 5:14 am

This reply has been marked as private.


Tony

  • Support Staff

October 12, 2022 at 7:04 am

My apologies, I should have kept you in the loop here.

I’ve tried everything I can to reproduce this but I’m always getting a valid event from the above code.

I’ve asked our senior developer to see if he can see any reason for this.

Can we add some additional code to the site to debug the above values/queries and see if anything stands out?


fuzzyminds

October 12, 2022 at 7:42 am

Sure Tony, let us know what needs to be added. We’ll run the tests and let you know the outcome.


Tony

  • Support Staff

October 12, 2022 at 5:07 pm

Right above the first line of code you posted above, add this:

$this->_event_model()->show_next_x_db_queries();

That will output the SQL query used by the event model.

You may need to add exit(); right after the snippet of code you posted before the filters run to see the output on the page.

Can you paste the query here, please?


fuzzyminds

October 13, 2022 at 5:39 am

This reply has been marked as private.


Tony

  • Support Staff

October 13, 2022 at 5:57 am

Ok, so that Event ID is indeed 7897, correct?

The event has NOT been trashed, correct?

With a prefix of wp_5_ I assume this is WP Multsite? That query is also using the corect site number for that specific site, correct?

(Apologies for the basic questions but I still can’t reproduce so working through everything I can think of currently)

Can you run SQL queries directly? Using CLI or something like PHPMyAdmin on that database and see if an event is returned when that query is run?


fuzzyminds

October 13, 2022 at 6:38 am

Yes the Event ID is 7897, yes it is a live event.
Yes, it’s a multisite installation. The site number is correct too.

Let me see what I can do about direct querying.


Tony

  • Support Staff

October 13, 2022 at 7:37 am

Actually, another test here.

Have you output $event after the above?

Add var_dump($event); just after the last line ();) of the snippet you included earlier and test again, what is it?


fuzzyminds

October 13, 2022 at 8:48 am

Yes I have already tried that. It brings up nothing. The $event variable is empty.


Tony

  • Support Staff

October 13, 2022 at 1:05 pm

Hmmm, so either the query fails completely or somehow the model is returning a cached value although I can’t see anywhere to cache… and I would then expect to be able to reproduce.

Any luck running the above query directly?


fuzzyminds

October 19, 2022 at 9:34 am

Yes, we ran the query directly. Not just with the event ID mentioned in the above reply, but with all the event IDs which are published. Got the relevant event back as a result each time.

An update on my investigation though:
1) Site Login as an Admin – the first time in a browser(or after cleaning cache/cookies)
2) The Edit Event window – I am working with the same id 7897
3) Set the status to draft, and hit the Update button.
4) The Error shows up.
5) Go Back to the last page, the Edit Event page comes up again and the status is updated despite the error.
6) Publish the event again. Now anytime I revert the Status to Draft, the error DOESNT show up in the same logged in session.
7) When I come back with a fresh session, the Error shows up again at the 4th step.

The above behavior is consistent across all the browsers, and happens each time the same way.


fuzzyminds

October 25, 2022 at 10:43 am

This reply has been marked as private.


Tony

  • Support Staff

November 4, 2022 at 4:33 am

Hi there,

I’ve literally tried every possible combination I can think of to try and reproduce this.

I’ve used Chrome, FireFox, Brave and IE to run the same tests, clear cache and all data (in all browsers except Chrome) and run through the same tests you mentioned.

However, I still don’t get a fatal error here.

I’ve also asked another member of the team to test the same steps on a couple of their test sites and again no issues.

I can’t think of any reason why a clear session would cause no EE_Event to be returned above and I’ve asked our senior developer for anything they can think of, he’s just as baffled as me as to why a clean session would cause this (he also tried do to reproduce but again can’t).

As you are the only user reporting this and none of us can reproduce on various different servers (we all have our own different testing environments and some shared) it points to ‘something’ specific to your site/setup however I can’t even take a guess as to what that would be currently.

Unfortunately, I’m lost with this one, the session state should matter and without being able to reproduce somewhere it’s really difficult to troubleshoot.

Viewing 19 reply threads

The support post ‘Fatal Error when Updating a Published Event back to Draft’ 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