Support » Plugin: My Simple Space » Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator

  • Resolved idempotent

    (@idempotent)


    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)
  • Plugin Author Michael Mann

    (@mannweb)

    Just now seeing this. I have added those line into 1.2.4 and pushed up that release.

    Plugin Author Michael Mann

    (@mannweb)

    Stripping these two lines:

    		$path .= '.';
    		$path = pathinfo( $path , PATHINFO_DIRNAME );

    And replacing this line:
    foreach( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::FOLLOW_SYMLINKS ) ) as $file ) {

    With this:

    foreach( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, \FilesystemIterator::CURRENT_AS_FILEINFO ) ) as $file ) {

    To correct incorrect returned values from the change to 1.2.4

    Plugin Author Michael Mann

    (@mannweb)

    1.2.5 released, which should fix this issue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator’ is closed to new replies.