• jayahn4

    (@jayahn4)


    Since updating to PHP 8.0, I’m getting the following error:

    PHP message: PHP Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method PMProRH_Field::saveFile() cannot be called statically in /www/austa_486/public/wp-content/plugins/pmpro-register-helper/pmpro-register-helper.php:937

    I’ve taken a look at pmpro-register-helper.php line 937, which contains the following:

    if(!empty($field->save_function))
        call_user_func($field->save_function, $user_id, $field->name, $_POST[$field->name]);

    And then at class.field.php:

    elseif($this->type == "file")
    {
    	//use the file save function
    	$this->save_function = array("PMProRH_Field", "saveFile");
    }

    Any thoughts?

    • This topic was modified 2 years ago by jayahn4.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jayahn4

    (@jayahn4)

    So I went into classes/class.field.php and edited line 146 and added ‘static’

    From
    function saveFile($user_id, $name, $value)

    To
    static function saveFile($user_id, $name, $value)

    And now it is working. Since PHP 8.0 is more strict with syntax, it doesn’t allow static calling of non-static methods. Perhaps this should be updated all throughout the plugin, or does anybody have any other workarounds?

    • This reply was modified 2 years ago by jayahn4.

    WordPress should be updated in its entirety to be completely honest, along with a whole boat load of plugins. There are plenty of websites out there claiming that WP is 100% compatible with PHP 8+, but this is a lie as I’m writing thins. Install a plugin such as Query Monitor and you’ll very quickly see how incompatible it actually is.

    Expect another 6 months+ before this issue is sorted. In the meanwhile “hacks” such as yours will need to be the order of the day. Well done for figuring it out btw.

    • This reply was modified 1 year, 8 months ago by Strusbobbin.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calling a non-static method statically’ is closed to new replies.