Problem/Motivation

Follow-up for #2631802: Allow explicitly configuring the type of context from parameters.

Proposed resolution

* Remove support for % placeholders
* Add validation for the path, so that you can't use them (or convert them automatically). Probably also require a leading / and validate that too?
* Provide a description for how a path should be structured and example allowed values.

Remaining tasks

User interface changes

Better help text/description

API changes

No longer supporting % and converting it to {} style.

Data model changes

N/A

Comments

Berdir created an issue. See original summary.

berdir’s picture

Title: Remove support for paths with %, provide validation and description for page_manager path » Remove support for paths with %, provide validation and description for path
tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new3.87 KB

The way forward for the UI is pretty clear. But what should we do for pages that are programmatically defined? Or if we don't write an upgrade path? (Though we probably should!)

Do we throw an exception, trigger an error, skip it and use an assert()?

Here's a patch for the exception.

Status: Needs review » Needs work

The last submitted patch, 3: 2659948-disallow_percent-3.patch, failed testing.

tim.plunkett’s picture

StatusFileSize
new3.87 KB
new470 bytes
tim.plunkett’s picture

Status: Needs work » Needs review
berdir’s picture

I posted the content of my upgrade path function in #2352959: Arguments step -1: Make it possible to generate paths with it..

The exceptions seems a bit tricky. Something might case a route rebuild during update.php, e.g. entity updates that trigger views re-save that in turn trigger a route rebuild...

berdir’s picture

Status: Needs review » Needs work

Two more things:

* Apparently people are trying to create a patch with just "/" as the path. We need to validate and prevent that. See #2623592: Error with page manager.
* Second, the show-link-or-not detection on the overview page doesn't work with {slug}'s. It displays those as a link and they will obviously not work then.

tim.plunkett’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new8.19 KB
new5.29 KB

Fixed #8. Didn't include an upgrade path. Still not sure about the exceptions.

Status: Needs review » Needs work

The last submitted patch, 9: 2659948-pm-9.patch, failed testing.

tim.plunkett’s picture

Uhhh, okay?

diff --git a/page_manager_ui/src/Form/PageFormBase.php b/page_manager_ui/src/Form/PageFormBase.php
index d089b5e..78c3793 100644
--- a/page_manager_ui/src/Form/PageFormBase.php
+++ b/page_manager_ui/src/Form/PageFormBase.php
@@ -108,10 +108,10 @@ public function validatePath(&$element, FormStateInterface $form_state) {
     $form_state->setValueForElement($element, $value);
 
     if (strpos($value, '%')) {
-      $form_state->setErrorByName('path', 'The entity path may not contain "%".');
+      $form_state->setErrorByName('path', 'The entity path may not contain %.');
     }
     if ($value === '/') {
-      $form_state->setErrorByName('path', 'The entity path may not be "/".');
+      $form_state->setErrorByName('path', 'The entity path may not be /.');
     }
 
     // Ensure each path is unique.
diff --git a/page_manager_ui/src/Tests/PageManagerAdminTest.php b/page_manager_ui/src/Tests/PageManagerAdminTest.php
index 6fa0159..a1ec058 100644
--- a/page_manager_ui/src/Tests/PageManagerAdminTest.php
+++ b/page_manager_ui/src/Tests/PageManagerAdminTest.php
@@ -367,7 +367,7 @@ protected function doTestAddPageWithSlashOnlyPath() {
       'path' => '/',
     ];
     $this->drupalPostForm('admin/structure/page_manager/add', $edit, 'Save');
-    $this->assertText('The entity path may not be "/".');
+    $this->assertText('The entity path may not be /.');
     $this->drupalGet('admin/structure/page_manager');
     $this->assertNoText('Bar');
   }
@@ -383,7 +383,7 @@ protected function doTestAddPageWithPercentInPath() {
       'path' => 'admin/%',
     ];
     $this->drupalPostForm('admin/structure/page_manager/add', $edit, 'Save');
-    $this->assertText('The entity path may not contain "%".');
+    $this->assertText('The entity path may not contain %.');
     $this->drupalGet('admin/structure/page_manager');
     $this->assertNoText('Bar');
   }

That would pass tests. What's so special about "?

tim.plunkett’s picture

Issue tags: +beta blocker
dobrzyns’s picture

Status: Needs work » Needs review
StatusFileSize
new8.12 KB

Re-rolling patch.

Status: Needs review » Needs work
blackiceua’s picture

blackiceua’s picture

blackiceua’s picture

blackiceua’s picture

japerry’s picture

Status: Needs work » Closed (outdated)

Page Manager 8.x-1.x is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.