• Resolved oghnia

    (@oghnia)


    I get the following error message when I click on Add new location

    Fatal error: Cannot use object of type WP_Error as array in /home//public_html/wp-content/plugins/restaurant-reservations/includes/MultipleLocations.class.php on line 148

    very weird,, any idea what could cause this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @oghnia,

    That’s pointing to a problem with this line of code:

    https://github.com/NateWr/restaurant-reservations/blob/master/includes/MultipleLocations.class.php#L148

    It seems that wp_insert_term() is returning a WP_Error instance and I haven’t properly checked for that case.

    Are you comfortable working with PHP code? If so, could you print out the the $term variable right before that line:

    `php
    var_dump( $term );
    `

    And then post the result here?

    That will help me identify why the term insertion is failing. My best guess is that there’s maybe an existing term in the database already that’s identical. Do you already have a location with this name that’s listed on the Bookings page dropdown?

    I’ve filed an issue to fix the fatal error in the development repo. You can follow progress here:

    https://github.com/NateWr/restaurant-reservations/issues/91

    But ideally we’d track down the source of the wp_insert_error issue and find a workaround.

    Thread Starter oghnia

    (@oghnia)

    i did what you asked me to do and here is what we have….

    object(WP_Error)#6911 (2) { ["errors"]=> array(1) { ["term_exists"]=> array(1) { [0]=> string(62) "A term with the name provided already exists in this taxonomy." } } ["error_data"]=> array(1) { ["term_exists"]=> int(15) } }

    Thread Starter oghnia

    (@oghnia)

    I also deleted all the listings in there,, I have nothing in the list of locations…

    Thanks for the error message @oghnia. This appears to be an issue with the auto-save functionality in WordPress, coupled with poor error handling in my plugin.

    I’m currently trying to track down the source of the problem (maybe a change in behaviour in 4.7, maybe a recent update to Restaurant Reservations). But I expect to get a fix for this out soon.

    You can track the status here:

    https://github.com/NateWr/restaurant-reservations/issues/91

    If you’re comfortable working with PHP, you can add a quick workaround by adding the following code above this line.

    
    if ( $post->post_title === 'Auto Draft' ) {
      return;
    }
    

    Bare in mind Auto Draft might be different if you run WordPress in a language other than English. This should only be a temporary fix until I can figure out the source of the issue.

    Thread Starter oghnia

    (@oghnia)

    Thanks, I am available to create new locations but I see a new problem…
    I have 2 business locations, and I have them listed there but the instead of just seeing 2 locations I see 3 options in select location drop down, and the first option is called “Auto Draft”!!!

    Hi @oghnia,

    Yes, unfortunately this is a side-effect of the bug. I’m going to try to build in something to automatically fix this in my next update. Just don’t assign any bookings to it until then if you can.

    I’m hoping to get it sorted out and released in the next day or two.

    HI @oghnia,

    I’ve just released an update to Restaurant Reservations that fixes this issue. It also makes an attempt to remove any auto-draft locations that have been added due to the bug.

    If any bookings have been added to an auto-draft location, though, it will simply archive the location in the bookings list rather than remove it entirely. Either way, customers should no longer be able to book that location.

    Sorry for the unfortunate bug here. Hopefully v1.7.1 of Restaurant Reservations cleans everything up for you. Please let me know if you have any problems with that.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error message when Adding a new location’ is closed to new replies.