Code Duplication    Length = 8-9 lines in 3 locations

src/wp-admin/includes/file.php 1 location

@@ 380-387 (lines=8) @@
377
		unlink( $file['tmp_name'] );
378
	}
379
380
	if ( false === $move_new_file ) {
381
		if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
382
			$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
383
		} else {
384
			$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
385
		}
386
		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
387
	}
388
389
	// Set correct file permissions.
390
	$stat = stat( dirname( $new_file ));

src/wp-includes/functions.php 2 locations

@@ 1891-1899 (lines=9) @@
1888
		if ( array_key_exists( $path, $tested_paths ) ) {
1889
			$uploads['error'] = $tested_paths[ $path ];
1890
		} else {
1891
			if ( ! wp_mkdir_p( $path ) ) {
1892
				if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
1893
					$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
1894
				} else {
1895
					$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
1896
				}
1897
1898
				$uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) );
1899
			}
1900
1901
			$tested_paths[ $path ] = $uploads['error'];
1902
		}
@@ 2151-2159 (lines=9) @@
2148
	$filename = wp_unique_filename( $upload['path'], $name );
2149
2150
	$new_file = $upload['path'] . "/$filename";
2151
	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
2152
		if ( 0 === strpos( $upload['basedir'], ABSPATH ) )
2153
			$error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir'];
2154
		else
2155
			$error_path = basename( $upload['basedir'] ) . $upload['subdir'];
2156
2157
		$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
2158
		return array( 'error' => $message );
2159
	}
2160
2161
	$ifp = @ fopen( $new_file, 'wb' );
2162
	if ( ! $ifp )