We use the $install_location var to throw a message exception when the directory is really defined in $directory:
/**
* Make sure the installation parent directory exists and is writable.
*
* @param FileTransfer $filetransfer
* Object which is a child of FileTransfer.
* @param string $directory
* The installation directory to prepare.
*/
public function prepareInstallDirectory(&$filetransfer, $directory) {
// Make the parent dir writable if need be and create the dir.
if (!is_dir($directory)) {
$parent_dir = dirname($directory);
if (!is_writable($parent_dir)) {
@chmod($parent_dir, 0755);
// It is expected that this will fail if the directory is owned by the
// FTP user. If the FTP user == web server, it will succeed.
try {
$filetransfer->createDirectory($directory);
$this->makeWorldReadable($filetransfer, $directory);
}
catch (FileTransferException $e) {
// Probably still not writable. Try to chmod and do it again.
// @todo: Make a new exception class so we can catch it differently.
try {
$old_perms = substr(sprintf('%o', fileperms($parent_dir)), -4);
$filetransfer->chmod($parent_dir, 0755);
$filetransfer->createDirectory($directory);
$this->makeWorldReadable($filetransfer, $directory);
// Put the permissions back.
$filetransfer->chmod($parent_dir, intval($old_perms, 8));
}
catch (FileTransferException $e) {
$message = t($e->getMessage(), $e->arguments);
$throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $install_location, '%reason' => $message));
throw new UpdaterException($throw_message);
}
}
// Put the parent directory back.
@chmod($parent_dir, 0555);
}
}
Comments
Comment #1
oriol_e9gComment #2
oriol_e9gComment #3
andypostSuppose this kind of issues should be marked as Novice and Quick fix
also should be checked as backportable prepareInstallDirectory/7
Comment #4
dries commentedLooks good and confirmed that this is a minor bug in both 7.x and 8.x.
Committed to 8.x and back-ported to 7.x. Thanks!