when i create a hierarchy in combination w module block I'll get this error message:

Undefined index: nid in nodehierarchy_parent_selector_validate() (line 1559 of C:\xampp\htdocs\drupal-dev\sites\all\modules\nodehierarchy\nodehierarchy.module).

Though it seems to work, the breadcrumb then is displayed corretly.

Comments

alexbern’s picture

and 2nd:

Notice: Undefined property: stdClass::$nid in nodehierarchy_nodehierarchy_node_form() (line 543 of C:\xampp\htdocs\drupal-dev\sites\all\modules\nodehierarchy\nodehierarchy.module).

when trying to create a new node.

xcono’s picture

subcribe

keithm’s picture

Title: undefined index » Warnings produced when creating nodes
Status: Active » Needs review
StatusFileSize
new862 bytes

Patch attached for the first issue. I can't reproduce the problem in #1. Could you please provide steps to reproduce it?

keithm’s picture

Found the second one. This patch fixes both warnings.

alexbern’s picture

Thanks a lot. will give it a try in combination with mulitple parents patch.

jvandooren’s picture

Status: Needs review » Reviewed & tested by the community

This patch did the trick for me. It also fixed this issue: #1137766: Error on saving new content

ecksley’s picture

I get the following error when creating nodes as a user who does not have any permissions pertaining to Node Hierarchy.

Notice: Undefined property: stdClass::$nid in nodehierarchy_nodehierarchy_node_form() (line 521 of /path/to/drupal/sites/all/modules/nodehierarchy/nodehierarchy.module).

However when working as a the superuser I have no such issue.

I tried the patch from #4 and it made no difference.

Thanks for you help and the cool module.

modoq’s picture

When creating a new child node I get the 2nd error, but on line 521! So the patch #4 won't work.

Notice: Undefined property: stdClass::$nid in nodehierarchy_nodehierarchy_node_form() (line 521 of /var/www/sites/all/modules/nodehierarchy/nodehierarchy.module).

BenPoole’s picture

I can not get either patch to run correctly. I get the following errors when running either patch:

bash: warnings-produced-when-creating-nodes-1168348-4.patch: line 5: syntax error near unexpected token `('
bash: warnings-produced-when-creating-nodes-1168348-4.patch: line 5: `@@ -540,7 +540,7 @@ function nodehierarchy_nodehierarchy_node_form($node) {'

doom_fist’s picture

I've applied the patch in #4, but I continue to see the error upon creation of a new node.

Error message
Notice: Undefined property: stdClass::$nodehierarchy_menu_links in _nodehierarchy_save_node() (line 714.../sites/all/modules/nodehierarchy/nodehierarchy.module).

jnettik’s picture

I was getting the error in #1 and used patch in #4. Seems to work so far.

Edit: After some more testing I'm getting the same error in #10.

tevans’s picture

subscribing

taecelle’s picture

I deleted in line 521:
$node->nid == NULL && user_access('create child nodes') etc.
following part:
->nid
And this worked!!!

bigpapa’s picture

I get this error when creating new content:

PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'IF'.: SELECT n.nid, n.type as type, n.title as title, n.uid as uid, ml.*, IF(depth IS NULL, 1, depth) as depth, IF(ml.mlid IS NULL, CONCAT('nid:', n.nid), ml.mlid) as mlid, ml.mlid as linkid FROM {node} n LEFT JOIN {nodehierarchy_menu_links} nh_parent ON nh_parent.nid = n.nid LEFT JOIN {menu_links} ml ON ml.mlid = nh_parent.mlid WHERE (ml.module = 'nodehierarchy' OR ml.module IS NULL) AND n.type IN ('department', 'page') ORDER BY IF(p1 IS NULL, n.created, 0) ASC, p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC; Array ( ) in _nodehierarchy_parent_options() (line 1607 of \Drupal\sites\all\modules\nodehierarchy\nodehierarchy.module).

luco’s picture

uhm. just so I'm clear, do these error messages imply any actual error that might cause data loss?

liam morland’s picture

@#15 The error in #14 looks like one that would just cause the SELECT to fail and would not cause data loss. It looks like the query needs to be rewritten to replace the IF with COALESCE to give it wider database compatibility.

Courtney.B’s picture

Ran patch #4, error's gone now.

luco’s picture

same here. ran the patch and now it works. :] thanks!

Bartox’s picture

Patch applied, the warnings are gone now.

ronan’s picture

Status: Reviewed & tested by the community » Fixed

Not really sure how to produce these warnings but the patch doesn't seem to cause any issues so I've committed it. Thanks all.

Status: Fixed » Closed (fixed)

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

luco’s picture

@doom_fist make sure the permissions create child nodes, edit all node parents and edit own node parents are on. that worked for me.

cheers

ryanrain’s picture

Status: Closed (fixed) » Active

hi all,

i'm not sure if this is the same issue, or separate, so i apologize if i've made a mistake in reopening it. the module works great for the super admin user, problems appear for anonymous:

I'm still getting the error Undefined property: stdClass::$nid in nodehierarchy_nodehierarchy_node_form() (line 533 on the top of a child node add form, and then the relationship is not saved, and the token [node:nodehierarchy:parent:title] is not generated.

steps to reproduce:
1. give permissions to anonymous users: Node: Create new child_node_type; Node Hierarchy: create child nodes, and, for good measure as @luco says above, edit all node parents and edit own node parents. as a side note from a site builder ui perspective, i don't think these should be necessary.
2. as an anonymous user, go to the parent page. although permissions are given, the default Create new child child_node_type does not appear. i have a view with a hardcoded link that passes the parent node id argument, i click that. to save time you could probably just type in the ?destination=node/27&parent=27 url.
3. error appears. node is saved normally, but without node hierarchy relationship data.

sorry to post this without trying to troubleshoot the php. one day i'll get time to dive in and learn it.

thanks in advance,
-ryan

ishiomin’s picture

StatusFileSize
new565 bytes

I had the same error but with an authenticated user.
This correction solve the problem :

- ($node->nid == NULL && user_access('create child nodes')) ||
+ (!isset($node->nid) && user_access('create child nodes')) ||

I attach the patch.

May be you already do the correction, it's a very useful module.

Guy