500 Internal Server Error on admin-ajax.php when editing RSVP ticket

Home Forums Ticket Products Event Tickets Plus 500 Internal Server Error on admin-ajax.php when editing RSVP ticket

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1216540
    Scott Anderson
    Participant

    My issue is similar to the problem identified in this thread but the solution there did not solve the problem.

    My client is running Event Tickets Plus with WooCommerce, and also offers some free events with RSVP only. The client reported being unable to edit an existing ticket. Specifically, the issue is with editing a ticket that is only RSVP, no paid (WooCommerce) tickets.

    I tested and found that clicking Edit causes the ticket postbox to gray out for a few seconds, and then nothing else happens. Console indicates a 500 Internal Server Error on the call to admin-ajax.php.

    Turning on WP_DEBUG revealed the following error message:

    PHP Fatal error: Call to a member function get_stock_quantity() on a non-object in /[PATH]/wp-content/plugins/event-tickets-plus/src/Tribe/Commerce/WooCommerce/Main.php on line 1222

    That line reads:

    $actual_stock = wc_get_product( $ticket_id )->get_stock_quantity();

    My thought here is that since there’s no WooCommerce ticket, the wc_get_product() function is returning false/null instead of an object; hence the error.

    I change the line to the following…

    $actual_stock = (wc_get_product( $ticket_id )) ? wc_get_product( $ticket_id )->get_stock_quantity() : 0;

    …and confirmed that it appears to resolve the issue.

    #1217059
    George
    Participant

    Hey Scott,

    I’m really sorry to hear about this fatal—I don’t see this myself, and we’re not seeing other reports of this from other customers, so I’m a bit stumped as to why this is happening.

    I’ve reached out to our developers to see if we can figure out what’s happening here—I will keep this thread updated with news based on what they say and determine.

    I’m glad you’ve got a temporary solution that’s working now—stay tuned for more information on this!

    — George

    #1217317
    Scott Anderson
    Participant

    Hi George,

    Thanks for your reply. I’m not entirely sure what’s going on with the client site. For troubleshooting I set up a partial mirror of the client’s site — that is, I set up a new WordPress site and installed the client’s custom theme and all of their plugins, but for time and logistics reasons I did not copy over all of their content. On my mirror site I could not replicate the issue. (My staging server is also running a different version of PHP than the client’s live server, which might be a factor.)

    Anyway, I went back to the client site and did confirm that the problem was specifically happening only on RSVP-only events, and narrowed it down to this one line of code.

    I would make the suggestion that it would be worth considering adding this change to the plugin even if you’re not able to replicate the problem, because as written it’s assuming that an external (WooCommerce) function is always going to return an object, which in some cases it may not.

    (I should also note that as I wrote it in my original post, the code is not efficient — it’s calling the WooCommerce function twice unnecessarily. I’ve modified my own version to assign its value to a variable and then return the variable in the ternary statement, rather than calling the function again.)

    • This reply was modified 9 years, 3 months ago by Scott Anderson. Reason: Added an additional comment
    #1217950
    George
    Participant

    Hey Scott,

    A developer on our team, Barry, has helped me dive a bit deeper on this, and we’ve indeed identified a bug. It’s tricky to get it to replicate, but is a valid bug nonetheless and I will update this thread when there is a fix available for it.

    There’s no specific ETA for the arrival of that fix yet, but I will post here when there’s news about it! If there’s no post from me, there’s no news—otherwise, stay tuned to this thread to be notified of when a fix is available for the bug you describe.

    Sorry for the trouble! Please let me know if there are any other issues or questions I can try to help with.

    — George

    #1224885
    Nico
    Member

    Hey,

    I’m reaching out to let you know that we just released a fix for this issue. Please update the plugins to version 4.4.1 (4.4.1.1 for The Events Calendar) and let us know if this actually makes the issue right in your site.

    More details on the release → Maintenance Release: The Events Calendar and Event Tickets 4.4.1, plus premium add-ons

    Best,
    Nico

    #1225145
    Scott Anderson
    Participant

    Thanks Nico. I just ran the update and tested it out, and it looks like the problem is fixed. I also reviewed the source code of the updated version and saw essentially my same code edit (the more efficient version) in place.

    Thanks to the team for all of the great work on these plugins!

    #1225279
    George
    Participant

    Thanks for your patience with all of this, Scott!

    Glad to hear things are working again.

    I’ll close this thread for now, but feel free to open a new thread any time if other issues or questions arise.

    Cheers,
    George

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘500 Internal Server Error on admin-ajax.php when editing RSVP ticket’ is closed to new replies.