Commit 57170a6a authored by xjm's avatar xjm

Revert "Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu,...

Revert "Issue #2244513 by kim.pepper, phenaproxima, 20th, andrei.dincu, beejeebus, Berdir, jibran, alexpott, andypost, larowlan, Chadwick Wood, Wim Leers, acbramley, YesCT, sun, tim.plunkett, chx: Move the unmanaged file APIs to the file_system service (file.inc)"

This reverts commit 56be1a03.
parent 56be1a03
......@@ -1565,27 +1565,25 @@ services:
arguments: [ '@state' ]
asset.css.collection_optimizer:
class: Drupal\Core\Asset\CssCollectionOptimizer
arguments: [ '@asset.css.collection_grouper', '@asset.css.optimizer', '@asset.css.dumper', '@state', '@file_system']
arguments: [ '@asset.css.collection_grouper', '@asset.css.optimizer', '@asset.css.dumper', '@state' ]
asset.css.optimizer:
class: Drupal\Core\Asset\CssOptimizer
asset.css.collection_grouper:
class: Drupal\Core\Asset\CssCollectionGrouper
asset.css.dumper:
class: Drupal\Core\Asset\AssetDumper
arguments: ['@file_system']
asset.js.collection_renderer:
class: Drupal\Core\Asset\JsCollectionRenderer
arguments: [ '@state' ]
asset.js.collection_optimizer:
class: Drupal\Core\Asset\JsCollectionOptimizer
arguments: [ '@asset.js.collection_grouper', '@asset.js.optimizer', '@asset.js.dumper', '@state', '@file_system']
arguments: [ '@asset.js.collection_grouper', '@asset.js.optimizer', '@asset.js.dumper', '@state' ]
asset.js.optimizer:
class: Drupal\Core\Asset\JsOptimizer
asset.js.collection_grouper:
class: Drupal\Core\Asset\JsCollectionGrouper
asset.js.dumper:
class: Drupal\Core\Asset\AssetDumper
arguments: ['@file_system']
library.discovery:
class: Drupal\Core\Asset\LibraryDiscovery
arguments: ['@library.discovery.collector']
......
This diff is collapsed.
......@@ -15,7 +15,6 @@
use Drupal\Core\DrupalKernel;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Installer\Exception\AlreadyInstalledException;
use Drupal\Core\Installer\Exception\InstallerException;
......@@ -1107,7 +1106,7 @@ function install_base_system(&$install_state) {
// configurable. The temporary directory needs to match what is set in each
// test types ::prepareEnvironment() step.
$temporary_directory = dirname(PublicStream::basePath()) . '/temp';
\Drupal::service('file_system')->prepareDirectory($temporary_directory, FileSystemInterface::MODIFY_PERMISSIONS | FileSystemInterface::CREATE_DIRECTORY);
file_prepare_directory($temporary_directory, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
\Drupal::configFactory()->getEditable('system.file')
->set('path.temporary', $temporary_directory)
->save();
......@@ -1916,12 +1915,9 @@ function install_check_translations($langcode, $server_pattern) {
$online = FALSE;
// First attempt to create or make writable the files directory.
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$file_system->prepareDirectory($files_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
file_prepare_directory($files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Then, attempt to create or make writable the translations directory.
$file_system->prepareDirectory($translations_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
file_prepare_directory($translations_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Get values so the requirements errors can be specific.
if (drupal_verify_install_file($translations_directory, FILE_EXIST, 'dir')) {
......
......@@ -7,7 +7,6 @@
use Drupal\Core\Extension\Dependency;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\File\FileSystemInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\OpCodeCache;
......@@ -512,7 +511,7 @@ function drupal_install_config_directories() {
// public files directory, which has already been verified to be writable
// itself. But if it somehow fails anyway, the installation cannot proceed.
// Bail out using a similar error message as in system_requirements().
if (!\Drupal::service('file_system')->prepareDirectory($config_directories[CONFIG_SYNC_DIRECTORY], FileSystemInterface::CREATE_DIRECTORY)
if (!file_prepare_directory($config_directories[CONFIG_SYNC_DIRECTORY], FILE_CREATE_DIRECTORY)
&& !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', [
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
......@@ -539,13 +538,12 @@ function drupal_install_config_directories() {
* TRUE if the config directory exists and is writable.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.x. Use
* config_get_config_directory() and
* \Drupal\Core\File\FileSystemInterface::prepareDirectory() instead.
* config_get_config_directory() and file_prepare_directory() instead.
*
* @see https://www.drupal.org/node/2501187
*/
function install_ensure_config_directory($type) {
@trigger_error('install_ensure_config_directory() is deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use config_get_config_directory() and \Drupal\Core\File\FileSystemInterface::prepareDirectory() instead. See https://www.drupal.org/node/2501187.', E_USER_DEPRECATED);
@trigger_error('install_ensure_config_directory() is deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use config_get_config_directory() and file_prepare_directory() instead. See https://www.drupal.org/node/2501187.', E_USER_DEPRECATED);
// The config directory must be defined in settings.php.
global $config_directories;
if (!isset($config_directories[$type])) {
......@@ -555,7 +553,7 @@ function install_ensure_config_directory($type) {
// directories that the installer creates.
else {
$config_directory = config_get_config_directory($type);
return \Drupal::service('file_system')->prepareDirectory($config_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
return file_prepare_directory($config_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}
}
......
......@@ -3,31 +3,12 @@
namespace Drupal\Core\Asset;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
/**
* Dumps a CSS or JavaScript asset.
*/
class AssetDumper implements AssetDumperInterface {
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* AssetDumper constructor.
*
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file handler.
*/
public function __construct(FileSystemInterface $file_system = NULL) {
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*
......@@ -43,13 +24,8 @@ public function dump($data, $file_extension) {
$path = 'public://' . $file_extension;
$uri = $path . '/' . $filename;
// Create the CSS or JS file.
$this->getFileSystem()->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
try {
if (!file_exists($uri) && !$this->getFileSystem()->saveData($data, $uri, FileSystemInterface::EXISTS_REPLACE)) {
return FALSE;
}
}
catch (FileException $e) {
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
if (!file_exists($uri) && !file_unmanaged_save_data($data, $uri, FILE_EXISTS_REPLACE)) {
return FALSE;
}
// If CSS/JS gzip compression is enabled and the zlib extension is available
......@@ -61,30 +37,11 @@ public function dump($data, $file_extension) {
// aren't working can set css.gzip to FALSE in order to skip
// generating a file that won't be used.
if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) {
try {
if (!file_exists($uri . '.gz') && !$this->getFileSystem()->saveData(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
return FALSE;
}
}
catch (FileException $e) {
if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
return FALSE;
}
}
return $uri;
}
/**
* Helper method for returning the file system service.
*
* @return \Drupal\Core\File\FileSystemInterface
* The file system service.
*/
private function getFileSystem() {
if (!$this->fileSystem) {
@trigger_error('\Drupal\Core\File\FileSystemInterface is a dependency of this class in Drupal 8.7.0 and will be required before Drupal 9.0.0. See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
$this->fileSystem = \Drupal::service('file_system');
}
return $this->fileSystem;
}
}
......@@ -2,7 +2,6 @@
namespace Drupal\Core\Asset;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\State\StateInterface;
/**
......@@ -38,13 +37,6 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
*/
protected $state;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* Constructs a CssCollectionOptimizer.
*
......@@ -56,19 +48,12 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface {
* The dumper for optimized CSS assets.
* @param \Drupal\Core\State\StateInterface $state
* The state key/value store.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system service.
*/
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state, FileSystemInterface $file_system = NULL) {
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) {
$this->grouper = $grouper;
$this->optimizer = $optimizer;
$this->dumper = $dumper;
$this->state = $state;
if (!$file_system) {
@trigger_error('The file_system service must be passed to CssCollectionOptimizer::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
$file_system = \Drupal::service('file_system');
}
$this->fileSystem = $file_system;
}
/**
......@@ -193,7 +178,7 @@ public function deleteAll() {
$delete_stale = function ($uri) {
// Default stale file threshold is 30 days.
if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
$this->fileSystem->delete($uri);
file_unmanaged_delete($uri);
}
};
file_scan_directory('public://css', '/.*/', ['callback' => $delete_stale]);
......
......@@ -2,7 +2,6 @@
namespace Drupal\Core\Asset;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\State\StateInterface;
/**
......@@ -38,13 +37,6 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
*/
protected $state;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* Constructs a JsCollectionOptimizer.
*
......@@ -56,19 +48,12 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface {
* The dumper for optimized JS assets.
* @param \Drupal\Core\State\StateInterface $state
* The state key/value store.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system service.
*/
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state, FileSystemInterface $file_system = NULL) {
public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) {
$this->grouper = $grouper;
$this->optimizer = $optimizer;
$this->dumper = $dumper;
$this->state = $state;
if (!$file_system) {
@trigger_error('The file_system service must be passed to JsCollectionOptimizer::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
$file_system = \Drupal::service('file_system');
}
$this->fileSystem = $file_system;
}
/**
......@@ -195,7 +180,7 @@ public function deleteAll() {
$delete_stale = function ($uri) {
// Default stale file threshold is 30 days.
if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
$this->fileSystem->delete($uri);
file_unmanaged_delete($uri);
}
};
file_scan_directory('public://js', '/.*/', ['callback' => $delete_stale]);
......
......@@ -4,7 +4,6 @@
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Serialization\Yaml;
/**
......@@ -45,6 +44,7 @@ class FileStorage implements StorageInterface {
public function __construct($directory, $collection = StorageInterface::DEFAULT_COLLECTION) {
$this->directory = $directory;
$this->collection = $collection;
// Use a NULL File Cache backend by default. This will ensure only the
// internal static caching of FileCache is used and thus avoids blowing up
// the APCu cache.
......@@ -76,7 +76,7 @@ public static function getFileExtension() {
*/
protected function ensureStorage() {
$dir = $this->getCollectionDirectory();
$success = \Drupal::service('file_system')->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
$success = file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Only create .htaccess file in root directory.
if ($dir == $this->directory) {
$success = $success && file_save_htaccess($this->directory, TRUE, TRUE);
......
......@@ -6,7 +6,6 @@
*/
use Drupal\Core\Database\Database;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException;
......@@ -227,7 +226,7 @@ function hook_modules_installed($modules) {
function hook_install() {
// Create the styles directory and ensure it's writable.
$directory = file_default_scheme() . '://styles';
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}
/**
......@@ -283,7 +282,7 @@ function hook_modules_uninstalled($modules) {
*/
function hook_uninstall() {
// Remove the styles directory and generated images.
\Drupal::service('file_system')->deleteRecursive(file_default_scheme() . '://styles');
file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
}
/**
......
<?php
namespace Drupal\Core\File\Exception;
/**
* Exception thrown when a file's destination directory is not ready.
*
* A directory can be considered not ready when it either does not exist, or
* is not writable.
*/
class DirectoryNotReadyException extends FileException {
}
<?php
namespace Drupal\Core\File\Exception;
/**
* Base class for exceptions related to file handling operations.
*/
class FileException extends \RuntimeException {
}
<?php
namespace Drupal\Core\File\Exception;
/**
* Exception thrown when a file unexpectedly exists.
*/
class FileExistsException extends FileException {
}
<?php
namespace Drupal\Core\File\Exception;
/**
* Exception thrown when a file is expected to exist but does not.
*/
class FileNotExistsException extends FileException {
}
<?php
namespace Drupal\Core\File\Exception;
/**
* Exception thrown when file cannot be written to disk.
*/
class FileWriteException extends FileException {
}
<?php
namespace Drupal\Core\File\Exception;
/**
* Exception thrown when a target is not a regular file (e.g. a directory).
*/
class NotRegularFileException extends FileException {
}
This diff is collapsed.
......@@ -7,31 +7,6 @@
*/
interface FileSystemInterface {
/**
* Flag for dealing with existing files: Appends number until name is unique.
*/
const EXISTS_RENAME = 0;
/**
* Flag for dealing with existing files: Replace the existing file.
*/
const EXISTS_REPLACE = 1;
/**
* Flag for dealing with existing files: Do nothing and return FALSE.
*/
const EXISTS_ERROR = 2;
/**
* Flag used by ::prepareDirectory() -- create directory if not present.
*/
const CREATE_DIRECTORY = 1;
/**
* Flag used by ::prepareDirectory() -- file permissions may be changed.
*/
const MODIFY_PERMISSIONS = 2;
/**
* Moves an uploaded file to a new location.
*
......@@ -262,202 +237,4 @@ public function uriScheme($uri);
*/
public function validScheme($scheme);
/**
* Copies a file to a new location without invoking the file API.
*
* This is a powerful function that in many ways performs like an advanced
* version of copy().
* - Checks if $source and $destination are valid and readable/writable.
* - If file already exists in $destination either the call will error out,
* replace the file or rename the file based on the $replace parameter.
* - If the $source and $destination are equal, the behavior depends on the
* $replace parameter. FILE_EXISTS_REPLACE will error out.
* FILE_EXISTS_RENAME will rename the file until the $destination is unique.
* - Provides a fallback using realpaths if the move fails using stream
* wrappers. This can occur because PHP's copy() function does not properly
* support streams if open_basedir is enabled. See
* https://bugs.php.net/bug.php?id=60456
*
* @param string $source
* A string specifying the filepath or URI of the source file.
* @param string $destination
* A URI containing the destination that $source should be copied to. The
* URI may be a bare filepath (without a scheme). If this value is omitted,
* Drupal's default files scheme will be used, usually "public://".
* @param int $replace
* Replace behavior when the destination file already exists:
* - FileManagerInterface::FILE_EXISTS_REPLACE - Replace the existing file.
* - FileManagerInterface::FILE_EXISTS_RENAME - Append _{incrementing
* number} until the filename is unique.
* - FileManagerInterface::FILE_EXISTS_ERROR - Throw an exception.
*
* @return string
* The path to the new file.
*
* @throws \Drupal\Core\File\Exception\FileException
* Implementation may throw FileException or its subtype on failure.
*/
public function copy($source, $destination = NULL, $replace = self::EXISTS_RENAME);
/**
* Deletes a file without database changes or hook invocations.
*
* This function should be used when the file to be deleted does not have an
* entry recorded in the files table.
*
* @param string $path
* A string containing a file path or (streamwrapper) URI.
*
* @throws \Drupal\Core\File\Exception\FileException
* Implementation may throw FileException or its subtype on failure.
*/
public function delete($path);
/**
* Deletes all files and directories in the specified filepath recursively.
*
* If the specified path is a directory then the function is called
* recursively to process the contents. Once the contents have been removed
* the directory is also removed.
*
* If the specified path is a file then it will be processed with delete()
* method.
*
* Note that this only deletes visible files with write permission.
*
* @param string $path
* A string containing either an URI or a file or directory path.
* @param callable|null $callback
* Callback function to run on each file prior to deleting it and on each
* directory prior to traversing it. For example, can be used to modify
* permissions.
*
* @throws \Drupal\Core\File\Exception\FileException
* Implementation may throw FileException or its subtype on failure.
*/
public function deleteRecursive($path, callable $callback = NULL);
/**
* Moves a file to a new location without database changes or hook invocation.
*
* This is a powerful function that in many ways performs like an advanced
* version of rename().
* - Checks if $source and $destination are valid and readable/writable.
* - Checks that $source is not equal to $destination; if they are an error
* is reported.
* - If file already exists in $destination either the call will error out,
* replace the file or rename the file based on the $replace parameter.
* - Works around a PHP bug where rename() does not properly support streams
* if safe_mode or open_basedir are enabled.
*
* @param string $source
* A string specifying the filepath or URI of the source file.
* @param string $destination
* A URI containing the destination that $source should be moved to. The
* URI may be a bare filepath (without a scheme) and in that case the
* default scheme (file://) will be used. If this value is omitted, Drupal's
* default files scheme will be used, usually "public://".
* @param int $replace
* Replace behavior when the destination file already exists:
* - FILE_EXISTS_REPLACE - Replace the existing file.
* - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
* is unique.
* - FILE_EXISTS_ERROR - Do nothing and return FALSE.
*
* @return string
* The path to the new file.
*
* @throws \Drupal\Core\File\Exception\FileException
* Implementation may throw FileException or its subtype on failure.
*
* @see https://bugs.php.net/bug.php?id=60456
*/
public function move($source, $destination = NULL, $replace = self::EXISTS_RENAME);
/**
* Saves a file to the specified destination without invoking file API.
*
* This function is identical to file_save_data() except the file will not be
* saved to the {file_managed} table and none of the file_* hooks will be
* called.
*
* @param string $data
* A string containing the contents of the file.
* @param string $destination
* A string containing the destination location. This must be a stream
* wrapper URI. If no value is provided, a randomized name will be generated
* and the file will be saved using Drupal's default files scheme, usually
* "public://".
* @param int $replace
* Replace behavior when the destination file already exists:
* - FILE_EXISTS_REPLACE - Replace the existing file.
* - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename
* is unique.
* - FILE_EXISTS_ERROR - Do nothing and return FALSE.
*
* @return string
* A string with the path of the resulting file, or FALSE on error.
*
* @throws \Drupal\Core\File\Exception\FileException
* Implementation may throw FileException or its subtype on failure.
*
* @see file_save_data()
*/
public function saveData($data, $destination = NULL, $replace = self::EXISTS_RENAME);
/**
* Checks that the directory exists and is writable.
*
* Directories need to have execute permissions to be considered a directory
* by FTP servers, etc.
*
* @param string $directory
* A string reference containing the name of a directory path or URI. A
* trailing slash will be trimmed from a path.
* @param int $options
* A bitmask to indicate if the directory should be created if it does
* not exist (FileSystemInterface::CREATE_DIRECTORY) or made writable if it
* is read-only (FileSystemInterface::MODIFY_PERMISSIONS).
*
* @return bool
* TRUE if the directory exists (or was created) and is writable. FALSE
* otherwise.
*/
public function prepareDirectory(&$directory, $options = self::MODIFY_PERMISSIONS);
/**
* Creates a full file path from a directory and filename.
*
* If a file with the specified name already exists, an alternative will be
* used.
*
* @param string $basename
* The filename.
* @param string $directory
* The directory or parent URI.
*
* @return string
* File path consisting of $directory and a unique filename based off
* of $basename.
*/
public function createFilename($basename, $directory);
/**
* Determines the destination path for a file.
*
* @param string $destination
* The desired final URI or filepath.
* @param int $replace
* Replace behavior when the destination file already exists.
* - FileSystemInterface::EXISTS_REPLACE - Replace the existing file.
* - FileSystemInterface::EXISTS_RENAME - Append _{incrementing number}
* until the filename is unique.
* - FileSystemInterface::EXISTS_ERROR - Do nothing and return FALSE.
*
* @return string|bool
* The destination filepath, or FALSE if the file already exists
* and FileSystemInterface::EXISTS_ERROR is specified.
*/
public function getDestinationFilename($destination, $replace);
}
......@@ -8,7 +8,6 @@
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\MissingDependencyException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Session\UserSession;
use Drupal\Core\Site\Settings;
......@@ -319,7 +318,7 @@ protected function initConfig(ContainerInterface $container) {
$config = $container->get('config.factory');
// Manually create the private directory.
\Drupal::service('file_system')->prepareDirectory($this->privateFilesDirectory, FileSystemInterface::CREATE_DIRECTORY);
file_prepare_directory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
// Manually configure the test mail collector implementation to prevent
// tests from sending out emails and collect them in state instead.
......@@ -576,7 +575,7 @@ protected function prepareEnvironment() {
// Create test directory ahead of installation so fatal errors and debug
// information can be logged during installation process.
\Drupal::service('file_system')->prepareDirectory($this->siteDirectory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Prepare filesystem directory paths.
$this->publicFilesDirectory = $this->siteDirectory . '/files';
......
......@@ -288,7 +288,7 @@ public function getValidOpml(array $feeds) {
$path = 'public://valid-opml.xml';
// Add the UTF-8 byte order mark.
return \Drupal::service('file_system')->saveData(chr(239) . chr(187) . chr(191) . $opml, $path);
return file_unmanaged_save_data(chr(239) . chr(187) . chr(191) . $opml, $path);
}
/**
......@@ -305,7 +305,7 @@ public function getInvalidOpml() {
EOF;
$path = 'public://invalid-