diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php index 0a056fb..f9bd733 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php @@ -71,9 +71,7 @@ protected function textFormatHasTransformationFilters($format_id) { * Implements \Drupal\edit\EditPluginInterface::getAttachments(). */ public function getAttachments() { - global $user; - - $user_format_ids = array_keys(filter_formats($user)); + $user_format_ids = array_keys(filter_formats(user_load($GLOBALS['user']->uid))); $manager = drupal_container()->get('plugin.manager.editor'); $definitions = $manager->getDefinitions(); diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index 58be02b..941772c 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -4,6 +4,7 @@ * @file * Administrative page callbacks for the Filter module. */ +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Page callback: Form constructor for a form to list and reorder text formats. @@ -120,6 +121,9 @@ function filter_admin_format_page($format = NULL) { $format = entity_create('filter_format', array()); } + elseif (!$format->status()) { + throw new NotFoundHttpException(); + } return drupal_get_form('filter_admin_format_form', $format); } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index d195d4b..f864cb3 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -231,7 +231,7 @@ function filter_permission() { /** * Retrieves a list of enabled text formats, ordered by weight. * - * @param $account + * @param \Drupal\user\UserInterface|null $account * (optional) If provided, only those formats that are allowed for this user * account will be returned. All enabled formats will be returned otherwise. * Defaults to NULL. @@ -242,7 +242,7 @@ function filter_permission() { * * @see filter_formats_reset() */ -function filter_formats($account = NULL) { +function filter_formats(UserInterface $account = NULL) { $formats = &drupal_static(__FUNCTION__, array()); if (!isset($formats['all'])) { @@ -255,11 +255,6 @@ function filter_formats($account = NULL) { return $formats['all']; } - // Ensure we have a proper user object. - if (!($account instanceof UserInterface)) { - $account = entity_load('user', $account->uid); - } - // Build a list of user-specific formats. $account_id = $account->id(); if (!isset($formats['user'][$account_id])) { @@ -340,7 +335,7 @@ function filter_get_formats_by_role($rid) { * returned by filter_fallback_format() should be used, since that is intended * to be a safe, consistent format that is always available to all users. * - * @param $account + * @param \Drupal\user\UserInterface $account * (optional) The user account to check. Defaults to the currently logged-in * user. Defaults to NULL. * @@ -349,10 +344,9 @@ function filter_get_formats_by_role($rid) { * * @see filter_fallback_format() */ -function filter_default_format($account = NULL) { - global $user; +function filter_default_format(UserInterface $account = NULL) { if (!isset($account)) { - $account = $user; + $account = user_load($GLOBALS['user']->uid) ?: NULL; } // Get a list of formats for this user, ordered by weight. The first one // available is the user's default format. @@ -587,8 +581,6 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE, * The expanded element. */ function filter_process_format($element) { - global $user; - // Ensure that children appear as subkeys of this element. $element['#tree'] = TRUE; $blacklist = array( @@ -631,11 +623,12 @@ function filter_process_format($element) { ); // Get a list of formats that the current user has access to. - $formats = filter_formats($user); + $account = user_load($GLOBALS['user']->uid) ?: NULL; + $formats = filter_formats($account); // Use the default format for this user if none was selected. if (!isset($element['#format'])) { - $element['#format'] = filter_default_format($user); + $element['#format'] = filter_default_format($account); } // If multiple text formats are available, remove the fallback. The @@ -780,9 +773,8 @@ function theme_text_format_wrapper($variables) { * - id: Filter ID. */ function _filter_tips($format_id, $long = FALSE) { - global $user; - - $formats = filter_formats($user); + $account = user_load($GLOBALS['user']->uid) ?: NULL; + $formats = filter_formats($account); $tips = array(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php index 8205798..1b27ef4 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php @@ -37,6 +37,7 @@ protected function setUp() { parent::setUp(); $this->installConfig(array('system', 'filter')); + $this->installSchema('user', array('users')); } public function testAreaText() {