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.
node_object_prepare() should not assume the present logged-in user.
if (!isset($node->nid) || isset($node->is_new)) {
// ...
global $user;
$node->uid = $user->uid;
}
Looking more into this, it assumes a lot. The function says it is for edit forms but it still seems very useful for programmatic node creation- should it be refactored?
Comments
Comment #1
pillarsdotnet CreditAttribution: pillarsdotnet commentedIf you are creating a node on behalf of another user, why not just change the
$node->uid
property after creation?