Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILE_STATUS_PERMANENT is deprecated #262

Open
github-actions bot opened this issue Apr 21, 2023 · 1 comment
Open

FILE_STATUS_PERMANENT is deprecated #262

github-actions bot opened this issue Apr 21, 2023 · 1 comment
Labels
9.3.x archived Issues that are unlikely to work on in the future drupal-rector drupal-rector-covered This issue is covered in rector

Comments

@github-actions
Copy link

https://www.drupal.org/node/3022147

Introduced in branch/version: 9.3.x / 9.3.0

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_PERMANENT is 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();
      }
@github-actions github-actions bot added the 9.3.x label Apr 21, 2023
@bbrala
Copy link
Collaborator

bbrala commented Dec 23, 2023

@bbrala bbrala added drupal-rector drupal-rector-covered This issue is covered in rector labels Dec 23, 2023
@bbrala bbrala added the archived Issues that are unlikely to work on in the future label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.3.x archived Issues that are unlikely to work on in the future drupal-rector drupal-rector-covered This issue is covered in rector
Projects
None yet
Development

No branches or pull requests

1 participant