#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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9.1 |
| Component: | Upgrade/Install | Version: | 4.9 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: | administration |
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
@
9 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!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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?