function file_delete
Same name in other branches
- 7.x includes/file.inc \file_delete()
Deletes a file and its database record.
Instead of directly deleting a file, it is strongly recommended to delete file usages instead. That will automatically mark the file as temporary and remove it during cleanup.
Parameters
$fid: The file id.
Deprecated
in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityStorageInterface::delete() instead.
See also
\Drupal\file\FileUsage\FileUsageBase::delete()
\Drupal\Core\Entity\EntityStorageInterface::delete()
https://www.drupal.org/node/3021663
Related topics
1 call to file_delete()
- FileLegacyTest::testEntityLegacyCode in core/
modules/ file/ tests/ src/ Kernel/ FileLegacyTest.php - @expectedDeprecation file_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::loadMultiple(). See https://www.drupal.org/node/2266845 @expectedDeprecation file_load() is deprecated in…
File
-
core/
includes/ file.inc, line 778
Code
function file_delete($fid) {
@trigger_error('file_delete() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\Entity\\EntityStorageInterface::delete() instead. See https://www.drupal.org/node/3021663.', E_USER_DEPRECATED);
return file_delete_multiple([
$fid,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.