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

Comments

hass’s picture

Status: Active » Postponed (maintainer needs more info)

These 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.

hass’s picture

This happens only on new nodes, isn't it? Not with nodes that have been saved and are edited again.

hass’s picture

I 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.

function linkchecker_node_prepare($node) {
  // If you have devel installed
  krumo($node);
  // or if not.
  var_dump($node);
andrebonfanti’s picture

I'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:

22: linkchecker_node_prepare() (Array, 2 elements)

    file (String, 52 characters ) sites/all/modules/linkchecker/linkchecker.modul...
        sites/all/modules/linkchecker/linkchecker.module:514
    args (Array, 1 element)
        0 (Object) stdClass
            uid (String, 1 characters ) 1
            name (String, 5 characters ) admin
            type (String, 3 characters ) faq
            language (String, 3 characters ) und
            title (NULL)
            status (Integer) 1
            promote (Integer) 1
            sticky (Integer) 0
            created (Integer) 1345537600
            revision (Boolean) FALSE
            book (Array, 12 elements)
                original_bid (Integer) 0
                menu_name (String, 0 characters )
                nid (String, 3 characters ) new
                bid (Integer) 0
                router_path (String, 6 characters ) node/%
                plid (Integer) 0
                mlid (Integer) 0
                has_children (Integer) 0
                weight (Integer) 0
                module (String, 4 characters ) book
                options (Array, 0 elements)
                parent_depth_limit (Integer) 8
            comment (Integer) 2

thanks for the debugging hints.

hass’s picture

Can 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.

andrebonfanti’s picture

I 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

hass’s picture

Title: Editing node throws "Undefined property: stdClass::$nid in linkchecker_node_prepare()" line 514 » Editing node throws "Undefined property" stdClass::$nid in hook_node_prepare()
Project: Link checker » Frequently Asked Questions
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Category: support » bug
Priority: Minor » Normal
Status: Postponed (maintainer needs more info) » Active

Let'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.

andrebonfanti’s picture

Version: 7.x-1.x-dev » 7.x-1.0-rc2

Changed to rc2 because I had the issue with this release, not the dev.

stenjo’s picture

Silly 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?

andrebonfanti’s picture

Yes.
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.

hass’s picture

How does the #4 array look like with the one or the other module disabled?

andrebonfanti’s picture

Array 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 $page array, but it does not contain the linkchecker function (I am not a programmer, so silly question: should this function appear in the whole $page array?).

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.

stenjo’s picture

Project: Frequently Asked Questions » FAQ_Ask
Version: 7.x-1.0-rc2 » 7.x-1.x-dev
Assigned: Unassigned » stenjo

I 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.

stenjo’s picture

Status: Active » Postponed (maintainer needs more info)

I 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?

hass’s picture

@Stenjo: are you changing the node object structure? If you do, this is the bug.

andrebonfanti’s picture

Sorry, 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.

Luen Warneke’s picture

same issue here.

stenjo’s picture

Project: FAQ_Ask » Link checker
Version: 7.x-1.x-dev » 7.x-1.0-beta1
Assigned: stenjo » Unassigned
Status: Postponed (maintainer needs more info) » Active

With 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_prepare we can read:

Drupal 7 hook_node_prepare($node)
Act on a node object about to be shown on the add/edit form.

The Ask a question form is a modified node add form and hook_node_prepare() is called when the line

$form = node_add('faq');

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.

hass’s picture

Project: Link checker » FAQ_Ask
Version: 7.x-1.0-beta1 » 7.x-1.x-dev

You 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.

/**
 * Implements hook_node_prepare().
 */
function linkchecker_node_prepare($node) {
  // Node edit tab is viewed.
  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') {
...

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->nid property to $node->book['nid']. $node->nid does not exist. This is the bug.

nid is a well known reference in the node table for all node objects. Without such a reference we cannot save data in a relational database.

hass’s picture

http://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->nid to be set or the conditions inside these core function will fail.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

I'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.

stenjo’s picture

Project: FAQ_Ask » Link checker
StatusFileSize
new988 bytes

In #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:

  • once for the node being edited
  • once for the node create form in the Ask a question block

Modifying the code to something like this:

/**
* Implements hook_node_prepare().
*/
function linkchecker_node_prepare($node) {
  // Node edit tab is viewed.
  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit' && isset($node->nid)) {
...

should take care of it all.

Patch attached.

hass’s picture

Status: Postponed (maintainer needs more info) » Needs review

Ok, now I got it. With Overlay enabled you will not see the warning.

Status: Needs review » Needs work

The last submitted patch, Editing_node_throws_Undefined_property-1719174-22.patch, failed testing.

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new1.71 KB
hass’s picture

Status: Fixed » Closed (fixed)

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