When I go to a prospective parent node and click "Attach existing [content type]", I get a "page not found" error when trying to access [mysite]/relativity/listnodes/[contenttype]/parent/[nid]. I can create new child nodes and remove existing child nodes from the hierarchy with no problem, but I am utterly unable to add existing nodes to the hierarchy. Furthermore, in an old version of my site running Relativity 6.x-1.3, I can add existing nodes without any problem. I have all the Node Relativity permissions enabled (and am logged in as user 1 besides), and I tried disabling Pathauto after read about a similar issue, but the problem persists.

CommentFileSizeAuthor
#4 990642_relativity_page_not_found.patch982 bytesblackdog
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

walktalker’s picture

facing the same problem, even cleared cache, run cron, rebuild permission...

lucas.matias’s picture

Facing the same problem too.
any solution?

blackdog’s picture

Title: Cannot attach existing nodes to parents » Trying to attach existing nodes returns Page not found
Component: Miscellaneous » Code
Category: support » bug

Something is indeed wrong.

blackdog’s picture

Status: Active » Needs review
FileSize
982 bytes

Here's a quick fix to the issue, that at least gets the page loaded. Not really sure what that load function actually do, so if someone can shed some light here that would be nice.

toddchris’s picture

I'm having the same problem, and it would really be a nice feature. Has anyone tried the patch above?

TC

blackdog’s picture

I have the patch running without issues, but we need a maintainer or someone with better knowledge of the module to review the changes.

draxiom’s picture

The patch did not work for me. I was able to workaround this problem by just adding new relationships directly into the relativity mysql table. It is fairly straight forward... nid and parent_nid. I inserted the appropriate nids and the relationship showed up on the site. The "Attach existing Page" link is still dead, but at least the page hierarchy is in there.

dineshcooper’s picture

Same problem here - patch did not work for me.

jonhattan’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Status: Needs review » Postponed (maintainer needs more info)

Sorry I'm unable to reproduce this bug report. The diff between 1.3 and 1.4 in this area is:

     $items['relativity/listnodes/%relativity_node_list/parent/%node'] = array(
       'title' => 'list of !type nodes to attach',
-      'title arguments' => array('!type' => node_get_types('name', arg(2))),
+      'title arguments' => array('!type' => node_get_types('name', 2)),
       'load arguments' => array(4),
       'page callback' => 'relativity_list_possible_children',
       'page arguments' => array(2, 4),
-      'access callback' => 'relativity_access_listnodes',
-      'access arguments' => array('update', 4, 'add child relations'),
+      'access arguments' => array('add child relations'),
       'type' => MENU_CALLBACK,
     );
 

Drupal should catch this change upon a menu rebuild. You can trigger a menu rebuild by submitting the admin/build/modules form.

Can anyone reproduce this bug with a fresh install of drupal+relativity?

yosepkur’s picture

I tried changing the following lines and it loads the page successfully.

<?php
-    $items['relativity/listnodes/%relativity_node_list/parent/%node'] = array(
+    $items['relativity/listnodes/%relativity_node_list/parent/%'] = array(

...

-    $items['relativity/addparent/%node/parent/%node'] = array(
+    $items['relativity/addparent/%/parent/%'] = array(

...
?>

I've also updated the following function:

<?php
function relativity_list_possible_children($type, $parent) {
  $links = array();
+   $parent = node_load($parent);
  $relativity_query = variable_get('relativity_child_query_'. $parent->type .'_'. $type, NULL);
  $common_children_reqd = variable_get('relativity_common_child_'. $parent->type .'_'. $type, array());

...
}
?>

Hope it helps.

jennifer.chang’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs work

yosepkur , comment #10 is right.

Keep %node in 'relativity/addparent/%node/parent/%node'
but rework function relativity_addparent($child_nid = "", $parent_nid = "") {...} to accept two nodes instead:
relativity_addparent($child_node, $parent_node) {...}
No need to rely on arg().

jennifer.chang’s picture

yosepkur is right for 'relativity/listnodes/%relativity_node_list/parent/%node'.
There is a conflict with the node loader called with %node and the 'load arguments' => array(4).
The relativity_node_list_load() already checks that the nid is valid.

The code is a bit ugly though. It is trying to be too clever with the menu API but it's not using the wildcards exactly the way it was intended.
The badly named relativity_node_list_load() should not check whether the node->nid exist. It's done for us by node_load() thanks to the wildcard %node.
Instead relativity_node_list_load() should simply check that the node type is within relativity_node_list() and return either FALSE if not, or the machine node type.
Then both the node type and the fully loaded node can be passed to relativity_list_possible_children().

jennifer.chang’s picture

passing '2' to node_get_types within hook_menu does not work either:
'title arguments' => array('!type' => node_get_types('name', 2))
The patch in #4 is pointing at this problem but it's merely offering a hack, breaking the original intend.

I don't think that we can use 'title arguments' the way it's used here. Remove it completly and use drupal_set_title() manually in the callback function.