From 078cd826b6c24a632c49bd34badeafc8e0736de8 Mon Sep 17 00:00:00 2001 From: Dave Reid Date: Wed, 22 Aug 2012 15:04:05 +0200 Subject: [PATCH] Issue #1647440: Fixed PHP notices of invalid format IDs were requested on filter/tips. --- core/modules/filter/filter.module | 8 +++++++ core/modules/filter/filter.pages.inc | 7 ++--- .../Drupal/filter/Tests/FilterFormatAccessTest.php | 21 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 4d9bfef..48b1161 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -99,6 +99,14 @@ function filter_menu() { 'type' => MENU_SUGGESTED_ITEM, 'file' => 'filter.pages.inc', ); + $items['filter/tips/%filter_format'] = array( + 'title' => 'Compose tips', + 'page callback' => 'filter_tips_long', + 'page arguments' => array(2), + 'access callback' => 'filter_access', + 'access arguments' => array(2), + 'file' => 'filter.pages.inc', + ); $items['admin/config/content/formats'] = array( 'title' => 'Text formats', 'description' => 'Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters.', diff --git a/core/modules/filter/filter.pages.inc b/core/modules/filter/filter.pages.inc index ce8fdb9..70d3673 100644 --- a/core/modules/filter/filter.pages.inc +++ b/core/modules/filter/filter.pages.inc @@ -9,10 +9,9 @@ /** * Menu callback; show a page with long filter tips. */ -function filter_tips_long() { - $format_id = arg(2); - if ($format_id) { - $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE)); +function filter_tips_long($format = NULL) { + if (!empty($format)) { + $output = theme('filter_tips', array('tips' => _filter_tips($format->format, TRUE), 'long' => TRUE)); } else { $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE)); diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php index d6a08c6..2548a88 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php @@ -103,6 +103,27 @@ class FilterFormatAccessTest extends WebTestBase { $this->assertTrue(isset($options[$this->allowed_format->format]), t('The allowed text format appears as an option when adding a new node.')); $this->assertFalse(isset($options[$this->disallowed_format->format]), t('The disallowed text format does not appear as an option when adding a new node.')); $this->assertTrue(isset($options[filter_fallback_format()]), t('The fallback format appears as an option when adding a new node.')); + + // Check regular user access to the filter tips pages. + $this->drupalGet('filter/tips/' . $this->allowed_format->format); + $this->assertResponse(200); + $this->drupalGet('filter/tips/' . $this->disallowed_format->format); + $this->assertResponse(403); + $this->drupalGet('filter/tips/' . filter_fallback_format()); + $this->assertResponse(200); + $this->drupalGet('filter/tips/invalid-format'); + $this->assertResponse(404); + + // Check admin user access to the filter tips pages. + $this->drupalLogin($this->admin_user); + $this->drupalGet('filter/tips/' . $this->allowed_format->format); + $this->assertResponse(200); + $this->drupalGet('filter/tips/' . $this->disallowed_format->format); + $this->assertResponse(200); + $this->drupalGet('filter/tips/' . filter_fallback_format()); + $this->assertResponse(200); + $this->drupalGet('filter/tips/invalid-format'); + $this->assertResponse(404); } function testFormatRoles() { -- 1.7.7.5 (Apple Git-26)