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

Fatal error: Uncaught Error: Call to a member function using_index_permalinks() in delete_used_css_on_update_or_delete() #7061

Open
alfonso100 opened this issue Oct 25, 2024 · 0 comments · May be fixed by #7073
Labels
priority: medium Issues which are important, but no one will go out of business. severity: major Feature is not working as expected and no work around available type: bug Indicates an unexpected problem or unintended behavior

Comments

@alfonso100
Copy link
Contributor

alfonso100 commented Oct 25, 2024

Describe the bug
A Fatal error is triggered if an attachment post-creation happens too early.

The error happens inside delete_used_css_on_update_or_delete():
Fatal error: Uncaught Error: Call to a member function using_index_permalinks() in delete_used_css_on_update_or_delete()

Because we try to clear the used CSS but wp_rewrite is null:

$this->used_css->delete_used_css( untrailingslashit( $url ) );

It happens with the plugin Wonder Cart, because they trigger an Attachment post creation in the class-yith-sales-install.php file. too early in the WP Loading process
it is creating attachments using the function create_media()
$attach_id = wp_insert_attachment( $attachment, $filename );

Other plugins could cause the same error in the same conditions

Expected behavior
We should guard against early attachment post creation to prevent fatal errors by checking if is_attachment is true and bailout, here:

Additional context
Ticket https://secure.helpscout.net/conversation/2738205682/518537?folderId=2683093
Slack convo: https://wp-media.slack.com/archives/C43T1AYMQ/p1729280828960439

@wordpressfan wordpressfan linked a pull request Oct 28, 2024 that will close this issue
16 tasks
@piotrbak piotrbak added type: bug Indicates an unexpected problem or unintended behavior priority: medium Issues which are important, but no one will go out of business. severity: major Feature is not working as expected and no work around available labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Issues which are important, but no one will go out of business. severity: major Feature is not working as expected and no work around available type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants