Keep seeing this message after I turn on the module on one site, but no message appears on another testing site:

Notice: Undefined property: stdClass::$body in content_lock_content_lock_node_lockable() (line 697 of /var/www/html/sites/all/modules/content_lock/content_lock.module).

However, it is still functional on both sites. I have checked and compared the files in two sites. It seems not a database issue. I have looked at the code and cannot make it disappear. Any suggestions?

Comments

ohnobinki’s picture

May you more clearly describe which particular pages that PHP warning shows up on? Are these only on node-editing pages, the node-viewing pages, for nodes of a specific type or with an unusual content type/input format?

I can make some code conditional whether or not ::$body is present or not, but I'd like to know more about the situation and understand the source of the error. At the line referenced in your warning message, $node is supposedly guaranteed to be a node object (which I assume means it's supposed to have a ::body member). I don't have a good enough understanding of the node module yet to understand why a node might not have a ::body ;-).

Eric Yang’s picture

Thanks for pointing out the 'node without body'.

Now I know the source of error.
It is because on my website with that error, I used a node block as a footer.
And that node type does not have a 'body' field!
In another word, a 'node without body' appear at the bottom of every page.
That's why I get error messages everywhere on my website.

Then I turned off footer, There is no more error message except on the page of that footer node.

In Drupal 7, Every content type has a default body field, but you can delete it.
I think this message should be fixed, because people are creating content types without body field.
e.g. A content type of image which only contains a title, an image and a text field of description used for banners.

It is a wonderful module, and on my website, users usually spend hours editing one node. It's good to have a module to lock the content.

Eric Yang’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Eric Yang’s picture

I reintalled the dev release (2011-06-09) yesterday.

I also found another issue.

If a node with a undefined body (empty body), this message will appear on the node page:

Notice: Undefined index: und in content_lock_content_lock_node_lockable() (line 697 of /var/www/sites/all/modules/content_lock/content_lock.module).

ohnobinki’s picture

Status: Active » Fixed

Thanks for the explanations and additional note. For now I think I'll just disabled the "input format type" checks when the node doesn't have ::body set. The dev release doesn't yet have that fix, but I just committed what I hope is a quick fix for this at 15a2111.

Eric Yang’s picture

Thank you. It works perfectly now.

Status: Fixed » Closed (fixed)

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