diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php index 0d49189..1db2c27 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php @@ -20,20 +20,26 @@ class FilterFormatAccessController extends EntityAccessController { * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - // Handle special cases up front. All users have access to the fallback - // format. - if ($entity->isFallbackFormat()) { - return TRUE; + // All users are allowed to view the fallback filter. + if ($operation == 'view') { + return $entity->isFallbackFormat() || $account->hasPermission($entity->getPermissionName()); } - if ($operation != 'view' && $account->hasPermission('administer filters')) { - return TRUE; + // We do not allow filter formats to be deleted through the UI, because that + // would render any content that uses them unusable. + if ($operation == 'delete') { + return FALSE; + } + + // The fallback format may not be disabled. + if ($operation == 'disable' && $entity->isFallbackFormat()) { + return FALSE; } - // Check the permission if one exists; otherwise, we have a non-existent - // format so we return FALSE. - $permission = $entity->getPermissionName(); - return !empty($permission) && $account->hasPermission($permission); + // For administrative operations, check the permission. + if (in_array($operation, array('update', 'disable')) && $account->hasPermission('administer filters')) { + return TRUE; + } } /** diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php index 3e1debf..b0f0714 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php @@ -129,15 +129,6 @@ public function getOperations(EntityInterface $entity) { if (isset($operations['edit'])) { $operations['edit']['title'] = t('Configure'); } - - // The fallback format may not be disabled. - if ($entity->isFallbackFormat()) { - unset($operations['disable']); - } - - // Formats can never be deleted. - unset($operations['delete']); - return $operations; } /**