? 418302-copy-setttings-164.patch ? 418302-copy-setttings-165.patch Index: INSTALL.txt =================================================================== RCS file: /cvs/drupal/drupal/INSTALL.txt,v retrieving revision 1.81 diff -u -p -r1.81 INSTALL.txt --- INSTALL.txt 30 Jul 2010 01:59:14 -0000 1.81 +++ INSTALL.txt 1 Sep 2010 20:31:48 -0000 @@ -79,13 +79,15 @@ INSTALLATION http://drupal.org/project/translations and download the package. Extract the contents to the same directory where you extracted Drupal into. -2. CREATE THE CONFIGURATION FILE AND GRANT WRITE PERMISSIONS +2. IF NECESSARY, CREATE THE CONFIGURATION FILE AND GRANT WRITE PERMISSIONS Drupal comes with a default.settings.php file in the sites/default directory. The installer uses this file as a template to create your settings file using the details you provide through the install process. To avoid problems when upgrading, Drupal is not packaged with an actual - settings file. You must create a file named settings.php. You may do so + settings file. During installation, Drupal will try to create this settings + file automatically. If this fails (which it can due to different server + setups), you must create a file named settings.php yourself. You may do so by making a copy of default.settings.php (or create an empty file with this name in the same directory). For example, (from the installation directory) make a copy of the default.settings.php file with the command: Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.226 diff -u -p -r1.226 file.inc --- includes/file.inc 22 Aug 2010 13:52:58 -0000 1.226 +++ includes/file.inc 1 Sep 2010 20:31:49 -0000 @@ -826,6 +826,22 @@ function file_unmanaged_copy($source, $d } /** + * Determines whether the owners of two files are identical. This works only on + * the local filesystem, not with stream wrapper URIs. + * + * @param $source + * A source file or directory. + * @param destination + * A destination file or directory. This must already exist. + * + * @return + * TRUE if the owners are identical, FALSE if they are not. + */ +function file_owners_identical($source, $destination) { + return fileowner($source) == fileowner($destination); +} + +/** * Given a relative path, construct a URI into Drupal's default files location. */ function file_build_uri($path) { Index: includes/install.core.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.core.inc,v retrieving revision 1.28 diff -u -p -r1.28 install.core.inc --- includes/install.core.inc 1 Sep 2010 01:24:05 -0000 1.28 +++ includes/install.core.inc 1 Sep 2010 20:31:49 -0000 @@ -1568,7 +1568,7 @@ function install_check_requirements($ins $exists = FALSE; // Verify that the directory exists. if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) { - // Check to make sure a settings.php already exists. + // Check if a settings.php file already exists. $file = $settings_file; if (drupal_verify_install_file($settings_file, FILE_EXIST)) { // If it does, make sure it is writable. @@ -1587,6 +1587,25 @@ function install_check_requirements($ins 'description' => st('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_settings_file)), ); } + // If default.settings.php is readable and settings.php does not exist yet, + // we can try to copy it. + // @todo We should probably be using something like file_unmanaged_copy($default_settings_file, $settings_file, FILE_EXISTS_ERROR)) + // here, but it doesn't work at the moment. + elseif (!$exists && drupal_verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file)) { + // Check if the copy was successfully performed and the owners of + // default.settings.php and the copied settings.php are identical. + // Additionally, make sure the settings file is writable. + if (file_owners_identical($default_settings_file, $settings_file)) { + $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE); + $exists = TRUE; + } + // If the file owners are not identical, delete the settings file. + // Otherwise, users on shared hosts might not be able to edit their + // settings file later on. The user will have to create it on their own. + else { + file_unmanaged_delete($settings_file); + } + } // If settings.php does not exist, throw an error. if (!$exists) { @@ -1594,7 +1613,7 @@ function install_check_requirements($ins 'title' => st('Settings file'), 'value' => st('The settings file does not exist.'), 'severity' => REQUIREMENT_ERROR, - 'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'INSTALL.txt')), + 'description' => st('An automated attempt to create this file failed, possibly due to a permissions problem. The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_settings_file, '@install_txt' => base_path() . 'INSTALL.txt')), ); } else { Index: modules/update/update.manager.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.manager.inc,v retrieving revision 1.24 diff -u -p -r1.24 update.manager.inc --- modules/update/update.manager.inc 29 Jul 2010 02:27:43 -0000 1.24 +++ modules/update/update.manager.inc 1 Sep 2010 20:31:49 -0000 @@ -416,7 +416,7 @@ function update_manager_update_ready_for // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a FileTransferLocal and invoke // update_authorize_run_update() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (file_owners_identical($project_real_location, conf_path())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new FileTransferLocal(DRUPAL_ROOT); update_authorize_run_update($filetransfer, $updates); @@ -593,7 +593,7 @@ function update_manager_install_form_sub // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a FileTransferLocal and invoke // update_authorize_run_install() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (file_owners_identical($project_real_location, conf_path())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new FileTransferLocal(DRUPAL_ROOT); call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));