humanmade / asset-manager-framework

A framework for overriding the WordPress media library with an external asset provider, such as a DAM
GNU General Public License v2.0
155 stars 7 forks source link

Type error in fix_media_url #39

Closed jazzsequence closed 3 years ago

jazzsequence commented 3 years ago

I am getting the following error anytime I open the media library or when I attempt to edit/replace an image in a post: Uncaught TypeError: Argument 1 passed to AssetManagerFramework\fix_media_url() must be of the type string, bool given

I am using AMF 0.12.0, AMF WordPress 0.2.1 and Altis Media dev-master.

Steps to reproduce

  1. Open the media library. The loading indicator permanently rotates.

or

  1. Select an image within a post
  2. Click Replace
  3. The loading indicator permanently rotates

However, repeating that process will load the images. See screengrab: https://www.dropbox.com/s/ocxlqqtcojzd9gd/tachyon-provider-error.mov?raw=1

When I dug into this a bit, it seems like the first time the $size['url'] is requested to pass into fix_media_url, it's coming back with a boolean (false), which fatals. Subsequent requests return the sizes.

Full stack trace is below:

php_1              | [17-Jun-2021 21:18:09 UTC] PHP Fatal error:  Uncaught TypeError: Argument 1 passed to AssetManagerFramework\fix_media_url() must be of the type string, bool given, called in /usr/src/app/extra-packages/asset-manager-framework/inc/namespace.php on line 318 and defined in /usr/src/app/extra-packages/asset-manager-framework/inc/namespace.php:305
php_1              | Stack trace:
php_1              | #0 /usr/src/app/extra-packages/asset-manager-framework/inc/namespace.php(318): AssetManagerFramework\fix_media_url(false, Object(WP_Post))
php_1              | #1 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(294): AssetManagerFramework\fix_media_size_urls(Array, Object(WP_Post))
php_1              | #2 /usr/src/app/wordpress/wp-includes/plugin.php(212): WP_Hook->apply_filters(Array, Array)
php_1              | #3 /usr/src/app/wordpress/wp-includes/media.php(4141): apply_filters('wp_prepare_atta...', Array, Object(WP_Post), Array)
php_1              | #4 [internal function]: wp_prepare_attachment_for_js(Object(WP_Post))
php_1              | #5 /usr/src/app/wordpress/wp-admin/includes/ajax-actions.php(2993): array_map('wp_prepare_atta...', Array)
php_1              | #6 /usr/src/app/extra-packages/asset-manager-framework/inc/LocalProvider.php(24): wp_ajax_query_attachments()
php_1              | #7 /usr/src/app/extra-packages/asset-manager-framework/inc/Provider.php(138): AssetManagerFramework\LocalProvider->request(Array)
php_1              | #8 /usr/src/app/extra-packages/asset-manager-framework/inc/namespace.php(268): AssetManagerFramework\Provider->request_items(Array)
php_1              | #9 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(292): AssetManagerFramework\ajax_query_attachments('')
php_1              | #10 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array)
php_1              | #11 /usr/src/app/wordpress/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
php_1              | #12 /usr/src/app/wordpress/wp-admin/admin-ajax.php(187): do_action('wp_ajax_query-a...')
php_1              | #13 {main}
php_1              |   thrown in /usr/src/app/extra-packages/asset-manager-framework/inc/namespace.php on line 305
roborourke commented 3 years ago

Thanks @jazzsequence, fixed in #40