[wp-trac] [WordPress Trac] #42628: New function flatten_dirlist in 4.9 does't play nice with folders with numeric names
WordPress Trac
noreply at wordpress.org
Sun Nov 19 18:52:27 UTC 2017
#42628: New function flatten_dirlist in 4.9 does't play nice with folders with
numeric names
-----------------------------+-----------------------------
Reporter: edo888 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: 4.9
Severity: normal | Keywords:
Focuses: administration |
-----------------------------+-----------------------------
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
<?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
<?php
$files = array_merge( $files, $children );
}}}
It should be
{{{#!php
<?php
$files = $files + $children;
}}}
so the folders with numeric names will be preserved.
Thanks!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42628>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list