Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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).
Comment | File | Size | Author |
---|---|---|---|
forum_notice.patch | 2.03 KB | mikeryan | |
Comments
Comment #1
larowlanforum_notice.patch queued for re-testing.
Comment #2
JeremyFrench CreditAttribution: JeremyFrench commentedThis looks good to me and removes the notice that I was getting.
Comment #3
mahfiaz CreditAttribution: mahfiaz commentedThis patch worked good. No notice, everything works fine.
Comment #4
webchickLooks good! Let's get it in 8.x first.
Comment #5
mikeryanI'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.
Comment #6
webchickAh, that makes sense.
Committed and pushed to 7.x. Thanks!
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedThose tests are worth forward-porting to Drupal 8, though, aren't they?
Comment #11
catchComment #22
quietone CreditAttribution: quietone at PreviousNext commentedForum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.