WordPress.org

Forums

Meta Box
[resolved] Warning: call_user_func(Array) (10 posts)

  1. MissHD
    Member
    Posted 1 year ago #

    Hello,

    Since the last update (4.3.7), i've got this warning instead of input (single post edit).

    What can i do ?

    Thanks

    Warning: call_user_func(Array) [function.call-user-func]: First argument is expected to be a valid callback in /.../wp-content/plugins/meta-box/inc/field.php on line 32

    Warning: call_user_func(Array) [function.call-user-func]: First argument is expected to be a valid callback in /.../wp-content/plugins/meta-box/inc/field.php on line 38

    Warning: call_user_func(Array) [function.call-user-func]: First argument is expected to be a valid callback in /.../wp-content/plugins/meta-box/inc/field.php on line 91

    Warning: call_user_func(Array) [function.call-user-func]: First argument is expected to be a valid callback in /.../wp-content/plugins/meta-box/inc/field.php on line 100

    http://wordpress.org/plugins/meta-box/

  2. drlovable
    Member
    Posted 1 year ago #

    Same here! I've used this plugin exactly the same way for years, and suddenly all errors.

  3. Shaffe
    Member
    Posted 1 year ago #

    Here some thoughts to correct the error.
    The error is with PHP version < 5.3.
    The get_called_class function is not working because methods of the RWMB_Field classes are used statically so $t['object'] (line 53) is never set.
    So we want to do some late static binding.
    It's in the file /wp-content\plugins\meta-box\inc\common.php.

    I'm working on it, stay tuned :)

  4. Shaffe
    Member
    Posted 1 year ago #

    I've come to a fix which requires a small refactoring.
    Here is the steps to apply the fix:
    1- insert the following method at the end of the RWMB_Field class in the file
    /wp-content\plugins\meta-box\inc\field.php

    static function get_method_callback($field, $method)
    {
        if (version_compare(PHP_VERSION, '5.3') >= 0)
            return array(get_called_class(), $method);
        return array(RW_Meta_Box::get_class_name($field), $method);
    }

    2- Replace all call_user_func calls in this RWMB_Field class.
    call_user_func( array( get_called_class()
    with
    call_user_func( self::get_method_callback($field

    3- Test!

    If you still have "Warning: call_user_func(Array)", it's maybe because the type chosen for the field doesn't exists.

  5. Shaffe
    Member
    Posted 1 year ago #

    The bug is also occurring when a type contains the dash (-) character.
    To fix the bug edit the following file :
    /wp-content\plugins\meta-box\inc\meta-box.php:398
    Replace
    $_type = str_replace( '_', ' ', $field['type'] );
    with
    $_type = str_replace( array('_', '-'), ' ', $field['type'] );

  6. MissHD
    Member
    Posted 1 year ago #

    Thank you a lot ! It's perfect. :)

  7. vijayrajesh
    Member
    Posted 1 year ago #

    @Esoterick You are just awesome. Thanks for the fix.

  8. Shaffe
    Member
    Posted 1 year ago #

    The bug has been fixed in version 4.3.8.
    Careful however, the RW_Meta_Box::get_class_name method is still buggy if you use a type that contains dashes (like select-advanced or checkbox-list).
    To fix this bug:
    /wp-content\plugins\meta-box\inc\meta-box.php:396
    Replace
    $_type = str_replace( '_', ' ', $field['type'] );
    with
    $_type = str_replace( array('_', '-'), ' ', $field['type'] );

  9. thanchay
    Member
    Posted 1 year ago #

    Dear Esoterick , I want to use RWMB_Field in php version 5.2.pls help me

  10. Shaffe
    Member
    Posted 1 year ago #

    Dear Thanchay,
    If you download the latest version of Meta Box you will only have to replace
    Replace
    $_type = str_replace( '_', ' ', $field['type'] );
    with
    $_type = str_replace( array('_', '-'), ' ', $field['type'] );
    in the following file
    /wp-content\plugins\meta-box\inc\meta-box.php:396

    rilwis has fixed the PHP 5.2 version in the 4.3.8 version.
    Basically, he gets the class name in the following file
    wp-content\plugins\meta-box\inc\field.php:32
    and use it for every call_user_func.

    Regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic