Editing node content in Bartik theme throws:
Notice: Undefined property: stdClass::$nid in linkchecker_node_prepare() (line 514 of /[server-user-path]/www/sites/all/modules/linkchecker/linkchecker.module).
At the same time the node title, in the edit form, display 'em' tags (as in http://drupal.org/node/1188012):
<em>Edit Basic page</em> [my title]
Disabling linkchecker the title issue still remain, but perhaps it is a theme related issue, as using rubik admin theme the title display correctly. Using bartik theme (or acquia marina theme) and disabling "page title" module and "meta tags" module, the title issue remain when editing the node.
Letting apart the title issue, if I use the administration theme for editing, the linkchecker notice does not show.
I'm not a programmer but I checked the linkchecker_node_prepare() function in both the stable version and the -dev version: they are the same. So I did not install the -dev to verify the bug.
Edited content can be saved, can I ignore the notice?
Shared host configuration:
Host: ovh
Drupal: 7.15
MySQL: 5.1.63-0+squeeze1-log
PHP: 5.3.14
Admin theme: rubik 7.x-4.0-beta8
Default theme: bartik 7.15
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | 1719174+Editing+node+throws+Undefined+property+stdClass+nid-D7.patch | 1.71 KB | hass |
| #22 | Editing_node_throws_Undefined_property-1719174-22.patch | 988 bytes | stenjo |
Comments
Comment #1
hass commentedThese notice is harmless. The title or theme cannot be the reason. The node object need to have a nid property.
This is very strange and needs more info. The $node object need to be dumped for a review.
Comment #2
hass commentedThis happens only on new nodes, isn't it? Not with nodes that have been saved and are edited again.
Comment #3
hass commentedI cannot repro this issue.
Please add a line in the function in "linkchecker.module" file, repro the issue step by step (including all URLs), until you see the notice and let me know if there is a NID. Ist must be there... please attach the array.
Comment #4
andrebonfanti commentedI've been away some days. I'm back.
The notice appear also on edited nodes.
I expanded
linkchecker_node_prepare()function in Krumo output in the message area:thanks for the debugging hints.
Comment #5
hass commentedCan you confirm the issue happens only with faq pages? I have never seen this with basic page and articles... Is this a book type or something from the faq module? This could be a major bug in the faq module.
Comment #6
andrebonfanti commentedI think you are right.
I used to have the notice on Basic Pages and Book Pages content types. I tested only with these.
The array I posted was from a Basic Page: a "lorem ipsum" test page (not part of a book).
However, I decided to uninstall FAQ module as I decided to manage this with a new content type of my own + views + rules. Now editing the node does not give me errors. Even the HTML entities in the title are gone.
It should be a FAQ module or a FAQ_Ask module issue. I had the FAQ_Ask block enabled on pages, too.
I'll check FAQ issue queue.
tk
Comment #7
hass commentedLet's move to FAQ module queue, so we can find out the source of this bug and why this modules clutter the node object API structure many module rely on. The maintainers need to fix these bug. If it's FAQ_Ask module, feel free to move again and set the correct version you are using.
Comment #8
andrebonfanti commentedChanged to rc2 because I had the issue with this release, not the dev.
Comment #9
stenjo commentedSilly question: Is this problem still there also in the 7.x-1.x-dev version?
Could you try and uninstall FAQ-Ask (or at least disable it) and see if that has any effect?
Comment #10
andrebonfanti commentedYes.
I tested installing first FAQ 7.x-1.x-dev and the error did not appear during node editing.
After I installed FAQ-asq 7.x-1.x-dev, the error shows only when I enable the "ask a question" block in pages. Without the block, the error disappear.
Comment #11
hass commentedHow does the #4 array look like with the one or the other module disabled?
Comment #12
andrebonfanti commentedArray in #4 shows the
linkchecker_node_prepare()function only when I activate faq-ask block "Ask a Question".Enabling first the FAQ module and after the FAQ-ask module (without activating the "Ask a Question" block), there is no error: krumo does not expose me the linkchecker function in the message area. krumo exposes only the whole
$pagearray, but it does not contain the linkchecker function (I am not a programmer, so silly question: should this function appear in the whole$pagearray?).When I activate the "Ask a Question" block, editing the node throws me the linkchecker error.
Sorry if I cannot be more precise in debugging.
Comment #13
stenjo commentedI bet this is something in the cross-section between FAQ Ask module and the Link Checker module. I'll have a look at this issue and see if I'm able to recreate.
Comment #14
stenjo commentedI have made several attempts to recreate this problem without luck. Could you please provide a step-by-step instruction to this issue from a clean drupal-install?
Comment #15
hass commented@Stenjo: are you changing the node object structure? If you do, this is the bug.
Comment #16
andrebonfanti commentedSorry, job and family are taking all my time in these weeks, so I do not have much time to test with a clean install.
I will try soon or later.
Comment #17
Luen Warneke commentedsame issue here.
Comment #18
stenjo commentedWith reference to #1, aparently the node need not have a nid property when the node is not created yet - wich is the case for the question form.
From the API reference on
hook_node_preparewe can read:The Ask a question form is a modified node add form and hook_node_prepare() is called when the line
is run in the
faq_ask_a_question_blockform()I'd say the Link Checker code should not rely entirely on the presence of nid in the node object.
Comment #19
hass commentedYou may misunderstood something. Below code makes sure that this code (SQL request) runs only on node Edit forms and never on Add node forms where an NID does not exists.
The problem is in the faq node object that is missing
$node->nid. Every node module rely on this object structure. You cannot move the NID property anywhere else just for the reason that you like it. If you change the structure, the faq ask module becomes incompatible with every node module.See #4 for the dumped object of the broken structure, please. It looks like you moved the
$node->nidproperty to$node->book['nid'].$node->niddoes not exist. This is the bug.nidis a well known reference in the node table for all node objects. Without such a reference we cannot save data in a relational database.Comment #20
hass commentedhttp://api.drupal.org/api/drupal/modules%21node%21node.module/function/n... is calling the
module_invoke_all('node_prepare', $node);and also requires an$node->nidto be set or the conditions inside these core function will fail.Comment #21
hass commentedI'm personally not able to repro the issue with FAQ and Ask FAQ module and the Ask FAQ block. I'm using Seven theme.
The reporters should provide a step by step instruction how we are able to repro the issue.
Comment #22
stenjo commentedIn #19 the code you are referring to assumes we are dealing with only one form - but in fact we are dealing with two of them: One that is being displayed and retrieved based on the node in the database. This is also the one you get when parsing the path the way the code you refer to is written now. The faq_ask form is located in a block and also loads a node edit form, but this node is not created yet, therefore it is a node add form - without the nid property in the node object. Nor should it be. The nid property is added to the node object upon creation in the database.
The faq_ask code does not at any point remove or move the nid property. Nether does it call the node_object_prepare();
The Link Checker hook_node_prepare() implementation should not be dependant on the presence of a nid property and should neither assume only one form is being loaded. In this case hook is called twice when browsing to a node/$nid/edit page when the Ask a question block is enabled:
Modifying the code to something like this:
should take care of it all.
Patch attached.
Comment #23
hass commentedOk, now I got it. With Overlay enabled you will not see the warning.
Comment #25
hass commentedComment #26
hass commentedThanks for these simple patch.
D6: http://drupalcode.org/project/linkchecker.git/commit/1866cf1
D7: http://drupalcode.org/project/linkchecker.git/commit/4a22c68