In the View for the My Edits tab, the title link is set to " Link this field to its content revision." This setting turns the link into the format:

node/NID/revision/VID

But if there is only one revision on the node, this page returns Access Denied due to the logic in _node_revision_access():

    if ($is_current_revision && (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete')) {

IMO, this is a Views bug, but we should simply work around it and link to the proper Node view page, as expected.

Why don't we just use the non-revisioned titles here?

Comments

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new34.15 KB

And a patch.

Status: Needs review » Needs work

The last submitted patch, 1862014-my-edits.patch, failed testing.

bbinkovitz’s picture

Ken, can you reroll this patch to not change the name of the view, as that may break other things? Or would you like me to try doing this?

agentrickard’s picture

Hm. I thought it was safer to change the view to a new file. If you can re-roll that way, please do.

I'd also like to get @stevector's thoughts about why this View uses the node_revision base table.

tim.plunkett’s picture

This looks like it might be a bug in Views in D7 and D8?

Compare http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/modules... and http://drupalcode.org/project/views.git/blob/refs/heads/7.x-3.x:/modules...

Not sure why the first handler even exists? I must be missing something.

tim.plunkett’s picture

Title: My eidts links go to revisions but links may fail » My edits links go to revisions but links may fail

Also, rerolling the patch so the diff means something would be great.

tim.plunkett’s picture

Title: My edits links go to revisions but links may fail » Revision handler makes assumptions about path
Project: Workbench » Views (for Drupal 7)
Version: 7.x-1.x-dev » 7.x-3.x-dev
Assigned: Unassigned » dawehner

I think http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/node/li... might have the same problem, checking with the master :)

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new866 bytes

Well, let's try this.

tim.plunkett’s picture

StatusFileSize
new860 bytes

Whoops, I meant this

agentrickard’s picture

That seems to fix the issue.

Status: Needs review » Needs work

The last submitted patch, views-1862014-9.patch, failed testing.

agentrickard’s picture

Status: Needs work » Reviewed & tested by the community
dawehner’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.x-dev
Component: Code » node system
Issue tags: +Needs tests

Awesome, let's port that to d8.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +VDC
StatusFileSize
new917 bytes

Still needs tests.

agentrickard’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Needs work

Sorry. This doesn't actually work. The logic is too simple:

if ($nid != $vid)

This is an insufficient check, because if you create node 1, it works. Then revision node 1 to have vid 2.

Then create node 2, it gets vid 3 and the link breaks again.

The way core works this in D7 is to literally check the COUNT of rows in the {node_revision} table. Without patching core, I'm not sure we have any choice but to do that.

stevector’s picture

Assigned: dawehner » Unassigned

Yeah, this logic is not sufficient. The real question is "is this vid which is coming from {node_revision} also in {node}"

I've got a patch in the State Machine queue that is grappling with the same issue:

#1775540: Additional fields joins break with the latest version of Views

That handler is asking "is this vid which is coming from {node_revision} also in {node} and does it have a status of 1" The patch includes a test, which is now passing thanks to ugly additional queries that directly check the node table. This is needed there because these broke with a recent Views update.

  $this->additional_fields['node_vid'] = array('table' => 'node', 'field' => 'vid');
  $this->additional_fields['node_status'] = array('table' => 'node', 'field' => 'status');

Tim or dawehner, do know what could be done in the handler or elsewhere to get this additional field piece working again? If so, that could be the fix here as well as in the State Machine patch.

agentrickard’s picture

@stevector

Even that condition can cause a break in expected functionality. The vid may be in both tables and the link would still take you to an access denied, because the access check is for COUNT of rows in {node_revision}.

stevector’s picture

agentrickard, I think I wasn't clear in my last comment. If the vid for the given result is in both tables, then the link should go to node/1. If the vid for this result is not in both tables then there must be more than one vid (or something else has gone seriously wrong) and this vid is not the one in the node table so the link should go to node/%/revision/%/view.

agentrickard’s picture

Yes.

quicksketch’s picture

StatusFileSize
new2.19 KB

Here's a D7 patch for Views. I'll work on porting to D8.

quicksketch’s picture

Title: Revision handler makes assumptions about path » Node revision Views handler links to access denied page when only one revision exists
Version: 7.x-dev » 8.x-dev
Component: node system » node.module
Status: Needs work » Needs review
StatusFileSize
new2.29 KB

D8 port. I have to say: the D8 version of Views is refreshingly similar to the D7 module.

danmuzyka’s picture

Assigned: Unassigned » danmuzyka

Assigning.

danmuzyka’s picture

Assigned: danmuzyka » Unassigned

Ran out of time during code sprint. Assigning back to anonymous.

dawehner’s picture

Status: Needs review » Needs work

I don't see how this can cover all the cases, see issue summary.

dawehner’s picture

Issue summary: View changes

Clarifies.

xjm’s picture

Component: node.module » node system
Issue summary: View changes

(Merging "node system" and "node.module" components for 8.x; disregard.)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

acbramley’s picture

Status: Needs work » Closed (cannot reproduce)

This actually didn't need the fix above anymore due to how the link is rendered

If there is only 1 revision, it will be the default revision and therefore the link will be the canonical url. Otherwise it will link to the revision page.

If we are talking about a different handler, it will be fixed by the issue above.

Please re-open if I've made a mistake :)