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);
      }
    }
CommentFileSizeAuthor
#1 fix-undefined-var-1423510-1.patch708 bytesoriol_e9g
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oriol_e9g’s picture

oriol_e9g’s picture

Status: Needs work » Needs review
andypost’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix, +Novice, +Needs backport to D7

Suppose this kind of issues should be marked as Novice and Quick fix
also should be checked as backportable prepareInstallDirectory/7

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Looks 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!

Automatically closed -- issue fixed for 2 weeks with no activity.