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

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

Comments

forum_notice.patch queued for re-testing.

Status:Needs review» Reviewed & tested by the community

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

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

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.

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.

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.

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?