Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator
-
Hello,
I’ve been receiving a fatal exception in mss_dir_size when it tries to access a file path, instead of a folder path.
The two lines added below fixed my issue.
function mss_dir_size( $path ) { $path .= '.'; $path = pathinfo( $path , PATHINFO_DIRNAME ); if ( false === ( $total_size = get_transient( $path ) ) ) { $total_size = 0; foreach ( new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ) ) as $file ) { $total_size += $file->getSize(); } // Set transient, expires in 1 hour set_transient( $path, $total_size, 1 * HOUR_IN_SECONDS ); return $total_size; } else { return $total_size; } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator’ is closed to new replies.