By andypost on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
9.3.x
Introduced in version:
9.3.0
Issue links:
Description:
The constant FILE_STATUS_PERMANENT is deprecated.
- To check the status of a file, use
\Drupal\file\FileInterface::isPermanent()or\Drupal\file\FileInterface::isTemporary(). - To make a file permanent, use
\Drupal\file\FileInterface::setPermanent(). \Drupal\file\FileInterface::STATUS_PERMANENTis the internal replacement for the constant.
Before
$fids = Drupal::entityQuery('file')
->condition('status', FILE_STATUS_PERMANENT, '<>')
...
if ($file->status->value !== FILE_STATUS_PERMANENT) {
$file->status->value = FILE_STATUS_PERMANENT;
$file->save();
}
After
use Drupal\file\FileInterface;
...
$fids = Drupal::entityQuery('file')
->condition('status', FileInterface::STATUS_PERMANENT, '<>')
if ($file->isTemporary()) {
$file->setPermanent();
$file->save();
}
Impacts:
Module developers