Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#53492 closed defect (bug) (fixed)

Fatal error serving media assets when `ms_files_rewriting` enabled

Reported by: iandunn's profile iandunn Owned by: iandunn's profile iandunn
Milestone: 5.8 Priority: high
Severity: blocker Version: 5.8
Component: Media Keywords: has-patch has-unit-tests
Focuses: multisite Cc:

Description

r51211 introduced a fatal error for Multisites using ms-files.php.

Uncaught Error: Call to undefined function wp_image_editor_supports() in wp-includes/functions.php on line 3306

ms-files.php is loaded with SHORTINIT, so media.php never loads. Props @otto42, @barry, and @ryelle for help debugging.

To reproduce:

  1. Setup Multisite
  2. svn up -r 51210
  3. wp site option set ms_files_rewriting 1
  4. Setup rewrite rules, restart web service. e.g.,
    location / {
    	rewrite ^/([_0-9a-zA-Z-]+/)?files/$ /index.php last;
    	rewrite ^/([_0-9a-zA-Z-]+/)?files/(.+) /wp-includes/ms-files.php?file=$2 last;
    }
    
  5. go to site that isn't main site
  6. upload new image
  7. view raw image, verify serving media from /files/. e.g., https://foo.wp-develop.test/files/2021/06/pizza.jpg
  8. svn up -r 51211
  9. change error_reporting( 0 ); to 1 in ms-files.php
  10. refresh, the error should appear

cc @azaozz, @adamsilverstein, @desrosj

I'll start on a PR. Any ideas for the best approach?

Change History (8)

#1 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 5.8

#2 @azaozz
3 years ago

ms-files.php is loaded with SHORTINIT

Ughh, was looking at the possibility that wp_image_editor_supports() is not defined, missed SHORTINIT though.

Any ideas for the best approach?

Thinking best is to revert [51211]. #53475 can be fixed in a different way.

This ticket was mentioned in Slack in #meta by iandunn. View the logs.


3 years ago

This ticket was mentioned in Slack in #core by azaozz. View the logs.


3 years ago

This ticket was mentioned in PR #1421 on WordPress/wordpress-develop by iandunn.


3 years ago
#5

  • Keywords has-patch added

r51211 accidentally introduced a fatal error for Multisite instances with ms_files_rewriting enabled. Reverting removes the error, and the original purpose of the commit can be solved in another way.

Props azaozz.
Fixes #53492. See #53475.

SVN command for actual commit: svn merge -c -51211 ., to preserve history etc


Trac ticket: https://core.trac.wordpress.org/ticket/53492

#6 @iandunn
3 years ago

  • Owner set to iandunn
  • Resolution set to fixed
  • Status changed from new to closed

In 51223:

Media: Revert r51211 to restore ms-files.php assets.

r51211 accidentally introduced a fatal error for Multisite instances with ms_files_rewriting enabled. Reverting removes the error, and the original purpose of the commit can be solved in another way.

Props otto42, barry, ryelle, azaozz.
Fixes #53492. See #53475.

This ticket was mentioned in PR #1437 on WordPress/wordpress-develop by iandunn.


3 years ago
#8

  • Keywords has-unit-tests added

Previously errors were not displayed or logged, but the original intention was only to prevent them from being displayed. Hiding them from logs makes problems like https://core.trac.wordpress.org/ticket/53492 much harder to debug.

This makes the handling of errors in ms-files consistent with the REST API, admin-ajax, and XML-RPC.


Trac ticket: https://core.trac.wordpress.org/ticket/53493

Note: See TracTickets for help on using tickets.