Skip to:
Content
Pages
Categories
Search
Top
Bottom

500: post_status no array


  • tweichart
    Participant

    @tweichart

    Hey guys,

    I get a 500 error after the latest update:

    
    AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: [] operator not supported for strings in /var/www/vhosts/<url>/wp-content/plugins/bbpress/includes/forums/functions.php:1800
    Stack trace:
    #0 /var/www/vhosts/<url>/wp-includes/class-wp-hook.php(298): bbp_pre_get_posts_normalize_forum_visibility(Object(WP_Query))
    #1 /var/www/vhosts/<url>/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)
    #2 /var/www/vhosts/<url>/wp-includes/plugin.php(515): WP_Hook->do_action(Array)
    #3 /var/www/vhosts/<url>/wp-includes/class-wp-query.php(1681): do_action_ref_array('pre_get_posts', Array)
    #4 /var/www/vhosts/<url>/wp-includes/class-wp-query.php(3238): WP_Query->get_posts()
    #5 /var/www/vhosts<url>/wp-includes/class-wp.php(617): WP_Query->query(Array)
    #6 /var/www/vhosts/<url>/wp-includes/clas...'
    

    ln 1800 looks like this:

    
    $post_stati = $posts_query->get( 'post_status' );
    
    // Default to public status
    if ( empty( $post_stati ) ) {
        $post_stati[] = bbp_get_public_status_id();
    
    // Split the status string
    } elseif ( is_string( $post_stati ) ) {
        $post_stati = explode( ',', $post_stati );
    }
    

    could be fixed by forcing the array:

    
    $post_stati = $posts_query->get( 'post_status' );
    if (!is_array($post_stati)){
        $post_stati = array($post_stati);
    }
    
    // Default to public status
    if ( empty( $post_stati ) ) {
        $post_stati[] = bbp_get_public_status_id();
    
    // Split the status string
    } elseif ( is_string( $post_stati ) ) {
        $post_stati = explode( ',', $post_stati );
    }
    

    side note: wp version 4.7.4, bbpress version 2.5.12

    Thanks in advance,
    Toby

Viewing 15 replies - 1 through 15 (of 15 total)

  • Robin W
    Moderator

    @robin-w

    Suspect you are using php 7.1

    so 3 fixes
    1. downgrade to a lesser version of php
    2. upgrade to bbpress 2.6beta-2
    3. in bbpress 2.5.12 change line 1851 from
    $meta_query = $posts_query->get( ‘meta_query’ );
    to
    $meta_query = $posts_query->get( ‘meta_query’, array() );
    Since the next upgrade will fix that anyway, no issue in changing the bbpress file
    best I can offer I’m afraid


    Barry
    Participant

    @barryhughes-1

    I find it just a little disconcerting that this problem has been in the wild – stopping, for example, new users of the plugin from being able to set anything up – for almost 6 months now …


    Robin W
    Moderator

    @robin-w

    2.5.13 will apparently be release shortly that will fix this.


    tweichart
    Participant

    @tweichart

    Thanks for the hotfix, as long as it’s fixed with the next update I’m fine 😉


    tweichart
    Participant

    @tweichart

    sorry to come back on this, just did an update to 2.5.13, error persists, fatal error came back due to my local hotfix being kicked out…


    Robin W
    Moderator

    @robin-w

    didn’t know that 2.5.13 had been released, where did you get a copy?


    tweichart
    Participant

    @tweichart

    i don’t know, just clicked update in my wordpress installation… https://wordpress.org/plugins/bbpress/ shows 2.5.13 too btw, last updated 13 hours ago


    Robin W
    Moderator

    @robin-w

    thanks, yes I can now see the file.

    It ahs the required change in it.

    what do you see when you look at line 1851 ?


    tweichart
    Participant

    @tweichart

    ln 1851 looks like this:

    $meta_query = $posts_query->get( 'meta_query', array() );


    Robin W
    Moderator

    @robin-w

    wqhich is exactly what it should look like, and is the same as the hotfix you applied

    what is the exact error you are now getting?


    tweichart
    Participant

    @tweichart

    the error is still the same and it’s on line 1800. Fixing something on ln 1850 won’t do the trick here I guess, so you’d need to change as initially written ln 1796 from

    
    $post_stati = $posts_query->get( 'post_status' );
    

    to

    
    $post_stati = $posts_query->get( 'post_status' );
    if (!is_array($post_stati)){
        $post_stati = array($post_stati);
    }
    

    Setting $post_stati to an array through the second parameter of the get method call won’t help here as $post_stati is an empty string.


    Robin W
    Moderator

    @robin-w

    ok, thanks for that.


    FionaS
    Participant

    @fionas

    Kia ora from New Zealand 🙂
    Just thought I’d let you know that I am also having problems with this since upgrading to PHP 7.1. To trouble-shoot I have changed my theme to the default 2017, I have deactivated all other plugins and instead of just a blank page I now get the HTTP ERROR 500; I had also changed line 1851 (a couple of weeks ago) but that didn’t work either so I was just hoping that the bbPress upgrade to v 2.5.13 would fix this but unfortunately not. I got my host to roll back the PHP upgrade and everything started to work again.
    I am not a PHP programmer so cannot give you all the details that tweichart has.
    Version of WordPress is 4.8 but also had the same problem with the previous version.


    Robin W
    Moderator

    @robin-w

    try doing the change that @tweichart suggested ie

    on line 1800 of the same file

    the error is still the same and it’s on line 1800. Fixing something on ln 1850 won’t do the trick here I guess, so you’d need to change as initially written ln 1796 from

    $post_stati = $posts_query->get( 'post_status' );
    to
    $post_stati = $posts_query->get( 'post_status' );
    if (!is_array($post_stati)){
        $post_stati = array($post_stati);
    }

    and then report back


    FionaS
    Participant

    @fionas

    OK will do – thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.
Skip to toolbar