Local Fonts deleting error

Created on 8 November 2023, about 1 year ago
Updated 14 March 2024, 9 months ago

Problem/Motivation

When I try to delete local font I receive an error

Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck().

Proposed resolution

I suppose accessCheck(FALSE) method should be added in local_fonts_entity_delete hook same as in general fontyourface_delete hook.

function local_fonts_entity_delete(EntityInterface $entity) {
  if ($entity instanceof LocalFontConfigEntity) {
    $font_id = 'local_fonts://' . $entity->id();
    $fids = \Drupal::entityQuery('font')
      ->condition('url', $font_id)
      ->accessCheck(FALSE)
      ->range(0, 50)
      ->execute();
    if (!empty($fids)) {
      $storage_handler = \Drupal::entityTypeManager()->getStorage('font');
      $fonts = $storage_handler->loadMultiple(array_keys($fids));
      $storage_handler->delete($fonts);
    }
  }
🐛 Bug report
Status

Closed: duplicate

Version

4.0

Component

Code (general)

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024