Unverified Commit 97a68691 authored by alexpott's avatar alexpott

Issue #3021450 by kim.pepper, jibran, voleger, alexpott, Berdir: Add...

Issue #3021450 by kim.pepper, jibran, voleger, alexpott, Berdir: Add @trigger_error to deprecated functions in file.inc and replace their usages
parent edd0191d
......@@ -18,21 +18,23 @@
use Drupal\Core\StreamWrapper\PublicStream;
/**
* Default mode for new directories. See drupal_chmod().
* Default mode for new directories.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::CHMOD_DIRECTORY.
*
* @see \Drupal\Core\File\FileSystemInterface::chmod()
* @see https://www.drupal.org/node/2418133
*/
const FILE_CHMOD_DIRECTORY = FileSystem::CHMOD_DIRECTORY;
/**
* Default mode for new files. See drupal_chmod().
* Default mode for new files.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::CHMOD_FILE.
*
* @see \Drupal\Core\File\FileSystemInterface::chmod()
* @see https://www.drupal.org/node/2418133
*/
const FILE_CHMOD_FILE = FileSystem::CHMOD_FILE;
......@@ -372,7 +374,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
// Write the .htaccess file.
if (file_exists($directory) && is_writable($directory) && file_put_contents($htaccess_path, $htaccess_lines)) {
return drupal_chmod($htaccess_path, 0444);
return \Drupal::service('file_system')->chmod($htaccess_path, 0444);
}
else {
$variables = ['%directory' => $directory, '@htaccess' => $htaccess_lines];
......@@ -527,17 +529,17 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// Build a destination URI if necessary.
if (!isset($destination)) {
$destination = file_build_uri(drupal_basename($source));
$destination = file_build_uri($file_system->basename($source));
}
// Prepare the destination directory.
if (file_prepare_directory($destination)) {
// The destination is already a directory, so append the source basename.
$destination = file_stream_wrapper_uri_normalize($destination . '/' . drupal_basename($source));
$destination = file_stream_wrapper_uri_normalize($destination . '/' . $file_system->basename($source));
}
else {
// Perhaps $destination is a dir/file?
$dirname = drupal_dirname($destination);
$dirname = $file_system->dirname($destination);
if (!file_prepare_directory($dirname)) {
// The destination is not valid.
$logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', ['%file' => $original_source, '%destination' => $dirname]);
......@@ -1060,12 +1062,13 @@ function file_upload_max_size() {
/**
* Sets the permissions on a file or directory.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::chmod().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_chmod($uri, $mode = NULL) {
@trigger_error('drupal_chmod() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::chmod(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->chmod($uri, $mode);
}
......@@ -1096,24 +1099,26 @@ function drupal_realpath($uri) {
/**
* Gets the name of the directory from a given path.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::dirname().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_dirname($uri) {
@trigger_error('drupal_dirname() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::dirname(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->dirname($uri);
}
/**
* Gets the filename from a given path.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::basename().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_basename($uri, $suffix = NULL) {
@trigger_error('drupal_basename() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::basename(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->basename($uri, $suffix);
}
......@@ -1121,36 +1126,39 @@ function drupal_basename($uri, $suffix = NULL) {
* Creates a directory, optionally creating missing components in the path to
* the directory.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::mkdir().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
@trigger_error('drupal_mkdir() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::mkdir(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->mkdir($uri, $mode, $recursive, $context);
}
/**
* Removes a directory.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::rmdir().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_rmdir($uri, $context = NULL) {
@trigger_error('drupal_rmdir() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::rmdir(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->rmdir($uri, $context);
}
/**
* Creates a file with a unique filename in the specified directory.
*
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
* @deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::tempnam().
*
* @see https://www.drupal.org/node/2418133
*/
function drupal_tempnam($directory, $prefix) {
@trigger_error('tempnam() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::tempnam(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->tempnam($directory, $prefix);
}
......
......@@ -1444,9 +1444,11 @@ function install_download_translation(&$install_state) {
*/
function install_retrieve_file($uri, $destination) {
$parsed_url = parse_url($uri);
if (is_dir(\Drupal::service('file_system')->realpath($destination))) {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
if (is_dir($file_system->realpath($destination))) {
// Prevent URIs with triple slashes when gluing parts together.
$path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']);
$path = str_replace('///', '//', "$destination/") . $file_system->basename($parsed_url['path']);
}
else {
$path = $destination;
......
......@@ -781,7 +781,7 @@ function drupal_install_mkdir($file, $mask, $message = TRUE) {
}
}
if (@drupal_mkdir($file, $mod)) {
if (@\Drupal::service('file_system')->mkdir($file, $mod)) {
return TRUE;
}
else {
......
......@@ -156,7 +156,7 @@ public function write($name, array $data) {
throw new StorageException('Failed to write configuration file: ' . $this->getFilePath($name));
}
else {
drupal_chmod($target);
\Drupal::service('file_system')->chmod($target);
}
$this->fileCache->set($target, $data);
......@@ -248,7 +248,7 @@ public function deleteAll($prefix = '') {
if ($success && $this->collection != StorageInterface::DEFAULT_COLLECTION) {
// Remove empty directories.
if (!(new \FilesystemIterator($this->getCollectionDirectory()))->valid()) {
drupal_rmdir($this->getCollectionDirectory());
\Drupal::service('file_system')->rmdir($this->getCollectionDirectory());
}
}
return $success;
......
......@@ -386,7 +386,7 @@ public function databaseType() {
public function createDatabase($database) {
// Verify the database is writable.
$db_directory = new \SplFileInfo(dirname($database));
if (!$db_directory->isDir() && !drupal_mkdir($db_directory->getPathName(), 0755, TRUE)) {
if (!$db_directory->isDir() && !\Drupal::service('file_system')->mkdir($db_directory->getPathName(), 0755, TRUE)) {
throw new DatabaseNotFoundException('Unable to create database directory ' . $db_directory->getPathName());
}
}
......
......@@ -68,7 +68,7 @@ protected function connect() {
// We cannot use file_directory_temp() here because we haven't yet
// successfully connected to the database.
$connection_info['default']['database'] = drupal_tempnam(sys_get_temp_dir(), 'sqlite');
$connection_info['default']['database'] = \Drupal::service('file_system')->tempnam(sys_get_temp_dir(), 'sqlite');
// In order to change the Database::$databaseInfo array, need to remove
// the active connection, then re-add it with the new info.
......
......@@ -897,7 +897,7 @@ public function guess($path) {
}
$extension = '';
$file_parts = explode('.', drupal_basename($path));
$file_parts = explode('.', \Drupal::service('file_system')->basename($path));
// Remove the first part: a full filename should not match an extension.
array_shift($file_parts);
......
......@@ -272,7 +272,7 @@ public function sanitizePath($path) {
*/
protected function copyDirectoryJailed($source, $destination) {
if ($this->isDirectory($destination)) {
$destination = $destination . '/' . drupal_basename($source);
$destination = $destination . '/' . \Drupal::service('file_system')->basename($source);
}
$this->createDirectory($destination);
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
......@@ -364,7 +364,7 @@ public function findChroot() {
$chroot = '';
while (count($parts)) {
$check = implode($parts, '/');
if ($this->isFile($check . '/' . drupal_basename(__FILE__))) {
if ($this->isFile($check . '/' . \Drupal::service('file_system')->basename(__FILE__))) {
// Remove the trailing slash.
return substr($chroot, 0, -1);
}
......
......@@ -47,9 +47,11 @@ protected function removeDirectoryJailed($directory) {
// Programmer error assertion, not something we expect users to see.
throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, ['%directory' => $directory]);
}
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) {
if ($file->isDir()) {
if (@!drupal_rmdir($filename)) {
if (@!$file_system->rmdir($filename)) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $filename]);
}
}
......@@ -59,7 +61,7 @@ protected function removeDirectoryJailed($directory) {
}
}
}
if (@!drupal_rmdir($directory)) {
if (@!$file_system->rmdir($directory)) {
throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $directory]);
}
}
......
......@@ -128,8 +128,7 @@ public function save($destination = NULL) {
$this->fileSize = filesize($destination);
$this->source = $destination;
// @todo Use File utility when https://www.drupal.org/node/2050759 is in.
if ($this->chmod($destination)) {
if (\Drupal::service('file_system')->chmod($destination)) {
return $return;
}
}
......@@ -208,15 +207,18 @@ public function scale($width, $height = NULL, $upscale = FALSE) {
* Integer value for the permissions. Consult PHP chmod() documentation for
* more information.
*
* @see drupal_chmod()
*
* @todo Remove when https://www.drupal.org/node/2050759 is in.
*
* @return bool
* TRUE for success, FALSE in the event of an error.
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
* Use \Drupal\Core\File\FileSystem::chmod().
*
* @see \Drupal\Core\File\FileSystemInterface::chmod()
* @see https://www.drupal.org/node/2418133
*/
protected function chmod($uri, $mode = NULL) {
return drupal_chmod($uri, $mode);
@trigger_error('chmod() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::chmod(). See https://www.drupal.org/node/2418133.', E_USER_DEPRECATED);
return \Drupal::service('file_system')->chmod($uri, $mode);
}
}
......@@ -134,7 +134,7 @@ protected function getLocalPath($uri = NULL) {
$realpath = realpath($path);
if (!$realpath) {
// This file does not yet exist.
$realpath = realpath(dirname($path)) . '/' . drupal_basename($path);
$realpath = realpath(dirname($path)) . '/' . \Drupal::service('file_system')->basename($path);
}
$directory = realpath($this->getDirectoryPath());
if (!$realpath || !$directory || strpos($realpath, $directory) !== 0) {
......@@ -397,9 +397,9 @@ public function rename($from_uri, $to_uri) {
/**
* Gets the name of the directory from a given path.
*
* This method is usually accessed through drupal_dirname(), which wraps
* around the PHP dirname() function because it does not support stream
* wrappers.
* This method is usually accessed through
* \Drupal\Core\File\FileSystemInterface::dirname(), which wraps around the
* PHP dirname() function because it does not support stream wrappers.
*
* @param string $uri
* A URI or path.
......@@ -407,7 +407,7 @@ public function rename($from_uri, $to_uri) {
* @return string
* A string containing the directory name.
*
* @see drupal_dirname()
* @see \Drupal\Core\File\FileSystemInterface::dirname()
*/
public function dirname($uri = NULL) {
list($scheme) = explode('://', $uri, 2);
......@@ -447,11 +447,13 @@ public function mkdir($uri, $mode, $options) {
else {
$localpath = $this->getLocalPath($uri);
}
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
if ($options & STREAM_REPORT_ERRORS) {
return drupal_mkdir($localpath, $mode, $recursive);
return $file_system->mkdir($localpath, $mode, $recursive);
}
else {
return @drupal_mkdir($localpath, $mode, $recursive);
return @$file_system->mkdir($localpath, $mode, $recursive);
}
}
......@@ -470,11 +472,13 @@ public function mkdir($uri, $mode, $options) {
*/
public function rmdir($uri, $options) {
$this->uri = $uri;
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
if ($options & STREAM_REPORT_ERRORS) {
return drupal_rmdir($this->getLocalPath());
return $file_system->rmdir($this->getLocalPath());
}
else {
return @drupal_rmdir($this->getLocalPath());
return @$file_system->rmdir($this->getLocalPath());
}
}
......
......@@ -167,9 +167,9 @@ public function realpath();
/**
* Gets the name of the directory from a given path.
*
* This method is usually accessed through drupal_dirname(), which wraps
* around the normal PHP dirname() function, which does not support stream
* wrappers.
* This method is usually accessed through
* \Drupal\Core\File\FileSystemInterface::dirname(), which wraps around the
* normal PHP dirname() function, which does not support stream wrappers.
*
* @param string $uri
* An optional URI.
......@@ -177,7 +177,7 @@ public function realpath();
* @return string
* A string containing the directory name, or FALSE if not applicable.
*
* @see drupal_dirname()
* @see \Drupal\Core\File\FileSystemInterface::dirname()
*/
public function dirname($uri = NULL);
......
......@@ -111,7 +111,7 @@ public static function findInfoFile($directory) {
return FALSE;
}
foreach ($info_files as $info_file) {
if (mb_substr($info_file->filename, 0, -9) == drupal_basename($directory)) {
if (mb_substr($info_file->filename, 0, -9) == \Drupal::service('file_system')->basename($directory)) {
// Info file Has the same name as the directory, return it.
return $info_file->uri;
}
......@@ -155,7 +155,7 @@ protected static function getExtensionInfo($directory) {
* The name of the project.
*/
public static function getProjectName($directory) {
return drupal_basename($directory);
return \Drupal::service('file_system')->basename($directory);
}
/**
......
......@@ -88,7 +88,9 @@ function color_library_info_alter(&$libraries, $extension) {
foreach ($color_paths as $color_path) {
// Color module currently requires unique file names to be used,
// which allows us to compare different file paths.
if (drupal_basename($path) == drupal_basename($color_path)) {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
if ($file_system->basename($path) == $file_system->basename($color_path)) {
// Replace the path to the new css file.
// This keeps the order of the stylesheets intact.
$index = array_search($path, array_keys($libraries[$name]['css'][$category]));
......@@ -429,7 +431,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
}
}
if (isset($file) && $file = dirname($file)) {
@drupal_rmdir($file);
@\Drupal::service('file_system')->rmdir($file);
}
// No change in color config, use the standard theme from color.inc.
......@@ -459,8 +461,10 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
->save();
// Copy over neutral images.
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
foreach ($info['copy'] as $file) {
$base = drupal_basename($file);
$base = $file_system->basename($file);
$source = $paths['source'] . $file;
try {
$filepath = $file_system->copy($source, $paths['target'] . $base);
......@@ -502,7 +506,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
// Rewrite stylesheet with new colors.
$style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
$base_file = drupal_basename($file);
$base_file = $file_system->basename($file);
$css[] = $paths['target'] . $base_file;
_color_save_stylesheet($paths['target'] . $base_file, $style, $paths);
}
......@@ -595,7 +599,7 @@ function _color_save_stylesheet($file, $style, &$paths) {
$paths['files'][] = $filepath;
// Set standard file permissions for webserver-generated files.
drupal_chmod($file);
\Drupal::service('file_system')->chmod($file);
}
/**
......@@ -645,8 +649,10 @@ function _color_render_images($theme, &$info, &$paths, $palette) {
// Cut out slices.
foreach ($info['slices'] as $file => $coord) {
list($x, $y, $width, $height) = $coord;
$base = drupal_basename($file);
$image = \Drupal::service('file_system')->realpath($paths['target'] . $base);
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$base = $file_system->basename($file);
$image = $file_system->realpath($paths['target'] . $base);
// Cut out slice.
if ($file == 'screenshot.png') {
......@@ -666,8 +672,8 @@ function _color_render_images($theme, &$info, &$paths, $palette) {
imagedestroy($slice);
$paths['files'][] = $image;
// Set standard file permissions for webserver-generated files
drupal_chmod($image);
// Set standard file permissions for webserver-generated files.
$file_system->chmod($image);
// Build before/after map of image paths.
$paths['map'][$file] = $base;
......
......@@ -73,7 +73,7 @@ public function testEditorEntityHooks() {
foreach ($image_paths as $key => $image_path) {
$image = File::create();
$image->setFileUri($image_path);
$image->setFilename(drupal_basename($image->getFileUri()));
$image->setFilename(\Drupal::service('file_system')->basename($image->getFileUri()));
$image->save();
$file_usage = $this->container->get('file.usage');
......
......@@ -172,7 +172,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
$uri = $file_system->copy($source->getFileUri(), $destination, $replace);
$file = $source->createDuplicate();
$file->setFileUri($uri);
$file->setFilename(drupal_basename($uri));
$file->setFilename($file_system->basename($uri));
// If we are replacing an existing file re-use its database record.
// @todo Do not create a new entity in order to update it. See
// https://www.drupal.org/node/2241865.
......@@ -188,7 +188,7 @@ function file_copy(FileInterface $source, $destination = NULL, $replace = FILE_E
// If we are renaming around an existing file (rather than a directory),
// use its basename for the filename.
elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
$file->setFilename(drupal_basename($destination));
$file->setFilename($file_system->basename($destination));
}
$file->save();
......@@ -267,7 +267,7 @@ function file_move(FileInterface $source, $destination = NULL, $replace = FILE_E
// If we are renaming around an existing file (rather than a directory),
// use its basename for the filename.
elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
$file->setFilename(drupal_basename($destination));
$file->setFilename(\Drupal::service('file_system')->basename($destination));
}
$file->save();
......@@ -590,7 +590,7 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
// If we are renaming around an existing file (rather than a directory),
// use its basename for the filename.
elseif ($replace == FILE_EXISTS_RENAME && is_file($destination)) {
$file->setFilename(drupal_basename($destination));
$file->setFilename(\Drupal::service('file_system')->basename($destination));
}
$file->save();
......@@ -1078,7 +1078,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
}
// Set the permissions on the new file.
drupal_chmod($file->getFileUri());
$file_system->chmod($file->getFileUri());
// If we are replacing an existing file re-use its database record.
// @todo Do not create a new entity in order to update it. See
......
......@@ -165,7 +165,7 @@ public function setTemporary() {
public static function preCreate(EntityStorageInterface $storage, array &$values) {
// Automatically detect filename if not set.
if (!isset($values['filename']) && isset($values['uri'])) {
$values['filename'] = drupal_basename($values['uri']);
$values['filename'] = \Drupal::service('file_system')->basename($values['uri']);
}
// Automatically detect filemime if not set.
......
......@@ -31,7 +31,7 @@ public function testFileTokenReplacement() {
$test_file = $this->getTestFile('text');
// Coping a file to test uploads with non-latin filenames.
$filename = drupal_dirname($test_file->getFileUri()) . '/текстовый файл.txt';
$filename = \Drupal::service('file_system')->dirname($test_file->getFileUri()) . '/текстовый файл.txt';
$test_file = file_copy($test_file, $filename);
// Create a new node with the uploaded file.
......
......@@ -134,7 +134,7 @@ public function testNormal() {
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'));
$this->assertTrue(is_file('temporary://' . $dir . '/' . trim(drupal_basename($image3_realpath))));
$this->assertTrue(is_file('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath))));
}
/**
......@@ -364,7 +364,7 @@ public function testNoUpload() {
public function testDrupalMovingUploadedFileError() {
// Create a directory and make it not writable.
$test_directory = 'test_drupal_move_uploaded_file_fail';
drupal_mkdir('temporary://' . $test_directory, 0000);
\Drupal::service('file_system')->mkdir('temporary://' . $test_directory, 0000);
$this->assertTrue(is_dir('temporary://' . $test_directory));
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
......
......@@ -125,7 +125,7 @@ public function testNormal() {
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'));
$this->assertTrue(is_file('temporary://' . $dir . '/' . trim(drupal_basename($image3_realpath))));
$this->assertTrue(is_file('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath))));
}
/**
......@@ -346,12 +346,14 @@ public function testNoUpload() {
public function testDrupalMovingUploadedFileError() {
// Create a directory and make it not writable.
$test_directory = 'test_drupal_move_uploaded_file_fail';
drupal_mkdir('temporary://' . $test_directory, 0000);
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$file_system->mkdir('temporary://' . $test_directory, 0000);
$this->assertTrue(is_dir('temporary://' . $test_directory));
$edit = [
'file_subdir' => $test_directory,
'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
'files[file_test_upload]' => $file_system->realpath($this->image->getFileUri()),
];
\Drupal::state()->set('file_test.disable_error_collection', TRUE);
......
......@@ -21,7 +21,7 @@ public function testWithoutFilename() {
$this->assertTrue($result, 'Unnamed file saved correctly.');