WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 3 years ago

#14401 reopened defect (bug)

Unable to locate WordPress Content directory (wp-content).

Reported by: pavelevap Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Filesystem API Keywords: needs-patch has-unit-tests
Focuses: Cc:

Description

Hi, I encounter this message on one server during plugin install: "Unable to locate WordPress Content directory (wp-content)."

PHP Version 5.2.0-8+etch1

Another info from Core Control plugin:

Direct Not Available

SSH2 Not Available

PHP FTP Extension Available

PHP FTP Sockets Available

ABSPATH: /home/www/domain.eu/subdomains/www/

WP_CONTENT_DIR /home/www/domain.eu/subdomains/www/wp-content WP_PLUGIN_DIR /home/www/domain.eu/subdomains/www/wp-content/plugins

DOCUMENT_ROOT (from phpinfo) /home/www/domain.eu/subdomains/www

I tried some hacks in wp-config.php, but I was not successfull.

When I tried ftpsockets, following error appears:

Warning: socket_last_error() expects parameter 1 to be resource, null given in /home/www/domain.eu/subdomains/www/wp-admin/includes/class-ftp-sockets.php on line 59

When I tried direct, following error appears:

Downloading install package from http://downloads.wordpress.org/plugin/wp-memory-usage.zip

Unpacking the package

Could not create directory. /home/www/domain.eu/subdomains/www/wp-content/upgrade/wp-memory-usage.tmp

Attachments (3)

14401.diff (554 bytes) - added by dd32 7 years ago.
wordpress-ftp-path-fix.diff (950 bytes) - added by vericgar 7 years ago.
14401.unit-tests.diff (1.2 KB) - added by dd32 5 years ago.

Download all attachments as: .zip

Change History (27)

#1 @dd32
8 years ago

When you connect via FTP, What is the path you see? Are the WordPress files located in / when viewed by FTP, or in a subdirectory? (If so, Which one?)

#2 @pavelevap
8 years ago

I can see path ftp://user.domain.eu@ftp.domain.eu and WordPress is directly in root directory (as soon as connected, I am in this folder). Or I am not sure how to get the path from FTP...

BTW, I wanted to read (probably your) article "WordPress Filesystem Abstraction FAQ" from http://dd32.id.au/ but it is not possible (only for registered users, registration not possible).

#3 @dd32
8 years ago

Or I am not sure how to get the path from FTP...

Most FTP Clients have a path section, is it just "/" in the Address bar perhaps?

Try adding this to your wp-config.php file, Whilst it should be guessed automatically, it might be failing for some reason:

define('FTP_CONTENT_DIR', '/');

but it is not possible (only for registered users, registration not possible).

Thats correct, Its down for a bit until i get around to fixing something.

#4 @pavelevap
8 years ago

I tried Filezilla and Total Commander, but I could not find current server path, everywhere is only ftp://user.domain.eu@ftp.domain.eu.

Adding your code to wp-config.php changed error, now there is:

"Unable to locate WordPress Plugin directory."

So, I tried adding to wp-config.php:

define('FTP_PLUGIN_DIR', '/');

It helps a little and following text appears (for installing plugin WP Memory Usage):

Downloading install package from http://downloads.wordpress.org/plugin/wp-memory-usage.zip

Unpacking the package…

Installing the plugin…

Warning: rename() [function.rename]: SAFE MODE Restriction in effect. The script whose uid is 8855 is not allowed to access /home/www/domain.eu/subdomains/www/wp-content/visitor-maps-backup owned by uid 33 in /home/www/domain.eu/subdomains/www/wp-content/plugins/visitor-maps/visitor-maps.php on line 1338

Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/www/domain.eu/subdomains/www/wp-admin/includes/class-wp-upgrader.php on line 189

Incompatible Archive.

Plugin install failed.

Tmp folder works well, also in directory upgrade there is subdirectory wp-memory-usage.tmp created with all files from this plugin.

First error is probably somehow related to "Visitor Maps and Who's Online" plugin. In wp-content there is folder visitor-maps-backup (chmod 755) which is for this plugin, but how can this influence installation of new plugin? After deactivating this plugin there is only the second error messagge about array_keys(). But this error can be also related to the original problem with unrecognized backslash in FTP_CONTENT_DIR?

#5 @dd32
8 years ago

define('FTP_PLUGIN_DIR', '/'); you'd have to set that to /wp-content/plugins/ instead, The error related to Visitor maps was probably due to the / define.

Without seeing the server environment for myself, I'm not sure where to goto next.. Feel free to contact me offtrac with the host details if you wish: wordpress at dd32.id.au

#6 @scribu
8 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Feel free to re-open, if a fix is needed.

#7 @scribu
8 years ago

  • Milestone Awaiting Review deleted

#8 follow-up: @pavelevap
7 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version changed from 3.0 to 3.1

Upgraded to latest 3.1 and problem is still here: "Unable to locate WordPress Content directory (wp-content)." It is strange, I use WordPress on many websites and different webhost, but this is related only to one specific webhost. But I found similar problems in Support forums, so this should be resolved...

I tried Core control plugin and several other settings for filesystem in wp-config.php, but nothing helped. I also sent login to dd32 several months ago, but did not get any answer. If anyone interested in this problem, I can give him WP admin and FTP access. Before moving to another webhost, we are only testing our domain...

#9 in reply to: ↑ 8 @sivel
7 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed
  • Version changed from 3.1 to 3.0

Replying to pavelevap:

Upgraded to latest 3.1 and problem is still here: "Unable to locate WordPress Content directory (wp-content)." It is strange, I use WordPress on many websites and different webhost, but this is related only to one specific webhost. But I found similar problems in Support forums, so this should be resolved...

I tried Core control plugin and several other settings for filesystem in wp-config.php, but nothing helped. I also sent login to dd32 several months ago, but did not get any answer. If anyone interested in this problem, I can give him WP admin and FTP access. Before moving to another webhost, we are only testing our domain...

First, please do not change the version, as we use that to trac when a bug was introduced/noticed.

Second, it may be required to update constants within your wp-config.php file on some configurations so that WP can know where all of the correct locations are: http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants

If you need support please use the support forums at http://wordpress.org/support/

#10 @hakre
7 years ago

Or WordPress Answers as they accept configuration issues as well. Please reference this ticket ID if you convert your problem into a question.

#11 @pavelevap
7 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Sorry for changing version.

I tried it in forums several months ago, but without answer.

I will summarize the whole problem - and try to explain why it can be WP related problem...

I am familiar with wp-config.php settings, but this case is special. No constant can solve my issue. Problem with installing/upgrading (ftpext and ftpsockets) has 2 parts:

Info from Core Control plugin (and phpinfo):

Direct Not Available

SSH2 Not Available

PHP FTP Extension Available

PHP FTP Sockets Available

1) First problem when using "ftpext" method.

Error: "Unable to locate WordPress Content directory (wp-content)."

Even if constants FTP_BASE, FTP_CONTENT_DIR and FTP_PLUGIN_DIR defined, for example:

define('FTP_BASE', '/home/www/domain.eu/subdomains/www/');
define('FTP_CONTENT_DIR', '/home/www/domain.eu/subdomains/www/wp-content/');
define('FTP_PLUGIN_DIR', '/home/www/domain.eu/subdomains/www/wp-content/plugins/');

I ended with following error:

"Could not create directory. /home"

I also do not understand why /home is the problematic directory? There is no need to create /home directory... No way to install/upgrade WordPress or plugins this way.

2) When I tried "ftpsockets", following error appears:

Warning: socket_last_error() expects parameter 1 to be resource, null given in /srv2/www/domain.eu/subdomains/www/wp-admin/includes/class-ftp-sockets.php on line 59

I noticed one problem, that WordPress thinks that address starts with /srv2/www (see socket error) but my phpinfo starts DOCUMENT_ROOT with /home/www. Please see error messages. When using ftpext, /home is used by Wordpress, but when using ftpsockets, /srv2 is used.

Sorry for reopening ticket once again, but after testing upgrade constants it may be problem on WP side, I guess...

#12 @dd32
7 years ago

  • Milestone set to Awaiting Review

Ignore what the phpinfo says for a start, it sounds like it's not what your FTP server says.. which is where the confusion seems to be occurring.

First of all, try the constants with the FTP path:

define('FTP_BASE', '/srv2/www/domain.eu/subdomains/www/');
define('FTP_CONTENT_DIR', '/srv2/www/domain.eu/subdomains/www/wp-content/');
define('FTP_PLUGIN_DIR', '/srv2/www/domain.eu/subdomains/www/wp-content/plugins/');

Next up, Ignore the WordPress upgrader for a moment, Connect via a standard FTP client, What is the path there? What is the directory that it opens to by default? What is the path that WordPress is installed in according to the FTP Client?

#13 @pavelevap
7 years ago

Yes, I tried to change home and srv2.

For ftpext is following error: "Could not create directory. /srv2", for ftpsockets is the same.

After connecting to FTP, I am in 0:/ or ftp://domain.eu@ftp.domain.eu directory by default. There are subdirectories log, stats, tmp, subdomains. In subdomains is another subdirectory www and in it is WordPress (wp-config.php, 0:/subdomains/www in FTP client).

#14 @dd32
7 years ago

try these defines then:

define('FTP_BASE', '/subdomains/www/');
define('FTP_CONTENT_DIR', '/subdomains/www/wp-content/');
define('FTP_PLUGIN_DIR', '/subdomains/www/wp-content/plugins/');

Once we work out which combination is needed, I can take a look at the code and see where it's falling over for you. It honestly sounds like is_dir() is returning incorrectly (or rather, is hitting an unexpected case). If we can get the process to work with the constants, it rules out that part of the code.

#15 @pavelevap
7 years ago

This combination is much more better:

Downloading install package from http://downloads.wordpress.org/plugin/health-check.0.1.zip…

Unpacking the package…

Installing the plugin…

Warning: array_keys() [function.array-keys]: The first argument should be an array in /srv2/www/domain.eu/subdomains/www/wp-admin/includes/class-wp-upgrader.php on line 189

Incompatible Archive.

Plugin install failed.

I saw this error in support forums many times. But it is another problem, I guess?

Maybe related: http://core.trac.wordpress.org/ticket/10831

Using ftpsockets, there is the same error.

@dd32
7 years ago

#16 @dd32
7 years ago

attachment 14401.diff added

Can you remove the constants and try the attached patch, and see if that works please?

(Find find_folder() in wp-admin/includes/class-wp-filesystem-base.php and replace $this->exists with $this->is_dir)

As for the array_keys error, I'll look into that once we get the path detection working correctly (Hopefully the error will disapear then..)

#17 @pavelevap
7 years ago

After applying patch and commenting 3 constants, initial error appears: "Unable to locate WordPress Content directory (wp-content)."

I can give you FTP and WP admin access, if you want to test it further...

#18 @SergeyBiryukov
7 years ago

  • Keywords reporter-feedback added

I'd like to test it further. Is it still happening in 3.2.1?

#19 @vericgar
7 years ago

  • Cc vericgar added
  • Keywords has-patch added

I ran into the same issue in 3.2.1.

The path on my host as visible to PHP is /f5/username/public/wp-content The path via FTP is /public/wp-content

Setting FTP_BASE and FTP_CONTENT_DIR helped, but then it errored out when looking for the themes directory. There was no option that I could find to override where it was looking for the theme directory.

I created a fix, that when using find_folder, if FTP_BASE is set, will look for ABSPATH in $folder and replace it with FTP_BASE. This fix should solve the issues with the paths between FTP and PHP being so different.

The patch is against 3.2.1.

#20 @c3mdigital
5 years ago

  • Keywords needs-refresh added; reporter-feedback removed

#21 @dd32
5 years ago

In 25057:

WP_Filesystem: Use the FTP_* path override constants during upgrades for prefixed paths, ie. use FTP_BASE for ABSPATH/sub-dir as well as just for ABSPATH/. Props vericgar for initial patch. See #14401

#22 @dd32
5 years ago

  • Keywords needs-patch has-unit-tests added; has-patch needs-refresh removed
  • Milestone changed from Awaiting Review to Future Release

Attachment 14401.unit-tests.diff​ added

I think that unit test cover the issue at hand in this ticket.

#23 @dd32
5 years ago

  • Component changed from Upgrade/Install to Filesystem
Note: See TracTickets for help on using tickets.