#42628 closed defect (bug) (fixed)
New function flatten_dirlist in 4.9 does't play nice with folders with numeric names
Reported by: | edo888 | Owned by: | dd32 |
---|---|---|---|
Milestone: | 4.9.1 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Upgrade/Install | Keywords: | needs-patch |
Focuses: | administration | Cc: |
Description
Hi,
When you have folders with numeric names in your plugin the flatten_dirlist function will replace the filename(folder name) with 0. Since the plugin usually doesn't have a folder with 0 name it becomes unwritable and plugin update fails. This happens, because flatten_dirlist function uses array_merge function which doesn't preserve the keys and does re-indexing. http://php.net/manual/en/function.array-merge.php
wp-admin/includes/class-wp-upgrader.php:
<?php protected function flatten_dirlist( $nested_files, $path = '' ) { $files = array(); foreach ( $nested_files as $name => $details ) { $files[ $path . $name ] = $details; // Append children recursively if ( ! empty( $details['files'] ) ) { $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); $files = array_merge( $files, $children ); } } return $files; }
As you see currently it uses
<?php $files = array_merge( $files, $children );
It should be
<?php $files = $files + $children;
so the folders with numeric names will be preserved.
Thanks!
Change History (7)
#2
@
7 years ago
@dd32 You can check GTranslate plugin https://wordpress.org/plugins/gtranslate/
You can install version 2.8.31 and try to update to the latest version.
Thanks!
Note: See
TracTickets for help on using
tickets.
Hi @edo888 and thanks for reporting this, I'm moving it to 4.9.1 for review.
Are you aware of any plugins hosted on WordPress.org which are affected by this?