Package: wordpress Version: 4.1+dfsg-1 Severity: normal This was probably reported before but let's start all over again:
I'm trying to add new theme, I click [Install] and got the following error: Unpacking the package… Could not create directory. I fix this utterly unhelpful message using the following patch: ~~~~ --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -628,9 +628,9 @@ // Create those directories if need be: foreach ( $needed_dirs as $_dir ) { if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way. - return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); + return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory '.$_dir ), substr( $_dir, strlen( $to ) ) ); } unset($needed_dirs); for ( $i = 0; $i < $z->numFiles; $i++ ) { ~~~~ Now error message reveal the first problem: Could not create directory /usr/share/wordpress/wp-content/upgrade Indeed there is no such directory so I create missing symlink which is probably should be installed by the package: ln -sv /var/lib/wordpress/wp-content/upgrade /usr/share/wordpress/wp-content/upgrade Now theme archive is extracted to `/var/lib/wordpress/wp-content/upgrade` but there is another error: Unpacking the package… Installing the theme… Could not create directory. /usr/share/wordpress/wp-content/themes/yo-manga/ Theme install failed. Theme should be installed to `/var/lib/wordpress/wp-content/themes` instead of `/usr/share/wordpress/wp-content/themes` so I'm trying to address that with the following sloppy patch: ~~~~ --- a/wp-admin/includes/class-wp-upgrader.php +++ a/wp-admin/includes/class-wp-upgrader.php @@ -364,8 +364,14 @@ $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); $remote_destination = $wp_filesystem->find_folder( $local_destination ); + $remote_destination = str_replace( + '/usr/share/wordpress', + '/var/lib/wordpress', + $remote_destination + ); + //Locate which directory to copy to the new folder, This is based on the actual folder holding the files. if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); } elseif ( count( $source_files ) == 0 ) { ~~~~ Now installation is successful: Unpacking the package… Installing the theme… Successfully installed the theme Yo! Manga 1.4.6. Here I confirm that theme appears in `/var/lib/wordpress/wp-content/themes/yo-manga` but not in the list of themes in wordpress because the latter completely ignores `/var/lib/wordpress/wp-content/themes/`. So I make a symlink ln -s /var/lib/wordpress/wp-content/themes/yo-manga /usr/share/wordpress/wp-content/themes/yo-manga and only then new theme appears in wordpress. Unfortunately my PHP knowledge is not sufficient to find how to teach wordpress to look for themes in `/var/lib/wordpress/wp-content/themes`. It seems that wordpress needs patching to use themes from `/var/lib/wordpress/wp-content/themes`. Package already ship trigger (I think) to symlink everything from `/usr/share/wordpress/wp-content/themes/` to `/var/lib/wordpress/wp-content/themes` so already installed themes will not be affected. -- Cheers, Dmitry Smirnov GPG key : 4096R/53968D1B --- The truth is incontrovertible, malice may attack it, ignorance may deride it, but in the end; there it is. -- Winston Churchill
signature.asc
Description: This is a digitally signed message part.