From 096b8c5a58a03abfff1654ec706842966add8acf Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sun, 16 Jun 2013 10:24:30 +0200 Subject: [PATCH] Issue #2010290 by tim.plunkett, larowlan, alexpott, ParisLiakos: Editing a config entity from a listing page results in a 'page not found'. --- .../Entity/ConfigEntityListController.php | 4 ++++ .../Drupal/action/ActionListController.php | 15 ++------------ .../config/Tests/ConfigEntityListTest.php | 6 +++--- .../Drupal/config/Tests/ConfigEntityTest.php | 14 ++++++------- .../Drupal/contact/CategoryListController.php | 16 --------------- .../contact/Tests/ContactSitewideTest.php | 18 ++++++++++++++++- .../lib/Drupal/menu/MenuListController.php | 1 - .../shortcut/ShortcutListController.php | 20 +++++++------------ .../shortcut/Tests/ShortcutSetsTest.php | 4 +++- .../taxonomy/VocabularyListController.php | 2 ++ .../Drupal/views/Tests/Wizard/BasicTest.php | 7 +++---- .../views_ui/Tests/DefaultViewsTest.php | 6 +++--- .../views_ui/ViewCloneFormController.php | 2 +- 13 files changed, 51 insertions(+), 64 deletions(-) diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php index c4fa043a423..f0d1c5c0030 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php @@ -31,6 +31,10 @@ class ConfigEntityListController extends EntityListController { $operations = parent::getOperations($entity); $uri = $entity->uri(); + // For configuration entities edit path is the MENU_DEFAULT_LOCAL_TASK and + // therefore should be accessed by the short route. + $operations['edit']['href'] = $uri['path']; + if (isset($this->entityInfo['entity_keys']['status'])) { if (!$entity->status()) { $operations['enable'] = array( diff --git a/core/modules/action/lib/Drupal/action/ActionListController.php b/core/modules/action/lib/Drupal/action/ActionListController.php index cc00880cafa..1ad8319b20e 100644 --- a/core/modules/action/lib/Drupal/action/ActionListController.php +++ b/core/modules/action/lib/Drupal/action/ActionListController.php @@ -111,19 +111,8 @@ class ActionListController extends ConfigEntityListController implements EntityC public function getOperations(EntityInterface $entity) { $operations = array(); if ($entity->isConfigurable()) { - $uri = $entity->uri(); - $operations['edit'] = array( - 'title' => t('Configure'), - 'href' => $uri['path'], - 'options' => $uri['options'], - 'weight' => 10, - ); - $operations['delete'] = array( - 'title' => t('Delete'), - 'href' => $uri['path'] . '/delete', - 'options' => $uri['options'], - 'weight' => 100, - ); + $operations = parent::getOperations($entity); + $operations['edit']['title'] = t('Configure'); } return $operations; } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index 10ff0a725e0..7917731720d 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -55,7 +55,7 @@ class ConfigEntityListTest extends WebTestBase { $expected_operations = array( 'edit' => array ( 'title' => t('Edit'), - 'href' => $uri['path'] . '/edit', + 'href' => $uri['path'], 'options' => $uri['options'], 'weight' => 10, ), @@ -134,7 +134,7 @@ class ConfigEntityListTest extends WebTestBase { $expected_operations = array( 'edit' => array( 'title' => t('Edit'), - 'href' => $uri['path'] . '/edit', + 'href' => $uri['path'], 'options' => $uri['options'], 'weight' => 10, ), @@ -211,7 +211,7 @@ class ConfigEntityListTest extends WebTestBase { $this->assertFieldByXpath('//td', 'antelope', "Machine name found for added 'Antelope' entity."); // Edit the entity using the operations link. - $this->assertLinkByHref('admin/structure/config_test/manage/antelope/edit'); + $this->assertLinkByHref('admin/structure/config_test/manage/antelope'); $this->clickLink('Edit', 1); $this->assertResponse(200); $this->assertTitle('Edit Antelope | Drupal'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index 05f3d7454ce..dfdd73c00ec 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -206,7 +206,7 @@ class ConfigEntityTest extends WebTestBase { $this->assertResponse(200); $this->assertRaw($message_insert); $this->assertNoRaw($message_update); - $this->assertLinkByHref("admin/structure/config_test/manage/$id/edit"); + $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Update the configuration entity. $edit = array( @@ -217,11 +217,11 @@ class ConfigEntityTest extends WebTestBase { $this->assertResponse(200); $this->assertNoRaw($message_insert); $this->assertRaw($message_update); - $this->assertLinkByHref("admin/structure/config_test/manage/$id/edit"); + $this->assertLinkByHref("admin/structure/config_test/manage/$id"); $this->assertLinkByHref("admin/structure/config_test/manage/$id/delete"); // Delete the configuration entity. - $this->drupalGet("admin/structure/config_test/manage/$id/edit"); + $this->drupalGet("admin/structure/config_test/manage/$id"); $this->drupalPost(NULL, array(), 'Delete'); $this->assertUrl("admin/structure/config_test/manage/$id/delete"); $this->drupalPost(NULL, array(), 'Delete'); @@ -231,7 +231,6 @@ class ConfigEntityTest extends WebTestBase { $this->assertRaw($message_delete); $this->assertNoText($label1); $this->assertNoLinkByHref("admin/structure/config_test/manage/$id"); - $this->assertNoLinkByHref("admin/structure/config_test/manage/$id/edit"); // Re-create a configuration entity. $edit = array( @@ -242,7 +241,7 @@ class ConfigEntityTest extends WebTestBase { $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); $this->assertText($label1); - $this->assertLinkByHref("admin/structure/config_test/manage/$id/edit"); + $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Rename the configuration entity's ID/machine name. $edit = array( @@ -256,9 +255,8 @@ class ConfigEntityTest extends WebTestBase { $this->assertNoText($label2); $this->assertText($label3); $this->assertNoLinkByHref("admin/structure/config_test/manage/$id"); - $this->assertNoLinkByHref("admin/structure/config_test/manage/$id/edit"); $id = $edit['id']; - $this->assertLinkByHref("admin/structure/config_test/manage/$id/edit"); + $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Create a configuration entity with '0' machine name. $edit = array( @@ -269,7 +267,7 @@ class ConfigEntityTest extends WebTestBase { $this->assertResponse(200); $message_insert = format_string('%label configuration has been created.', array('%label' => $edit['label'])); $this->assertRaw($message_insert); - $this->assertLinkByHref('admin/structure/config_test/manage/0/edit'); + $this->assertLinkByHref('admin/structure/config_test/manage/0'); $this->assertLinkByHref('admin/structure/config_test/manage/0/delete'); $this->drupalPost('admin/structure/config_test/manage/0/delete', array(), 'Delete'); $this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted'); diff --git a/core/modules/contact/lib/Drupal/contact/CategoryListController.php b/core/modules/contact/lib/Drupal/contact/CategoryListController.php index 8a0bb02da56..a17423b9dc2 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryListController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php @@ -19,22 +19,6 @@ class CategoryListController extends ConfigEntityListController { */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); - if (module_exists('field_ui')) { - $uri = $entity->uri(); - $operations['manage-fields'] = array( - 'title' => t('Manage fields'), - 'href' => $uri['path'] . '/fields', - 'options' => $uri['options'], - 'weight' => 11, - ); - $operations['manage-display'] = array( - 'title' => t('Manage display'), - 'href' => $uri['path'] . '/display', - 'options' => $uri['options'], - 'weight' => 12, - ); - } - if (!$entity->access('delete')) { unset($operations['delete']); } diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 64586ae5c3a..1c23bd255e2 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -53,7 +53,10 @@ class ContactSitewideTest extends WebTestBase { // Default category exists. $this->assertLinkByHref('admin/structure/contact/manage/feedback/delete'); // User category could not be changed or deleted. - $this->assertNoLinkByHref('admin/structure/contact/manage/personal'); + // Cannot use assertNoLinkByHref() as it does partial URL matching. + $edit_href = 'admin/structure/contact/manage/personal'; + $edit_link = $this->xpath('//a[@href=:href]', array(':href' => url($edit_href))); + $this->assertTrue(empty($edit_link), format_string('No link containing href %href found.', array('%href' => $edit_href))); $this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete'); $this->drupalGet('admin/structure/contact/manage/personal'); @@ -189,6 +192,19 @@ class ContactSitewideTest extends WebTestBase { $this->drupalGet('contact'); $this->assertResponse(403); $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => config('contact.settings')->get('flood.limit'), '@interval' => format_interval(600)))); + + // Test listing controller. + $this->drupalLogin($admin_user); + + $this->deleteCategories(); + + $label = $this->randomName(16); + $recipients = implode(',', array($recipients[0], $recipients[1], $recipients[2])); + $this->addCategory(drupal_strtolower($this->randomName(16)), $label, $recipients, '', FALSE); + $this->drupalGet('admin/structure/contact'); + $this->clickLink(t('Edit')); + $this->assertResponse(200); + $this->assertFieldByName('label', $label); } /** diff --git a/core/modules/menu/lib/Drupal/menu/MenuListController.php b/core/modules/menu/lib/Drupal/menu/MenuListController.php index 64a1c4d4bda..dfa60193f43 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuListController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuListController.php @@ -48,7 +48,6 @@ class MenuListController extends ConfigEntityListController { $uri = $entity->uri(); $operations['edit']['title'] = t('Edit menu'); - $operatuins['edit']['href'] = $uri['path']; $operations['add'] = array( 'title' => t('Add link'), 'href' => $uri['path'] . '/add', diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php index 46cb5105979..a40005ca977 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php @@ -27,24 +27,18 @@ class ShortcutListController extends ConfigEntityListController { * Overrides \Drupal\Core\Entity\EntityListController::getOperations(). */ public function getOperations(EntityInterface $entity) { + $operations = parent::getOperations($entity); $uri = $entity->uri(); + + $operations['edit']['title'] = t('Edit menu'); + $operations['edit']['href'] = $uri['path'] . '/edit'; + $operations['list'] = array( 'title' => t('List links'), 'href' => $uri['path'], ); - $operations['edit'] = array( - 'title' => t('Edit set'), - 'href' => $uri['path'] . '/edit', - 'options' => $uri['options'], - 'weight' => 10, - ); - if ($entity->access('delete')) { - $operations['delete'] = array( - 'title' => t('Delete set'), - 'href' => $uri['path'] . '/delete', - 'options' => $uri['options'], - 'weight' => 100, - ); + if (!$entity->access('delete')) { + unset($operations['delete']); } return $operations; } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php index f1f21ddf2b2..8a55dfd8d66 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php @@ -108,7 +108,9 @@ class ShortcutSetsTest extends ShortcutTestBase { $set = $this->set; $new_label = $this->randomName(); - $this->drupalPost('admin/config/user-interface/shortcut/manage/' . $set->id() . '/edit', array('label' => $new_label), t('Save')); + $this->drupalGet('admin/config/user-interface/shortcut'); + $this->clickLink(t('Edit menu')); + $this->drupalPost(NULL, array('label' => $new_label), t('Save')); $set = shortcut_set_load($set->id()); $this->assertTrue($set->label() == $new_label, 'Shortcut set has been successfully renamed.'); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php index e61b8b6e5bc..11ed4a13ffa 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php @@ -31,6 +31,8 @@ class VocabularyListController extends ConfigEntityListController implements For $uri = $entity->uri(); $operations['edit']['title'] = t('edit vocabulary'); + $operations['edit']['href'] = $uri['path'] . '/edit'; + $operations['list'] = array( 'title' => t('list terms'), 'href' => $uri['path'], diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php index db85bb6624d..b663298de56 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php @@ -39,10 +39,9 @@ class BasicTest extends WizardTestBase { $this->drupalGet('admin/structure/views'); $this->assertText($view1['label']); $this->assertText($view1['description']); - // @todo For now, clone is being left to config.module to solve. - foreach (array('delete', 'edit') as $operation) { - $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/' . $operation)); - } + $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'])); + $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/delete')); + $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['id'] . '/clone')); // This view should not have a block. $this->drupalGet('admin/structure/block'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DefaultViewsTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DefaultViewsTest.php index 0e2ec93d5f3..f2d255792c8 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DefaultViewsTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DefaultViewsTest.php @@ -33,7 +33,7 @@ class DefaultViewsTest extends UITestBase { function testDefaultViews() { // Make sure the view starts off as disabled (does not appear on the listing // page). - $edit_href = 'admin/structure/views/view/glossary/edit'; + $edit_href = 'admin/structure/views/view/glossary'; $this->drupalGet('admin/structure/views'); // @todo Disabled default views do now appear on the front page. Test this // behavior with templates instead. @@ -88,14 +88,14 @@ class DefaultViewsTest extends UITestBase { ); $this->assertTitle(t('Clone of @label | @site-name', array('@label' => 'Glossary', '@site-name' => config('system.site')->get('name')))); $this->drupalPost(NULL, $edit, t('Clone')); - $this->assertUrl('admin/structure/views/view/clone_of_glossary/edit', array(), 'The normal cloning name schema is applied.'); + $this->assertUrl('admin/structure/views/view/clone_of_glossary', array(), 'The normal cloning name schema is applied.'); // Clone a view and set a custom name. $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink(t('Clone'), '/glossary'); $random_name = strtolower($this->randomName()); $this->drupalPost(NULL, array('id' => $random_name), t('Clone')); - $this->assertUrl("admin/structure/views/view/$random_name/edit", array(), 'The custom view name got saved.'); + $this->assertUrl("admin/structure/views/view/$random_name", array(), 'The custom view name got saved.'); // Now disable the view, and make sure it stops appearing on the main view // listing page but instead goes back to displaying on the disabled views diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php index 5e7666c0914..32ef5338cbb 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php @@ -80,7 +80,7 @@ class ViewCloneFormController extends ViewFormControllerBase { // Redirect the user to the view admin form. $uri = $this->entity->uri(); - $form_state['redirect'] = $uri['path'] . '/edit'; + $form_state['redirect'] = $uri['path']; return $this->entity; }