PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'remove_wpcf7' not found or invalid function name

Craig picture Craig · Aug 18, 2018 · Viewed 10.3k times · Source

Apologies for this broad question but I am not hugely familiar with the Error Log entries at present. Any directives on where to begin the relevant research, would be greatly appreciated.

For the past 12 months, I have had the Google Authenticate Plugin, installed on a WordPress powered eCommerce website I work on. There had been no issues with the Plugin until a recent VPS and WordPress update. Since said updates, the Google Authenticate Plugin does not recognise any of the inputted codes. I am not sure if the error is being triggered by the WordPress update or the VPS itself.

I then checked the error_log and saw the below entry when trying to use the Google Authenticate Plugin:

mod_fcgid: stderr: PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'remove_wpcf7' not found or invalid function name in /var/www/vhosts/example.com/httpdocs/wp-includes/class-wp-hook.php on line 286, referer: https://www.example.com/wp-admin/plugins.php

Troubleshooting

As standard, I deactivated all Plugins (Except for the WooCommerce Plugin) as well as the WordPress Theme I had created. I then simply activated WordPress' Twenty Seventeen Theme. The error still persisted; leaving me wondering just what is causing the issue.

I can see there is a reference to WordPress' core files. Maybe there is some incompatibilities?

Any directives on this, would be greatly appreciated ... Even if to just help me expand on this question.

Answer

Santiago Cerro López picture Santiago Cerro López · Aug 19, 2018

Find in code any reference to 'remove_wpcf7' and find method is assigned in filter/hook. In this case you can find, for example a method inside a class called incorrectly. For example: add_filter('filter_name', 'method');. You can fix, for example, by add: add_filter('filter_name', array($this, 'method')); or if method is static: add_filter('filter_name', array(CLASSNAME::class, 'method'));

Hope this help you

===

UPDATE

Edit wp-includes/class-wp-hook.php line 73 and add:

    public function add_filter( $tag, $function_to_add, $priority, $accepted_args ) {
        if ($function_to_add === 'remove_wpcf7') {
            throw new \Exception('Exception');
        }
        [...]
    }

Get trace of this uncaught exception (if you can use xdebug extension it be better) and you will see line is creating this filter.