Media: Restore the ability of WP_Image_Editor_Imagick->save() to create a missing directory when needed.

Props eemitch, mikeschroder, hellofromTonya, p00ya, johnbillion

Fixes #51665

Built from https://develop.svn.wordpress.org/trunk@49542


git-svn-id: http://core.svn.wordpress.org/trunk@49280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2020-11-09 13:18:04 +00:00
parent 2d8633bf22
commit 3688a9394e
2 changed files with 15 additions and 1 deletions

View File

@ -741,6 +741,20 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
return true;
}
} else {
$dir_name = dirname( $filename );
$dir_exists = wp_mkdir_p( $dir_name );
if ( ! $dir_exists ) {
return new WP_Error(
'image_save_error',
sprintf(
/* translators: %s: Directory path. */
__( 'Unable to create directory %s. Is its parent directory writable by the server?' ),
esc_html( $dir_name )
)
);
}
try {
return $image->writeImage( $filename );
} catch ( Exception $e ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-beta3-49541';
$wp_version = '5.6-beta3-49542';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.