Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When creating a Page View in the wizard and setting a path with leading slash (/) the created View display ends up with a double-slash (//)

(cherry picked from commit 6ae9811c48)
merge-requests/64/head
Alex Pott 2020-03-02 22:55:40 +00:00
parent ca93e60207
commit 8274945514
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 21 additions and 0 deletions

View File

@ -176,6 +176,20 @@ class BasicTest extends WizardTestBase {
$this->assertEqual(count($data), 1, 'Only the node of type page is exported.');
$node = reset($data);
$this->assertEqual($node['nid'][0]['value'], $node1->id(), 'The node of type page is exported.');
// Create a view with a leading slash in the path and test that is properly
// set.
$leading_slash_view = [];
$leading_slash_view['label'] = $this->randomMachineName(16);
$leading_slash_view['id'] = strtolower($this->randomMachineName(16));
$leading_slash_view['description'] = $this->randomMachineName(16);
$leading_slash_view['show[wizard_key]'] = 'node';
$leading_slash_view['show[type]'] = 'page';
$leading_slash_view['page[create]'] = 1;
$leading_slash_view['page[title]'] = $this->randomMachineName(16);
$leading_slash_view['page[path]'] = '/' . $this->randomMachineName(16);
$this->drupalPostForm('admin/structure/views/add', $leading_slash_view, t('Save and edit'));
$this->assertEquals($leading_slash_view['page[path]'], $this->cssSelect('#views-page-1-path')[0]->getText());
}
/**

View File

@ -164,6 +164,13 @@ class ViewAddForm extends ViewFormBase {
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
$form_state->set('wizard', $wizard_instance->getPluginDefinition());
$form_state->set('wizard_instance', $wizard_instance);
$path = &$form_state->getValue(['page', 'path']);
if (!empty($path)) {
// @todo https://www.drupal.org/node/2423913 Views should expect and store
// a leading /.
$path = ltrim($path, '/ ');
}
$errors = $wizard_instance->validateView($form, $form_state);
foreach ($errors as $display_errors) {