• Resolved tommanson

    (@tommanson)


    When trying to broadcast programmatically from within a script recently, regular users have been seeing a critical WordPress error.

    Stack trace shows the following:

    Notice: Undefined variable: custom_fields_input in /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/traits/meta_boxes.php on line 232
    
    Fatal error: Uncaught Error: Call to a member function hidden() on null in /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/traits/meta_boxes.php:232 Stack trace: #0 /var/www/html/dev.cornwall/wp-includes/class-wp-hook.php(287): threewp_broadcast\ThreeWP_Broadcast->threewp_broadcast_prepare_meta_box(Object(threewp_broadcast\actions\prepare_meta_box)) #1 /var/www/html/dev.cornwall/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #2 /var/www/html/dev.cornwall/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #3 /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/sdk/wordpress/actions/action.php(46): do_action('threewp_broadca...', Object(threewp_broadcast\actions\prepare_meta_box)) #4 /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/broadcasting_data.php(330): plainview\sdk_broadcast\wordpress\actions\action->execute() #5 /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/broadcasting_data.php(453): threewp_broadcast\broadcastin in /var/www/html/dev.cornwall/wp-content/plugins/threewp-broadcast/src/traits/meta_boxes.php on line 232

    The code being used to broadcast is as follows:

    ThreeWP_Broadcast()->api()->broadcast_children($thispost, [1]);

    The variable $thispost resolves to a post ID number.

    This only started happening after the latest update and only happens when the script is run by a lower level user. When admin users run the script, it functions without an issue.

    • This topic was modified 5 years, 6 months ago by tommanson.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter tommanson

    (@tommanson)

    Further investigation and tinkering, it turns out this was because the new “show extra checkboxes” option was not checked. As soon as I checked this box, it worked as expected.

    I didn’t expect this option was causing a problem as I was doing the broadcast programmatically, but this seemed to be the main change in the update that caused the issue.

    Plugin Author edward_plainview

    (@edward_plainview)

    So the forums work again. I couldn’t reach this thread yesterday, therefore the delay in answering.

    I’ve had a look at the problem and managed to replicate it. It’s related to your Broadcast user roles. Does the user that is broadcasting have enough permission to use broadcast and custom fields?

    I’m going to fix the fatal error anyways, though. It shouldn’t broadcast instead of giving a fatal error.

    Thread Starter tommanson

    (@tommanson)

    Yes, all the relevant users have the permissions, the only permission they don’t have is to broadcast as a draft.

    I didn’t realise that broadcasting programmatically would still take into account the user’s role. My assumption was that this being hardcoded would force the broadcast, but clearly that isn’t the case as the problem wasn’t there for admin users.

    As stated, though, I fixed this problem when I checked the new “show extra” option.

    Plugin Author edward_plainview

    (@edward_plainview)

    The “show extra” option should almost never be used.

    I’ve instead fixed the error by adding this on line 230 of src / traits / metaboxes.php

    if ( isset( $custom_fields_input ) )

    I’ll add the fix in the next version of Broadcast, which … I should release kinda immediately, if you’re fine with the above fix.

    Thread Starter tommanson

    (@tommanson)

    Whatever you need to do to fix the error 🙂

    Thanks for the response and dealing with the issue!

    Plugin Author edward_plainview

    (@edward_plainview)

    Fixed in v46.17, which I just released.

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

The topic ‘Call to member function hidden on null’ is closed to new replies.