diff --git a/core/includes/file.inc b/core/includes/file.inc index 6e9c8e8..98904ff 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -452,8 +452,9 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST } // Attempt to resolve the URIs. This is necessary in certain configurations // (see above). - $real_source = \Drupal::service('file_system')->realpath($source) ?: $source; - $real_destination = \Drupal::service('file_system')->realpath($destination) ?: $destination; + $file_system = \Drupal::service('file_system'); + $real_source = $file_system->realpath($source) ?: $source; + $real_destination = $file_system->realpath($destination) ?: $destination; // Perform the copy operation. if (!@copy($real_source, $real_destination)) { \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination)); @@ -497,12 +498,13 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_EXISTS_RENAME) { $original_source = $source; $logger = \Drupal::logger('file'); + $file_system = \Drupal::service('file_system'); // Assert that the source file actually exists. if (!file_exists($source)) { // @todo Replace drupal_set_message() calls with exceptions instead. drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error'); - if (($realpath = \Drupal::service('file_system')->realpath($original_source)) !== FALSE) { + if (($realpath = $file_system->realpath($original_source)) !== FALSE) { $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath)); } else { @@ -542,8 +544,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E } // Assert that the source and destination filenames are not the same. - $real_source = \Drupal::service('file_system')->realpath($source); - $real_destination = \Drupal::service('file_system')->realpath($destination); + $real_source = $file_system->realpath($source); + $real_destination = $file_system->realpath($destination); if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) { drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', array('%file' => $source)), 'error'); $logger->notice('File %file could not be moved/copied because it would overwrite itself.', array('%file' => $source)); @@ -643,8 +645,9 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST } // Attempt to resolve the URIs. This is necessary in certain configurations // (see above) and can also permit fast moves across local schemes. - $real_source = \Drupal::service('file_system')->realpath($source) ?: $source; - $real_destination = \Drupal::service('file_system')->realpath($destination) ?: $destination; + $file_system = \Drupal::service('file_system'); + $real_source = $file_system->realpath($source) ?: $source; + $real_destination = $file_system->realpath($destination) ?: $destination; // Perform the move operation. if (!@rename($real_source, $real_destination)) { // Fall back to slow copy and unlink procedure. This is necessary for diff --git a/core/modules/system/system.install b/core/modules/system/system.install index d5a8ee9..354d537 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -425,19 +425,20 @@ function system_requirements($phase) { // Try to write the .htaccess files first, to prevent false alarms in case // (for example) the /tmp directory was wiped. file_ensure_htaccess(); + $file_system = \Drupal::service('file_system'); $htaccess_files['public://.htaccess'] = array( 'title' => t('Public files directory'), - 'directory' => \Drupal::service('file_system')->realpath('public://'), + 'directory' => $file_system->realpath('public://'), ); if (PrivateStream::basePath()) { $htaccess_files['private://.htaccess'] = array( 'title' => t('Private files directory'), - 'directory' => \Drupal::service('file_system')->realpath('private://'), + 'directory' => $file_system->realpath('private://'), ); } $htaccess_files['temporary://.htaccess'] = array( 'title' => t('Temporary files directory'), - 'directory' => \Drupal::service('file_system')->realpath('temporary://'), + 'directory' => $file_system->realpath('temporary://'), ); foreach ($htaccess_files as $htaccess_file => $info) { // Check for the string which was added to the recommended .htaccess file