Pregunta

I have two different multisites:

  • www.example.org
  • www.example-two.org

On both sites, there are 5 sub-sites.

They're hosted on the same server (that I have setup myself using VirtualMin). All 10 sub-sites share the same parent theme, with different child-themes that has minor variations in them.

I've converted the sites to Gutenberg, - but whenever I upload an image, then I get this error:

The response is not a valid JSON response.

... Seen here:

The response is not a valid JSON response

In the error-log I get this error:

[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to undefined function upload_is_user_over_quota() in /PATH/TO/FOLDER/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:808, referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit

Here is the entire stack-trace:

[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to undefined function upload_is_user_over_quota() in /PATH/TO/FOLDER/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php:808, referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: Stack trace:, referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #0 /PATH/TO/FOLDER/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php(734): WP_REST_Attachments_Controller->check_upload_size(Array), referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #1 /PATH/TO/FOLDER/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php(108): WP_REST_Attachments_Controller->upload_from_file(Array, Array), referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #2 /PATH/TO/FOLDER/wp-includes/rest-api/class-wp-rest-server.php(936): WP_REST_Attachments_Controller->create_item(Object(WP_REST_Request)), referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #3 /PATH/TO/FOLDER/wp-includes/rest-api/class-wp-rest-server.php(321): WP_REST_Server->dispatch(Object(WP_REST_Request)), referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #4 /PATH/TO/FOLDER/wp-includes/rest-api.php(266): WP_REST_Server->serve_request('/wp/v2/media'), referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit
[DATESTAMP] [fcgid:warn] [pid 12345:tid 123456789012345] [client CLIENT_IP:55472] mod_fcgid: stderr: #5 /PATH/TO/FOLDER/wp-inclu in /PATH/TO/FOLDER/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php on line 808, referer: http://EXAMPLE.ORG/wp-admin/post.php?post=30&action=edit

It looks like that others are experiencing this error as well.

Does anyone know a fix or a work-around to this?

¿Fue útil?

Solución

In digging around this seems to be a bug with WordPress added in 4.9.8. This patch seems to have broken attachment uploads over the REST API on Multisite, because it uses a function from a file that isn't loaded for REST requests.

I've reported the bug here.

A quick and dirty fix would be to add this to your theme's functions.php file, or a simple plugin:

if ( ! function_exists( 'upload_is_user_over_quota' ) ) {
    function upload_is_user_over_quota( $echo ) {
        return false;
    }
}

The function won't do what it's supposed to do, but it will prevent the fatal error from occurring.

Licenciado bajo: CC-BY-SA con atribución
scroll top