diff --git includes/bootstrap.inc includes/bootstrap.inc index ef2f4d1..480454a 100644 --- includes/bootstrap.inc +++ includes/bootstrap.inc @@ -19,7 +19,7 @@ define('DRUPAL_CORE_COMPATIBILITY', '7.x'); /** * Minimum supported version of PHP. */ -define('DRUPAL_MINIMUM_PHP', '5.2.0'); +define('DRUPAL_MINIMUM_PHP', '5.2.1'); /** * Minimum recommended value of PHP memory_limit. diff --git includes/file.inc includes/file.inc index 676d274..5ce4628 100644 --- includes/file.inc +++ includes/file.inc @@ -385,7 +385,9 @@ function file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS) */ function file_ensure_htaccess() { file_create_htaccess('public://', FALSE); - file_create_htaccess('private://', TRUE); + if (variable_get('file_private_path', FALSE)) { + file_create_htaccess('private://', TRUE); + } file_create_htaccess('temporary://', TRUE); } diff --git includes/stream_wrappers.inc includes/stream_wrappers.inc index 183af42..97ab755 100644 --- includes/stream_wrappers.inc +++ includes/stream_wrappers.inc @@ -598,7 +598,7 @@ class DrupalPrivateStreamWrapper extends DrupalLocalStreamWrapper { * Implements abstract public function getDirectoryPath() */ public function getDirectoryPath() { - return variable_get('file_private_path', conf_path() . '/private/files'); + return variable_get('file_private_path', ''); } /** @@ -625,7 +625,7 @@ class DrupalTemporaryStreamWrapper extends DrupalLocalStreamWrapper { * Implements abstract public function getDirectoryPath() */ public function getDirectoryPath() { - return variable_get('file_temporary_path', conf_path() . '/private/temp'); + return variable_get('file_temporary_path', sys_get_temp_dir()); } /** diff --git index.php index.php index c7d323b..a2210b0 100644 --- index.php +++ index.php @@ -18,5 +18,5 @@ define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; -drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); +drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);is_dir('private://'); menu_execute_active_handler(); diff --git modules/system/system.admin.inc modules/system/system.admin.inc index f11dbbb..1c2b970 100644 --- modules/system/system.admin.inc +++ modules/system/system.admin.inc @@ -1738,11 +1738,10 @@ function system_file_system_settings() { '#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'), '#after_build' => array('system_check_directory'), ); - $wrappers = file_get_stream_wrappers(); - $options = array( - 'public' => $wrappers['public']['description'], - 'private' => $wrappers['private']['description'] - ); + $wrappers = array_intersect_key(file_get_stream_wrappers(), array('public' => 1, 'private' => 1)); + foreach ($wrappers as $key => $info) { + $options[$key] = $info['description']; + } $form['file_default_scheme'] = array( '#type' => 'radios', '#title' => t('Default download method'), diff --git modules/system/system.install modules/system/system.install index a14627a..e13b0ae 100644 --- modules/system/system.install +++ modules/system/system.install @@ -210,8 +210,9 @@ function system_requirements($phase) { // Test files directories. $directories = array( variable_get('file_public_path', conf_path() . '/files'), - variable_get('file_private_path', conf_path() . '/private/files'), - variable_get('file_temporary_path', conf_path() . '/private/temp'), + // By default no private files directory is configured. + variable_get('file_private_path', FALSE), + variable_get('file_temporary_path', sys_get_temp_dir()), ); $requirements['file system'] = array( 'title' => $t('File system'), @@ -220,6 +221,9 @@ function system_requirements($phase) { $error = ''; // For installer, create the directories if possible. foreach ($directories as $directory) { + if (!$directory) { + continue; + } if ($phase == 'install') { file_prepare_directory($directory, FILE_CREATE_DIRECTORY); } diff --git modules/system/system.module modules/system/system.module index 1f7d348..2b175bd 100644 --- modules/system/system.module +++ modules/system/system.module @@ -501,7 +501,8 @@ function system_menu() { 'title' => 'File download', 'page callback' => 'file_download', 'page arguments' => array('private'), - 'access callback' => TRUE, + 'access callback' => 'variable_get', + 'access arguments' => array('file_private_path', FALSE), 'type' => MENU_CALLBACK, ); $items['system/temporary'] = array( @@ -1451,23 +1452,28 @@ function system_library() { * Implements hook_stream_wrappers(). */ function system_stream_wrappers() { - return array( + $wrappers = array( 'public' => array( 'name' => t('Public files'), 'class' => 'DrupalPublicStreamWrapper', 'description' => t('Public local files served by the webserver.'), ), - 'private' => array( - 'name' => t('Private files'), - 'class' => 'DrupalPrivateStreamWrapper', - 'description' => t('Private local files served by Drupal.'), - ), 'temporary' => array( 'name' => t('Temporary files'), 'class' => 'DrupalTemporaryStreamWrapper', 'description' => t('Temporary local files for upload and previews.'), ) ); + // Only register the private file stream wrapper if + // a file path has been set. + if (variable_get('file_private_path', FALSE)) { + $wrappers['private'] = array( + 'name' => t('Private files'), + 'class' => 'DrupalPrivateStreamWrapper', + 'description' => t('Private local files served by Drupal.'), + ); + } + return $wrappers; } /** @@ -1978,6 +1984,9 @@ function system_admin_menu_block($item) { */ function system_check_directory($form_element) { $directory = $form_element['#value']; + if (strlen($directory) == 0) { + return $form_element; + } if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) { // If the directory does not exists and cannot be created. @@ -1990,7 +1999,7 @@ function system_check_directory($form_element) { form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory))); watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR); } - else { + elseif(is_dir($directory)) { if ($form_element['#name'] == 'file_public_path') { // Create public .htaccess file. file_create_htaccess($directory, FALSE);