diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index c8974e6..d1d3790 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -250,21 +250,28 @@ function filter_formats($account = NULL) { uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); } - // Build a list of user-specific formats. - if (isset($account) && !isset($formats['user'][$account->uid])) { + // If no user was specified, return all formats. + if (!isset($account)) { + return $formats['all']; + } + // Ensure we have a proper user object. if (!($account instanceof UserInterface)) { $account = entity_load('user', $account->uid); } - $formats['user'][$account->uid] = array(); + + // Build a list of user-specific formats. + $account_id = $account->id(); + if (!isset($formats['user'][$account_id])) { + $formats['user'][$account_id] = array(); foreach ($formats['all'] as $format) { if ($format->access('view', $account)) { - $formats['user'][$account->uid][$format->format] = $format; + $formats['user'][$account_id][$format->format] = $format; } } } - return isset($account) ? $formats['user'][$account->uid] : $formats['all']; + return $formats['user'][$account_id]; } /** diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php index 5bb895e..1ebdaf4 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\user\Plugin\Core\Entity\User; +use Drupal\user\UserInterface; /** * Defines the access controller for the filter format entity type. @@ -19,7 +19,7 @@ class FilterFormatAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, User $account) { + protected function checkAccess(EntityInterface $entity, $operation, $langcode, UserInterface $account) { // Handle special cases up front. All users have access to the fallback // format. if ($entity->id() == filter_fallback_format()) {