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.
I was trying to create a parent node programatically in our tests:
$node-> // various properties here
$node->simplenews_scheduler = array( ... );
node_save($node);
... and it doesn't work at all, because this module is completely ignorant of node API: our records are saved in simplenews_scheduler_submit() only.
The fix would be to have a hook_node_update/insert and then have simplenews_scheduler_submit() dose up the node object then save it. Which also simplifies our code with the merge query too.
Comments
Comment #1
BerdirI'm not very convinced of doing this anymore. My suggestion instead would be a separate API function to store this information.
Simplenews is doing it too but I have plans to remove that in the next major version.
Similar thing for hook_node_load(), we're currently checking every single node if it's maybe a scheduler node or an edition. I think it would save us quite a bit in the end if that is moved to separate load/check functions.
Comment #2
nevets CreditAttribution: nevets commentedIt really is best to use the existing api's and not go off on your own track.
Comment #3
BerdirThere is no existing API.
There is no need to go through node_save(), that's just an indirection, we'd still have our own query, just inside a hook rather than a submit callback. Not really a great example but comment.module uses comment_save() and not $node->new_comment + node_save() ;)
Comment #4
joachim CreditAttribution: joachim commentedcomment_save() isn't a good example, as it's saving a comment entity... comment module implements some node API hooks too.
A better example is maybe http://api.drupal.org/api/drupal/modules!forum!forum.module/function/for...
Comment #5
dgtlmoon CreditAttribution: dgtlmoon commented