Make WordPress Core

Opened 3 years ago

#53191 new defect (bug)

When upgrading translations and destination does NOT exist all files end up in "wp-content/plugins"

Reported by: jobst's profile jobst Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.7.1
Component: Upgrade/Install Keywords:
Focuses: administration Cc:

Description

Hi

Current install:
Using the LATEST version of WordPress, the line numbers in this bug report relate to that version number.

Problem Discription:
I noticed a huge (220+) amount of .json, .mo and .po files in the "wp-content/plugins" directory. They shouldn't be there, in fact they should be in "wp-content/languages/plugins".

Overview of Fix:
I researched why that maybe the case and found the problem: if the directory "wp-content/languages/plugins" does NOT exist, all json/po/mo files are placed into "wp-content/plugins" - which in itself is a "no no" as the directory belongs to the "protected" directory set (I get to that later).
If the directory exists, there is no problem and all files end up in the correct directory and NOT in the "wp-content/plugins".

Where I think the error comes from:
For every language file that is updated the function "install_package()" in "class-wp-upgrader.php" is called. The parameter passed is an array containing the SOURCE and DESTINATION of the file needing an update.

The DESTINATION is correct when passed to the function "install_package()" but gets altered when the DESTINATION does not exist on line 501:

$remote_destination = $wp_filesystem->find_folder( $local_destination );

If the directory "wp-content/languages/plugins" exists, there is NO problem.

If the directory "wp-content/languages/plugins" DOES NOT exist, there is a problem and

 $remote_destination

is set to "wp-content/plugins" - which in fact belongs to the "protected directories"

What steps should be taken to consistently reproduce the problem?
Delete the directory "wp-content/languages/plugins" and update translations.
All *.json, *.po and *.mo files will end up in "wp-content/plugins"

Does the problem occur even when you deactivate all plugins and use the default theme?
Not related, as issue is MISSING PATH related.

In case it's relevant to the ticket, what is the expected output or result?
I would assume that the directory "wp-content/languages/plugins" should be created if it is missing and not place all files in "wp-content/plugins"

I for now have created the directory, but I saw on the Internet that MANY people seeing large amount of files in the plugins directory "wp-content/plugins".

Also "wp-content/plugins" belongs to the group of "protected directories" as seen on line 545 in file class-wp-upgrader.php:

$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );

so for that reason alone no file SHOULD end up in there.

Also, it's ugly to have 200+ language files in the plugin folder where you should only find directories for plugins.

Change History (0)

Note: See TracTickets for help on using tickets.