When constructing a forum node object and saving it with node_save(), one sees the following notice:

Undefined property: stdClass::$nid File /var/www/modules/forum/forum.module, line 332(file: /var/www/modules/forum/forum.module, line 332)

See #1590008: Notice when saving forum entry - there are other instances scattered around d.o. The problem is forum_node_presave() assumes $node->nid is set.

I could not reproduce this on D8 (adding the equivalent test code there).

forum_notice.patch2.03 KBmikeryan
PASSED: [[SimpleTest]]: [MySQL] 39,096 pass(es).
[ View ]


larowlan’s picture

forum_notice.patch queued for re-testing.

JeremyFrench’s picture

Status:Needs review» Reviewed & tested by the community

This looks good to me and removes the notice that I was getting.

mahfiaz’s picture

This patch worked good. No notice, everything works fine.

webchick’s picture

Version:7.x-dev» 8.x-dev
Status:Reviewed & tested by the community» Patch (to be ported)

Looks good! Let's get it in 8.x first.

mikeryan’s picture

Version:8.x-dev» 7.x-dev
Status:Patch (to be ported)» Reviewed & tested by the community

I've dug in a little deeper, and confirmed this is not a problem in 8.x. Because nid is now a defined property of the Node object, there is no notice when referencing the unset nid, and the test from 7.x demonstrates nothing. The query where the empty nid is referenced will return no $old_tid, which is correct when there isn't even an old nid. The actual behavior is correct on 7.x as well, it's just that the notice is annoying (filling up migration message tables).

Moving back to 7.x-dev.

webchick’s picture

Status:Reviewed & tested by the community» Fixed

Ah, that makes sense.

Committed and pushed to 7.x. Thanks!

Status:Fixed» Closed (fixed)

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

David_Rothstein’s picture

Title:Notice generated when programmatically creating a forum node» (tests followup) Notice generated when programmatically creating a forum node
Version:7.x-dev» 8.x-dev
Category:bug» task
Status:Closed (fixed)» Patch (to be ported)

Those tests are worth forward-porting to Drupal 8, though, aren't they?