Problem/Motivation

Forcing the more link to always display causes an exception when there is no route, i.e. I have no page view to more link to..., however users can check this option in Views UI and kill their site, with no understanding of what just happened.

Proposed resolution

Don't allow users to check this option when there is no page view, OR allow users to set the path to a page/node whatever to "more link" to. Either way, this is a pretty nasty site builder wtf just happened to my site problem.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Version: 8.1.x-dev » 8.0.x-dev
Priority: Normal » Major
Issue tags: +VDC

Thank you for creating an issue.

Note: fixes should be filled against the recent version of the code.

Upchuk’s picture

Assigned: Unassigned » Upchuk
Status: Active » Needs work

Will take a stab at this.

Upchuk’s picture

Status: Needs work » Needs review
FileSize
954 bytes

How about this?

A check inside the validation of the display.

If the approach is good, will go ahead with writing a test.

dawehner’s picture

Mh, while this is certainly nice to have here, i'm a bit curios whether we really don't want to have a form level validation, which stops the user from saving the form.

Upchuk’s picture

Adding an error in the validation there prevents the form from being submitted as well. It's the same behaviour as with creating a Page display without specifying a path to it. Whenever the view executes, the validation will fail and you get the message in red. You can't save the form in that state either.

dawehner’s picture

Well, but I kinda prefer the inline validation as it has a better UX, IMHO.

Upchuk’s picture

Here we go. A fix + a test.

The last submitted patch, 7: 2428643-7-test.patch, failed testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

It looks great!

mpdonadio’s picture

Yeah, I think inline validation is better UX and DX; it will help prevent weird situations like #2446783: Views preview not working without saving new display.

Upchuk’s picture

Status: Reviewed & tested by the community » Needs work

@dawehner, I still want to add a little test to also check if the page display is removed completely. Currently it only disables it. The patch includes a check for both disabled and non-existent and the test should reflect both :)

@mpdonadio This cannot be implemented inline. I'm sorry I forgot to add a comment about this as I discussed this on IRC with dawehner a while ago. The problem with inline validation is that the form section responsible for turning on the 'more' link is different than the one responsible for selecting a custom url or a page display or whatever. So you end up in a situation that you won't be able to turn on the 'more' link because the other section (the link selection) will be by default set on 'None' (which will error out).

Upchuk’s picture

Status: Needs work » Needs review
FileSize
1.6 KB
1.74 KB
2.77 KB

Here we are, some extra checks.

The last submitted patch, 12: 2428643-12-test.patch, failed testing.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, looks great now!

dawehner’s picture

I'm sorry for my slacking +1 from me.

Upchuk’s picture

What slacking? You've been super helpful :)

catch’s picture

Status: Reviewed & tested by the community » Needs review

What happens if you configure this (when the validation would pass), but then later delete the display that can be linked to?

Upchuk’s picture

The validation gets called after many actions on the view. So just like test indicates, you can configure it properly but then when the validation gets called again, it fails if there is no valid page display with a path.

catch’s picture

Hmm I see that in the test now, it's not obvious from the comment though what's happening. Upchuck talked through in irc.

1. You have a valid View
2. You disable the page display which would make the view invalid
3. When you try to save, you get the validation error - because the path no longer has anywhere to point to.

So we don't stop you disabling the page display, but we then don't let you save the view until the master is updated.

That prevents the error I had in mind, I can see people getting confused when it happens but it's consistent with the page display never having been there at all.

Would change the comment to something like:

'Confirm that the view does not validate when the page display is disabled.'

But seems OK.

Upchuk’s picture

FileSize
1.54 KB
2.82 KB

Here we go.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2328,6 +2328,14 @@ public function validate() {
+        $errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. Please specify a custom URL.', array('@display' => $this->display['display_title']));

We don't use please in our UI text.

Upchuk’s picture

Status: Needs work » Needs review
FileSize
997 bytes
2.82 KB

Here we go.

Status: Needs review » Needs work

The last submitted patch, 23: 2428643-23.patch, failed testing.

dawehner’s picture

Please, don't use "please" in our UI.

Upchuk’s picture

Status: Needs work » Needs review
FileSize
2.84 KB

Damn it, forgot to update the test as well :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 0fd920c and pushed to 8.0.x. Thanks!

diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index b7204e9..1e5d894 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2366,7 +2366,7 @@ public function validate() {
     if ($this->isMoreEnabled() && $this->getOption('link_display') !== 'custom_url') {
       $routed_display = $this->getRoutedDisplay();
       if (!$routed_display || !$routed_display->isEnabled()) {
-        $errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. You\'ll need to specify a custom URL.', array('@display' => $this->display['display_title']));
+        $errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', array('@display' => $this->display['display_title']));
       }
     }
 
diff --git a/core/modules/views/src/Tests/Plugin/DisplayTest.php b/core/modules/views/src/Tests/Plugin/DisplayTest.php
index 68e4cbc..f0eb43f 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayTest.php
@@ -243,7 +243,7 @@ public function testReadMoreNoDisplay() {
     $view->setDisplay('default');
     $errors = $view->validate();
     $this->assertTrue(!empty($errors), 'More link validation has some errors.');
-    $this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You\'ll need to specify a custom URL.', 'More link validation has the right error.');
+    $this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', 'More link validation has the right error.');
 
     // Confirm that the view does not validate when the page display does not exist.
     $view = Views::getView('test_view');
@@ -251,7 +251,7 @@ public function testReadMoreNoDisplay() {
     $view->display_handler->setOption('use_more', 1);
     $errors = $view->validate();
     $this->assertTrue(!empty($errors), 'More link validation has some errors.');
-    $this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You\'ll need to specify a custom URL.', 'More link validation has the right error.');
+    $this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', 'More link validation has the right error.');
   }
 
   /**

This would have introduced the first use of "You'll need" into core. I changed this to "You need"

  • alexpott committed 0fd920c on 8.0.x
    Issue #2428643 by Upchuk: Always display the more link causes exception...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.