1

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.org/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.

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? 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. 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 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). 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 Commented Apr 25 at 14:33

1 Answer 1

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] 
7
  • This would store/access files directly, yes, but all of them in wp-content/uploads. However, I have a running multisite with a structure described above: wp-content/blogs.dir/N/files - where N is the number of the site (N-Max=10 in my case). If I understand ms-files.php correctly, I need its function to serve the right subsite directory for uploaded files. Commented Apr 26 at 20:13
  • Can you try to add require_once dirname( _DIR_ ) . '/wp-load.php'; to the top of ms file that was giving critical error - perhaps that will solve the issue as I think the super admin function was not loaded...but again its really hard to tell without seeing the contents of your error log to know for sure Commented Apr 26 at 21:57
  • WP bootstrap is loaded in ms-files.php by require_once dirname( __DIR__ ) . '/wp-load.php'; which loads wp-config.php which loads wp-settings.php which loads capabilities.php which defines the function is_super_admin(). Thus, this function - which is missing according to the fatal PHP error (see UPDATE-2) - is defined before being called. Or at least should be, because something went wrong. Commented Apr 27 at 13:02
  • Oh - In WordPress 6.8, a change introduced a call to the is_super_admin() function within ms-files.php. However, this function isn't available when WordPress is loaded with the SHORTINIT constant set to true, which is common in legacy setups using ms-files.php. This mismatch leads to the fatal error you're experiencing. It looks like they are going to fix this in 6.8.1 - gutenbergtimes.com/… Commented Apr 27 at 15:47
  • 1
    here is the actual ticket of the issue: core.trac.wordpress.org/ticket/63285 Commented Apr 27 at 15:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.