Skip to main content
4 of 6
deleted 43 characters in body

PHP Fatal error: Uncaught Error: Cannot unset string offsets

When trying to upload files to the Wordpress media library I encounter the following error:

Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.

I enabled debugging mode in WP by adding

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_DEBUG_LOG', true);

to my wordpress config file.

After taking a look at debug.log there seems to be a problem with one of the WP core files PHP Fatal error: Uncaught Error: Cannot unset string offsets

The full debug log

The function throwing the error is clean_dirsize_cache

Line 8381: unset( $directory_cache[ $path ] );

I've already tried the following:

  • Allocated more memory in php.ini
  • Changed limit for max file sizes

The error happens on every file I try to upload, file size or file type doesn't seem to matter.

As I'm not experienced with Wordpress and I haven't worked on this site previously at all I'm not quite sure what caused this to start occuring.