This code should save a new node. It does so but with these errors:
Notice: Undefined property: stdClass::$nid in simplenews_node_presave() (line 441 of /Users/joachim/Sites/lab-7/sites/all/modules/contrib/simplenews/simplenews.module).
Notice: Undefined property: stdClass::$nid in simplenews_newsletter_defaults() (line 474 of /Users/joachim/Sites/lab-7/sites/all/modules/contrib/simplenews/simplenews.module).
$node = (object) NULL;
$node->type = 'simplenews';
$node->title = 'New page';
$node->uid = 0;
$node->status = 1;
$node->language = 'und';
node_save($node);
The problem is that simplenews_node_presave() assumes a nid property is at least set. When a new node is saved via the UI, $node->nid is set but NULL. When using node_save(), $node->nid won't be set at all (which is the correct way to use node_save() -- see http://api.drupal.org/api/drupal/modules!node!node.module/function/node_...).
Marking as major as this is affecting unit tests in Simplenews Scheduler.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | fix_presave_notices.patch | 2.39 KB | berdir |
Comments
Comment #1
berdirPatch including a test.
Comment #2
berdirCommited.