Jetpack: Media: URL upload broken on Atomic sites

Created on 8 Oct 2020  路  7Comments  路  Source: Automattic/jetpack

Steps to reproduce the issue

  1. Go to My Site -> Site -> Media
  2. Click on the arrow next to the "Add new" button and choose "Add via URL"
  3. Add an image URL and you will get "1 file could not be uploaded because an error occurred while uploading." error.

What I expected

For the image to be uploaded like on sites which do not have custom plugins installed.

What happened instead

It seems this issue may be happening because of this PR - #16986.

A stack trace:

[08-Oct-2020 05:52:34 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function get_upload_space_available() in /wordpress/plugins/jetpack/9.0.1/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php:185
Stack trace:
#0 /wordpress/core/5.5.1/wp-includes/class-wp-hook.php(287): WPCOM_JSON_API_Upload_Media_v1_1_Endpoint->check_upload_size(Array)
#1 /wordpress/core/5.5.1/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array)
#2 /wordpress/core/5.5.1/wp-admin/includes/file.php(754): apply_filters('wp_handle_sidel...', Array)
#3 /wordpress/core/5.5.1/wp-admin/includes/file.php(1018): _wp_handle_upload(Array, Array, '2020-10-07 16:4...', 'wp_handle_sidel...')
#4 /wordpress/core/5.5.1/wp-admin/includes/media.php(449): wp_handle_sideload(Array, Array, '2020-10-07 16:4...')
#5 /wordpress/plugins/jetpack/9.0.1/class.json-api-endpoints.php(1943): media_handle_sideload(Array, 45533)
#6 /wordpress/plugins/jetpack/9.0.1/class.json-api-endpoints.php(1836): WPCOM_JSON_API_Endpoint->handle_media_sideload('https://cldup.c...', 45533)
#7 /wordpress/plugins/jetpack/9.0.1/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php(114): WPCOM_JSON_API_Endpoint->handle_media_creation_v1_1(Array, Array, Array)
#8 /wordpress/plugins/jetpack/9.0.1/class.json-api.php(348): WPCOM_JSON_API_Upload_Media_v1_1_Endpoint->callback('/sites/16514019...', 1)
#9 /wordpress/plugins/jetpack/9.0.1/class.json-api.php(332): WPCOM_JSON_API->process_request(Object(WPCOM_JSON_API_Upload_Media_v1_1_Endpoint), Array)
#10 /wordpress/plugins/jetpack/9.0.1/vendor/automattic/jetpack-connection/legacy/class-jetpack-xmlrpc-server.php(920): WPCOM_JSON_API->serve(false)
#11 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(121): Jetpack_XMLRPC_Server->json_api(Array)
#12 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(206): IXR_Server->call('jetpack.jsonAPI', Array)
#13 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(109): IXR_Server->multiCall(Array)
#14 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(59): IXR_Server->call('system.multical...', Array)
#15 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(27): IXR_Server->serve('<?xml version="...')
#16 /wordpress/core/5.5.1/wp-includes/IXR/class-IXR-server.php(35): IXR_Server->__construct(Array, false, false)
#17 /wordpress/core/5.5.1/wp-includes/class-wp-xmlrpc-server.php(191): IXR_Server->IXR_Server(Array)
#18 /wordpress/core/5.5.1/xmlrpc.php(87): wp_xmlrpc_server->serve_request()
#19 {main}
  thrown in /wordpress/plugins/jetpack/9.0.1/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php on line 185

p1602136996077900-slack-jetpack-developers

Touches WP.com Files WPCOM API [Pri] Normal [Status] Needs Author Reply [Type] Bug [Type] Happiness Request

All 7 comments

cc @cpapazoglou; do you think you could take a look?

For reference, this is the follow up ticket for the user report: 3385315-zd-woothemes

Can't properly debug it in my sandbox... I am commenting the offending line
https://github.com/Automattic/jetpack/blob/a85dea9d03691ee28d6b9a0474efcc9a3a9ecd4e/json-endpoints/class.wpcom-json-api-upload-media-v1-1-endpoint.php#L112
but I am still getting the same error through _cli.

Also, I am wondering why get_upload_space_available() is undefined. Checking a jetpack connected site (not wpcom) it works, are we doing define( 'MULTISITE', false ); in Atomic (yeah, I know the name suggests they are not multisite ;-))?

I have created a PR for anyone interested in reviewing it: https://github.com/Automattic/jetpack/pull/17415

I tested this today on a simple site and found the exact same problem. It was prompted from 3546649-zen. Should we just reopen this report or open a brand new one?

馃憢 @xpurichan! Thanks for making time to report the issue!

I have been reading the 3546649-zen and it seems that the customer has a problem invoking their native file system selector from the media library button (and especially when trying to add a Featured Image)

Probably the customer clicks on the arrow down button which is only used for "Add via URL"

Instead, they should click

If that is not the case, please create a new issue with clear steps to reproduce.

Now, to your specific case it seems that you are getting 1 file could not be uploaded because the file type is not supported.
which seems like a bug but is not related to the current issue. I just tried it in my IOS 14 device and it works but we need to investigate your case further. Could you please create a new issue and note down all steps to reproduce including the URL that you are pasting 馃檹?

@cpapazoglou Hmmm I was previously able to reproduce this one, but I can't right now. I was using the same steps as found in Kris' original post. I'll go ahead and close this once more and open a new issue if I can reproduce the problem in a different way.

Was this page helpful?
0 / 5 - 0 ratings