Error in show_attachment_count() during Ajax call
-
Hi there.
Found an error in the plugin. Probably harmless but easily fixed…
I’m using an ACF Gallery field in a reusable block page. When editing with the block editor, within an Ajax call to render the field, ACF calls wp_enqueue_media(), which you hook with enqueue_js_css() which calls show_attachment_count(). That checks for function_exists( ‘get_current_screen’ ) but not that a screen object is returned from it. Since this is an Ajax call, screen is null. The switch on $screen->base then fails. A simple check for $screen existing and an early bail should solve it.
Full stack trace:0: Media_Library_Organizer_Media->show_attachment_count() line 303 in /wp-content/plugins/media-library-organizer/includes/global/class-media-library-organizer-media.php 1: Media_Library_Organizer_Media->enqueue_js_css() line 307 in /wp-includes/class-wp-hook.php 2: do_action('wp_enqueue_media') line 4618 in /wp-includes/media.php 3: wp_enqueue_media() line 305 in /wp-content/plugins/advanced-custom-fields-pro/includes/assets.php 4: ACF_Assets->enqueue_uploader() line 613 in /wp-content/plugins/advanced-custom-fields-pro/includes/assets.php 5: acf_enqueue_uploader() line 418 in /wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-gallery.php 6: acf_field_gallery->render_field() line 307 in /wp-includes/class-wp-hook.php 7: do_action_ref_array('acf/render_field/type=gallery') line 113 in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-hook-functions.php 8: _acf_apply_hook_variations() line 307 in /wp-includes/class-wp-hook.php 9: do_action('acf/render_field') line 794 in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php 10: acf_render_field() line 754 in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php 11: acf_render_field_wrap() line 613 in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php 12: acf_render_fields() line 663 in /wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php 13: acf_ajax_fetch_block() line 307 in /wp-includes/class-wp-hook.php 14: do_action('wp_ajax_acf/ajax/fetch-block') line 187 in /wp-admin/admin-ajax.php
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Error in show_attachment_count() during Ajax call’ is closed to new replies.