All of my sites are working except displaying images, attachments, etc. The sites are part of a multisite. The respective path parameters are:
wp-content/blogs.dir/N/files
- where N is the number of the site/files
/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.
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.
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
It is announced, that WP 6.8.1 will fix the problem:
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:
wp-content/blogs.dir/N/files
- where N is the number of the sitehttps://www.domain.tld/files
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.
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.
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
It is announced, that WP 6.8.1 will fix the problem: https://core.trac.wordpress/ticket/63285
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.
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]
wp-content/debug.log
when enabled viaWP_DEBUG_LOG
inwp-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