multisite - Critical error on image display

admin2025-05-31  0

All of my sites are working except displaying images, attachments, etc. The sites are part of a multisite. The respective path parameters are:

  • upload_path: wp-content/blogs.dir/N/files - where N is the number of the site
  • upload_url_path: /files
  • fileupload_url: /files

This config worked until WP 6.7.x, but with WP 6.8 the error occurred on all sites.

The work-around described here with a static redirect for each site in .htaccess is only working for site=1.

UPDATE-1:

After fixing all minor PHP errors, no error message appeared except the WP critical error itself. Thus, I try to follow the code up to the point, where the error occurs. I started from .htaccess file at this line:

RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$1 [L]

Here, wp-includes/ms-files.php is called. There, test outputs like echo( 'x' ); brought me to the function is_super_admin(). Calling this function generates the WP critical error. Digging deeper in file wp-includes/capabilities.php where the function is defined does not result in any further results - the critical error is directly thrown by calling is_super_admin(). I have no idea why and how to proceed in finding the source of the WP critical error.

UPDATE-2:

Receiving the error logs, I can confirm that is_super_admin() throws the error:

PHP Fatal error: Uncaught Error: Call to undefined function is_super_admin() in /home/USER/WWW/multisite/wordpress/wp-includes/ms-files.php:23

UPDATE-3:

It is announced, that WP 6.8.1 will fix the problem:

UPDATE-4:

After WP 6.8.1 the critical error disappeared, but uploaded files are still not displayed (a 404 appears instead). Tracking ms-files.php up to line 28

$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] );

I found, that the path to the uploaded files BLOGUPLOADDIR is correct, but the filename is missing, because PHP superglobal $_GET['file'] is empty.

All of my sites are working except displaying images, attachments, etc. The sites are part of a multisite. The respective path parameters are:

  • upload_path: wp-content/blogs.dir/N/files - where N is the number of the site
  • upload_url_path: https://www.domain.tld/files
  • fileupload_url: https://www.domain.tld/files

This config worked until WP 6.7.x, but with WP 6.8 the error occurred on all sites.

The work-around described here with a static redirect for each site in .htaccess is only working for site=1.

UPDATE-1:

After fixing all minor PHP errors, no error message appeared except the WP critical error itself. Thus, I try to follow the code up to the point, where the error occurs. I started from .htaccess file at this line:

RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$1 [L]

Here, wp-includes/ms-files.php is called. There, test outputs like echo( 'x' ); brought me to the function is_super_admin(). Calling this function generates the WP critical error. Digging deeper in file wp-includes/capabilities.php where the function is defined does not result in any further results - the critical error is directly thrown by calling is_super_admin(). I have no idea why and how to proceed in finding the source of the WP critical error.

UPDATE-2:

Receiving the error logs, I can confirm that is_super_admin() throws the error:

PHP Fatal error: Uncaught Error: Call to undefined function is_super_admin() in /home/USER/WWW/multisite/wordpress/wp-includes/ms-files.php:23

UPDATE-3:

It is announced, that WP 6.8.1 will fix the problem: https://core.trac.wordpress/ticket/63285

UPDATE-4:

After WP 6.8.1 the critical error disappeared, but uploaded files are still not displayed (a 404 appears instead). Tracking ms-files.php up to line 28

$file = rtrim( BLOGUPLOADDIR, '/' ) . '/' . str_replace( '..', '', $_GET['file'] );

I found, that the path to the uploaded files BLOGUPLOADDIR is correct, but the filename is missing, because PHP superglobal $_GET['file'] is empty.

Share Improve this question edited May 8 at 7:26 bueltge 17.1k7 gold badges62 silver badges97 bronze badges asked Apr 24 at 8:51 StefanMzStefanMz 113 bronze badges 7
  • you mention there is a critical error can you give an example? Is this an Apache error page? A 404? White screen of death? Is it only uploaded files or is it also theme/plugin assets? – Tom J Nowell Commented Apr 24 at 11:51
  • It's the usual WP critical error: "There has been a critical error on this website" followed by a link "Learn more about troubleshooting WordPress". It concerns only uploaded files. – StefanMz Commented Apr 24 at 20:03
  • you should check your PHP error log then to discover the real error message, your host can help you with that if you're unsure where it is – Tom J Nowell Commented Apr 25 at 9:30
  • I tried to show PHP errors by adding a .user.ini to the root directory with the line "display_errors = On" (this is what the host recommends). Normally, that works and shows errors in detail on the screen. But in the case described above, nothing was shown (only the critical error message). – StefanMz Commented Apr 25 at 9:59
  • I wouldn't advise that since it might expose information on the site, instead there is a built in debug log that creates a wp-content/debug.log when enabled via WP_DEBUG_LOG in wp-config.php, and there should be provisions for an error log file by your host that you can download/read. Eitherway without the PHP error message and the associated code it's very difficult if not impossible for you to get help online with this – Tom J Nowell Commented Apr 25 at 14:33
 |  Show 2 more comments

1 Answer 1

Reset to default 0

Do you care about the admin restrictions for serving these files? Without seeing your exact error my guess would be that in ms-files.php, WordPress is not fully loaded at the point where is_super_admin() is called.

So again if you don't care about this super admin check then you can modify .htaccess to serve the files directly...no need for ms-files.php at all!

RewriteCond %{REQUEST_URI} ^/files/(.*)
RewriteRule ^files/(.*) wp-content/uploads/$1 [L]
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748633244a313670.html

最新回复(0)