Fatal error: Uncaught Error: Call to a member function using_index_permalinks() in delete_used_css_on_update_or_delete() #7061
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
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:wp-rocket/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php
Line 128 in a1bdab0
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:
wp-rocket/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php
Line 121 in 7348869
Additional context
Ticket https://secure.helpscout.net/conversation/2738205682/518537?folderId=2683093
Slack convo: https://wp-media.slack.com/archives/C43T1AYMQ/p1729280828960439
The text was updated successfully, but these errors were encountered: