• Resolved Jose

    (@yeahthatguyjose)


    Hey there,

    Below is the message I keep getting when I update a event or trashing a event.

    Warning: Illegal string offset 'term_id' in /homepages/12/d207939151/htdocs/wp-includes/functions.php on line 2657
    
    Warning: Illegal string offset 'term_id' in /homepages/12/d207939151/htdocs/wp-includes/functions.php on line 2657
    
    Warning: Cannot modify header information - headers already sent by (output started at /homepages/12/d207939151/htdocs/wp-includes/functions.php:2657) in /homepages/12/d207939151/htdocs/wp-includes/pluggable.php on line 876

    I’ve got a development site set up and it seems to be working fine with no erros. We migrate the site to 1and1 and we are experiencing this error. The funny issue though is the execution does run, so when I hit update it updates but I get that error page. I don’t know what can cause this. And I just updated to the latest version. Any ideas?

    https://www.ads-software.com/extend/plugins/event-organiser/

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    Hi Jose,

    Have you tried disabling all other plug-ins. The reason I ask is because the error message is being triggered by the wp_list_pluck() function, with the second argument being term_id.

    Event Organiser only uses wp_list_pluck() and term_id in one instance – and that is when its displaying a map of venue(s). This shouldn’t be called when updating an event, so its unlikely this is the cause. Which means it might be another plug-in, or the theme.

    Thread Starter Jose

    (@yeahthatguyjose)

    Hi Stephen,

    I had a similar issue that posted not long ago. The issue was that I had user restrictions that was causing the calendar not to load, you can see here.

    I’m currently going to put the site in maintenance mode to test out the plugins because I can’t seem to replicate the problem in our development server. But I’m guessing the issue will be caused from my theme. I’m using starkers naked theme – I’m linking my functions file here.

    I really appreciate you helping me out, thanks!

    Thread Starter Jose

    (@yeahthatguyjose)

    It’s funny, I installed WP Maintenance Mode and when I try to update the events it works fine. When I installed Maintenance Mode plugin it was giving me the original error.

    I deactivated all the plugins one by one and I was still getting the error. What in my theme can cause this? I wouldn’t know where to start in my theme.

    Plugin Author Stephen Harris

    (@stephenharris)

    Easiest way to find out what’s causing it…

    Find wp_list_pluck() in includes/functions.php. ( See source ). Between lines 2653-2654 (as indicated put the following:

    if( 'term_id' == $field && !isset( $value[ $field ] ) ){
              echo wp_debug_backtrace_summary();
              wp_die('');
        }

    What does this do? The error is caused when wp_list_pluck() is called to with $field set to ‘term_id’ – but an element in the passed array does not contain that as a key. This checks for such a situation and then prints the trace: this indicates which function it was called by, and which function called that, and so on.

    You should see a series of function/method names indicating the sequence in which the functions were called.

    wp_die() kills the process so we don’t loose the trace with a page redirect or something.

    Thread Starter Jose

    (@yeahthatguyjose)

    I inserted the snippet you gave me, not sure if I inserted it correctly but I’m getting a page error.

    Warning: Invalid argument supplied for foreach() in /homepages/12/d207939151/htdocs/wp-includes/post.php on line 1554
    
    Warning: Invalid argument supplied for foreach() in /homepages/12/d207939151/htdocs/wp-content/plugins/wordpress-seo/admin/class-metabox.php on line 56
    include('wp-admin/edit-form-advanced.php'), wp_enqueue_media, wp_list_pluck

    I’m pretty sure I did that wrong.

    Plugin Author Stephen Harris

    (@stephenharris)

    wp_enqueue_media() does call wp_list_pluck (see source), but not with ‘field_id’…

    You might want to check your install’s wp_enqueue_media() function.

    Thread Starter Jose

    (@yeahthatguyjose)

    Couldn’t find anything on it. I tried uninstalling the plugin and reinstall it for a clean install but I get this error as I try to uninstall it
    Fatal error: Call to undefined function eventorganiser_uninstall_install() in /homepages/12/d207939151/htdocs/wp-content/plugins/event-organiser/includes/event-organiser-install.php on line 328

    Plugin Author Stephen Harris

    (@stephenharris)

    Hi Jose,

    Yup, sorry thats a known error, I’ll be fixing it shortly. Replacing every instance of ‘eventorganiser_uninstall_install’ in that file with eventorganiser_uninstall_site() will resolve it.

    Thread Starter Jose

    (@yeahthatguyjose)

    Hi Stephen,

    I hate to admit this but I found the problem to the issue I was having. I named my WordPress theme folder “Main Theme” and changed it to “theme” and I’m guessing having that space somehow threw it off and now it’s working. Pretty crazy!

    We live and learn! Thank you again for your help.

    I’m having the same error show up (works in dev, but newer version of PHP gives the fits when saving an Event), and when I put in your debug code, I see:

    edit_post, wp_update_post, wp_insert_post, wp_transition_post_status, do_action(‘transition_post_status’), call_user_func_array, _update_term_count_on_transition_post_status, wp_get_object_terms, apply_filters(‘wp_get_object_terms’), call_user_func_array, _eventorganiser_get_event_venue, eventorganiser_update_venue_meta_cache, wp_list_pluck

    I did a project-wide search for wp_list_pluck, and I only see Event Organiser using it among my plugins. This seems to be the culprit in eventorganiser_update_venue_meta_cache():

    ~/wp-content/plugins/event-organiser/includes/event-organiser-cpt.php:
      762
      763  		//TODO Sort this out when $terms is an array of IDs not objects.
      764: 		$term_ids = wp_list_pluck($terms,'term_id');
      765
      766     		update_meta_cache('eo_venue',$term_ids);
    Plugin Author Stephen Harris

    (@stephenharris)

    Hi natebeaty,

    Yes, I realised that the bug is in EO the other day. I didn’t have time to fix it, that’s the reason for the comment

    >//TODO Sort this out when $terms is an array of IDs not objects.

    I believe that’s what is causing the issue. Its not a vital function so as an immediate workaround you can safely cut outs off its body,so that all it does return $terms;

    Hopefully will get this fixed soon.

    I did a quick fix testing if $terms is an associative array using a function noted on Stack Overflow:

    function isAssoc($arr) {
        return array_keys($arr) !== range(0, count($arr) - 1);
    }

    And then in event-organiser-cpt.php:

    if (isAssoc($terms)) {
    	$term_ids = wp_list_pluck($terms,'term_id');
    } else {
    	$term_ids = $terms;
    }

    This seems to work for now. Thanks for the quick response.

    Plugin Author Stephen Harris

    (@stephenharris)

    Awesome, thank you! Will fix this in the next release.

    Plugin Author Stephen Harris

    (@stephenharris)

    Actually, regardless the array should not be associative… What needs to be checked is if the array contains integers or objects

    Perhaps this would work?

    // check if only objects in array
    if (array_filter($terms,'is_object')===$terms) {
    	$term_ids = wp_list_pluck($terms,'term_id');
    } else {
    	$term_ids = $terms;
    }

    I’m not sure of the context of that function, where it’s being used throughout the plugin. Just a quick idea.

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Getting error messages when updating or deleting a event’ is closed to new replies.