Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress Media API is broken or not initialized while this plugin is active #217

Closed
1 task done
EHLOVader opened this issue Jun 27, 2023 · 1 comment · Fixed by #218
Closed
1 task done

WordPress Media API is broken or not initialized while this plugin is active #217

EHLOVader opened this issue Jun 27, 2023 · 1 comment · Fixed by #218
Assignees
Labels
type:bug Something isn’t working.
Milestone

Comments

@EHLOVader
Copy link
Contributor

Describe the bug

When this plugin is activated, other plugins are affected because something is wrong with the state of the WordPress javascript API for media.

wp.media.view.settings.post.id is not set and activating this plugin produces a lot of Uncaught TypeError: Cannot read properties of undefined (reading 'id') sort of errors.

This prevents opening the media library on admin pages like the Elementor page editor.

Steps to Reproduce

  1. Activate the plugin
  2. edit any page with Elementor (possibly other admin pages too)
  3. add or edit image

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

`

wp-core

version: 6.2.2
site_language: en_US
user_language: en_US
timezone: America/Detroit
permalink: /%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 29
dotorg_communication: true

wp-paths-sizes

wordpress_path: /src/site/web/wp
wordpress_size: 50.24 MB (52685430 bytes)
uploads_path: /src/site/web/app/uploads
uploads_size: 123.00 MB (128973896 bytes)
themes_path: /src/site/web/app/themes
themes_size: 63.16 MB (66226718 bytes)
plugins_path: /src/site/web/app/plugins
plugins_size: 234.32 MB (245699343 bytes)
database_size: 23.14 MB (24264704 bytes)
total_size: 493.86 MB (517850091 bytes)

wp-active-theme

name: Intranet (intranet)
version: 1.0
author: ThemeREX
author_website: https://themerex.net/
parent_theme: Alliance (alliance)
theme_features: core-block-patterns, wc-product-grid-enable, styles-and-scripts-full-merged, theme-updates-allowed, automatic-feed-links, custom-header, custom-logo, custom-background, customize-selective-refresh-widgets, post-formats, title-tag, nav-menus, html5, menus, post-thumbnails, align-wide, editor-styles, editor-style, editor-color-palette, widgets
theme_path: /src/site/web/app/themes/intranet

wp-parent-theme

name: Alliance (alliance)
version: 3.0.0
author: ThemeREX
author_website: https://themerex.net/
theme_path: /src/site/web/app/themes/alliance

wp-themes-inactive (1)

Twenty Twenty-Three: version: 1.0, author: the WordPress team (latest version: 1.1)

wp-mu-plugins (1)

Bedrock Autoloader: version: 1.0.3, author: Roots

wp-plugins-active (20)

Activity Plus Reloaded for BuddyPress: version: 1.1.0, author: BuddyDev
Advanced Custom Fields: version: 6.1.7, author: WP Engine
bbPress: version: 2.6.9, author: The bbPress Contributors
BuddyPress: version: 11.2.0, author: The BuddyPress Community
Contact Form 7: version: 5.7.7, author: Takayuki Miyoshi
Democracy Poll: version: 5.6.0, author: Kama
Elementor: version: 3.14.1, author: Elementor.com
Frontend Admin: version: 3.16.7, author: Shabti Kaplan
iThemes Security: version: 8.1.6, author: iThemes
Knowledge Base for Documents and FAQs: version: 10.1.0, author: Echo Plugins
Leira Letter Avatar: version: 1.3.7, author: Ariel
Safe SVG: version: 2.1.1, author: 10up
Simple Local Avatars: version: 2.7.5, author: 10up
Simple Page Ordering: version: 2.5.1, author: 10up
The Events Calendar: version: 6.1.2.2, author: The Events Calendar
The Events Calendar: Community Events: version: 4.10.8, author: The Events Calendar
The Events Calendar Extension: Test Data Generator: version: 1.0.6, author: The Events Calendar
The Events Calendar Pro: version: 6.1.0, author: The Events Calendar
ThemeREX Addons: version: 2.21.1.1, author: ThemeREX
Yoast Duplicate Post: version: 4.5, author: Enrico Battocchi & Team Yoast

wp-plugins-inactive (10)

Advanced Custom Fields: Extended: version: 0.8.9.3, author: ACF Extended
AI Engine: ChatGPT Chatbot, Content Generator, GPT 3 & 4, Ultra-Customizable: version: 1.8.0, author: Jordy Meow
Better Messages: version: 2.1.18, author: WordPlus
BuddyPress Activity ShortCode: version: 1.1.8, author: BuddyDev
BuddyPress Docs: version: 2.1.8, author: Boone B Gorges, David Cavins
MC4WP: Mailchimp for WordPress: version: 4.9.5, author: ibericode
M Chart: version: 1.10, author: Jamie Poitra
rtMedia for WordPress, BuddyPress and bbPress: version: 4.6.13, author: rtCamp
SiteGround Migrator: version: 2.0.9, author: SiteGround
WordPress Popular Posts: version: 6.1.3, author: Hector Cabrera

wp-media

image_editor: WP_Image_Editor_GD
imagick_module_version: Not available
imagemagick_version: Not available
imagick_version: Not available
file_uploads: File uploads is turned off
post_max_size: 128M
upload_max_filesize: 128M
max_effective_size: 128 MB
max_file_uploads: 20
gd_version: 2.3.3
gd_formats: GIF, JPEG, PNG, WebP, BMP, AVIF, XPM
ghostscript_version: not available

the-events-calendar

events-calendar-pro

wp-server

server_architecture: Darwin 22.4.0 x86_64
httpd_software: nginx/1.19.0
php_version: 8.1.20 64bit
php_sapi: fpm-fcgi
max_input_variables: 1000
time_limit: 300
memory_limit: 4G
max_input_time: 60
upload_max_filesize: 128M
php_post_max_size: 128M
curl_version: 8.1.2 (SecureTransport) OpenSSL/1.1.1u
suhosin: false
imagick_availability: false
pretty_permalinks: true

wp-database

extension: mysqli
server_version: 5.7.41
client_version: mysqlnd 8.1.20
max_allowed_packet: 1073741824
max_connections: 100000

wp-constants

WP_HOME: http://intranet.test
WP_SITEURL: http://intranet.test/wp
WP_CONTENT_DIR: /src/site/web/app
WP_PLUGIN_DIR: /src/site/web/app/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 4G
WP_DEBUG: false
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: production
DB_CHARSET: utf8mb4
DB_COLLATE: undefined

wp-filesystem

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable

buddypress

version: 11.2.0
active_components: Community Members, Extended Profiles, Account Settings, Notifications, User Groups
template_pack: BuddyPress Legacy 11.2.0
! hide-loggedout-adminbar: Yes
! bp-disable-account-deletion: No
! bp-disable-avatar-uploads: Yes
! bp-disable-cover-image-uploads: No
bp-enable-members-invitations: No
bp-enable-membership-requests: No
! bp-disable-profile-sync: Yes
! bp_restrict_group_creation: No
! bp-disable-group-avatar-uploads: Yes
! bp-disable-group-cover-image-uploads: No

`

Code of Conduct

  • I agree to follow this project's Code of Conduct
@EHLOVader EHLOVader added the type:bug Something isn’t working. label Jun 27, 2023
@EHLOVader
Copy link
Contributor Author

EHLOVader commented Jun 27, 2023

I've tracked it down to the following part of the hooks.
But I'm still not sure why exactly, going to look into the set defaults closer.

		add_filter( 'avatar_defaults', array( $this, 'add_avatar_default_field' ) );
	

Looking closer it appears to be specifically the call to wp_enqueue_media

		if ( ! did_action( 'wp_enqueue_media' ) ) {
			wp_enqueue_media();
		}

I don't understand why the avatar_defaults filter might be called on this page, or how it conflicts. I've tried adding wp_enqueue_media to my admin enqueue scripts and it doesn't cause the issue.

But I also don't know if I understand the use case here. The wp_enqueue_media is called outside of the output buffer.
Should this be done? When I comment it out the discussion options page seems to function fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn’t working.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants