Download & Extend

Undefined var in prepareInstallDirectory

Project:Drupal core
Version:8.x-dev
Component:update.module
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed (fixed)
Issue tags:needs backport to D7, Novice, Quick fix

Issue Summary

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

#1

AttachmentSizeStatusTest resultOperations
fix-undefined-var-1423510-1.patch708 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 33,945 pass(es).View details

#2

Status:needs work» needs review

#3

Status:needs review» reviewed & tested by the community

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

#4

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!

#5

Status:fixed» closed (fixed)

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

nobody click here