$ wp plugin list
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in wp-includes/rest-api/class-wp-rest-server.php on line 1165
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in wp-includes/rest-api/class-wp-rest-server.php on line 1165
$ wp plugin list --skip-plugins=google-site-kit
no warnings
wp plugin listwp plugin list --skip-plugins=google-site-kitThis seems to be environment specific and I can't duplicate on a server running PHP 7.4 (shrug)
PHP 7.2.24-0ubuntu0.18.04.3 (cli)v7.2.24-0ubuntu0.18.04.3DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"I DO have opcache enabled for fpm & cli on the affected server but when I turned it off I still got the warnings.
_Do not alter or remove anything below. The following sections will be managed by moderators only._
\Google\Site_Kit\Core\Modules\Modules::get_module_schema method to return a closure that returns the schema itself.woocommercewp plugin listHi.
I have the same problem, only together WooCommerce.
I see this "warning" when add a "new REST_Route()" with "schema". Example "... 'schema' => $this->get_module_schema()..." in line 583 of file google-site-kit/includes/Core/Modules/Modules.php
Hi,
I have the same problem. Error with WooCommerce for each wp-cli request.
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in www/wp-includes/rest-api/class-wp-rest-server.php on line 1244 (x3)
Passing this to level 2 as I don't have a host with CLI setup to try this one
receiving a similar error
root@5273c015a93e:# wp-cli --allow-root --path=/var/www/vhosts/html/ cache flush
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in /var/www/vhosts/html/wp-includes/rest-api/class-wp-rest-server.php on line 1244
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in /var/www/vhosts/html/wp-includes/rest-api/class-wp-rest-server.php on line 1244
Warning: call_user_func() expects parameter 1 to be a valid callback, array must have exactly two members in /var/www/vhosts/html/wp-includes/rest-api/class-wp-rest-server.php on line 1244
Success: The cache was flushed.
@felixarntz Looks like the bug still exists in the latest vesion of the plugin. The issue happens here:
https://github.com/google/site-kit-wp/blob/25642bc9aff64bc38e4d18739a92f15eec69ad6c/includes/Core/Modules/Modules.php#L496
https://github.com/google/site-kit-wp/blob/25642bc9aff64bc38e4d18739a92f15eec69ad6c/includes/Core/Modules/Modules.php#L556
https://github.com/google/site-kit-wp/blob/25642bc9aff64bc38e4d18739a92f15eec69ad6c/includes/Core/Modules/Modules.php#L584
The $this->get_module_schema() function returns schema array, but the rest server class expects it to be a function that returns the schema. To fix it we need to wrap get_module_schema calls with anonymous functions, something like this:
new REST_Route(
'core/modules/data/list',
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => function( WP_REST_Request $request ) {
$modules = array_map(
array( $this, 'prepare_module_data_for_response' ),
$this->get_available_modules()
);
return new WP_REST_Response( array_values( $modules ) );
},
'permission_callback' => $can_authenticate,
),
),
array(
'schema' => function() {
return $this->get_module_schema();
},
)
),
Or we can make get_modules_schema to be public and then we cau make it to be callable:
array(
'schema' => array( $this, 'get_module_schema' ),
)
Thanks @eugene-manuilov, let's fix this for the next release.
@felixarntz could you please check my IB? Is there anything you want me to add/update?
@eugene-manuilov IB looks good, except let's keep the method private and pass a closure to schema instead, which calls the method (tentative IB ✅ ).
If that's okay with you, feel free to just make that adjustment and move directly to execution.
Ok, updated. Moving to the execution.
Tested
Built latest develop, installed SK and Woocommerce, activated both.
Checked wp plugin list

No errors to report.
Passed QA ✅