vip-go-mu-plugins icon indicating copy to clipboard operation
vip-go-mu-plugins copied to clipboard

A forever loop can happen when amazon-s3-and-cloudfront conflicts with the a8c-files code

Open rogertheriault opened this issue 5 years ago • 1 comments

Expected/Desired Behavior

  1. A filter loop causing out of memory fatal error never happens

Actual Behavior

In at least one instance, with version 2.6dev of amazon-s3-and-cloudfront, an endless loop occurs... calling https://github.com/Automattic/vip-go-mu-plugins/blob/82308873535a775d263daa3f2cc24a36d8774ccd/a8c-files.php#L704 multiple times until memory is exceeded. Stack traces can be enormous.

Steps to Reproduce the Problem

  1. Install the amazon-s3-and-cloudfront plugin version
  2. Monitor CLI tasks.
  3. Get wp-content/plugins/amazon-s3-and-cloudfront/classes/amazon-s3-and-cloudfront.php:3330 plugins_url() to be called (normally, this will happen during the init hook)

Additional notes

It seems keeping a static variable for the uploads URL in https://github.com/Automattic/vip-go-mu-plugins/blob/82308873535a775d263daa3f2cc24a36d8774ccd/a8c-files.php#L704 (to avoid calling get_site_url again) may circumvent the loop.

Example stack trace (partial)

wp-content/plugins/amazon-s3-and-cloudfront/classes/as3cf-filter.php:954 wp_upload_dir(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/filters/as3cf-local-to-s3.php:122 AS3CF_Filter->get_bare_upload_base_urls(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/filters/as3cf-local-to-s3.php:349 AS3CF_Local_To_S3->url_needs_replacing(), 
wp-includes/class-wp-hook.php:287 AS3CF_Local_To_S3->set_url_scheme(), 
wp-includes/plugin.php:212 WP_Hook->apply_filters(), 
wp-includes/link-template.php:3694 apply_filters('set_url_scheme'), 
wp-includes/link-template.php:3284 set_url_scheme(), 
wp-content/mu-plugins/a8c-files.php:704 get_site_url(), 
wp-includes/class-wp-hook.php:287 A8C_Files->upload_url_path(), 
wp-includes/plugin.php:212 WP_Hook->apply_filters(), 
wp-includes/option.php:179 apply_filters('option_upload_url_path'), 
wp-includes/functions.php:2367 get_option(), 
wp-includes/functions.php:2297 _wp_upload_dir(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/as3cf-filter.php:954 wp_upload_dir(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/filters/as3cf-local-to-s3.php:122 AS3CF_Filter->get_bare_upload_base_urls(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/filters/as3cf-local-to-s3.php:349 AS3CF_Local_To_S3->url_needs_replacing(), 
wp-includes/class-wp-hook.php:287 AS3CF_Local_To_S3->set_url_scheme(), 
wp-includes/plugin.php:212 WP_Hook->apply_filters(), 
wp-includes/link-template.php:3694 apply_filters('set_url_scheme'), 
wp-includes/link-template.php:3431 set_url_scheme(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/amazon-s3-and-cloudfront.php:3330 plugins_url(), 
wp-content/plugins/amazon-s3-and-cloudfront/classes/amazon-s3-and-cloudfront.php:261 Amazon_S3_And_CloudFront->register_modal_assets(),

rogertheriault avatar Dec 23 '20 17:12 rogertheriault

The loop appears to be:

plugins_url() -> set_url_scheme() -> apply_filters('set_url_scheme') -> 
wp_upload_dir() -> apply_filters('option_upload_url_path') -> A8C_Files->upload_url_path() -> 
get_site_url() -> set_url_scheme() -> (repeat, etc)

rogertheriault avatar Dec 23 '20 17:12 rogertheriault

This issue has been marked stale because it has been open for 60 days with no activity. If there is no activity within 7 days, it will be closed.

This is an automation to keep issues manageable and actionable and is not a comment on the quality of this issue nor on the work done so far. Closed issues are still valuable to the project and are available to be searched.

github-actions[bot] avatar Sep 17 '22 00:09 github-actions[bot]