From Drupal 4.6 onward node_submit() imports the current $user in its first line, but never makes use of it. I'm new to Drupal, but this doesn't make any sense to me. Furthermore the function (at least in D6>=) fails to use the user variable, when it actually would be feasible. Eg. in this line "$node->uid = 0;" instead of "$node->uid = $user->uid". If no $node->name is supplied, it would be perfectly fine to just rely on the fact that the current user submitted the form/node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

oddbit’s picture

Status: Active » Needs review
FileSize
548 bytes

This one has a number of related issues on this topic already. For example:
#659962: Nodes with a $node->uid assigned can not have author changed
#398110: node_submit resets $node->uid

The issue is also present in 7.x so I have added an issue for that (with a suggested patch): #1028000: Clarify the behavior of node_submit()

Status: Needs review » Needs work

The last submitted patch, 813146.oddbit.patch, failed testing.

oddbit’s picture

FileSize
475 bytes

New try with v6.20

oddbit’s picture

Status: Needs work » Needs review
FileSize
475 bytes

Status: Needs review » Needs work

The last submitted patch, node-submit-813146-4.patch, failed testing.

oddbit’s picture

Status: Needs work » Needs review
FileSize
501 bytes
pfrenssen’s picture

Version: 6.x-dev » 8.x-dev
Status: Needs review » Reviewed & tested by the community
FileSize
547 bytes

Patch looks good, but the problem still exists in 8.x and should be fixed there first. This is the same patch rerolled against 8.x-dev.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 813146-7-node-node_submit.patch, failed testing.

marcingy’s picture

Version: 8.x-dev » 7.x-dev

$user is used in d8 so it needs to move back to d7.

bleen’s picture

Status: Needs work » Needs review
FileSize
520 bytes

this is a patch against D7

bleen’s picture

Issue tags: +Novice

now that I think of it ... tagging

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

As the summary says: Not even f8526cb5 that added node_submit() initially used $user. It's not used, so whatever happens - it's safe to remove it.
I also re-verified that D8 doesn't have the same issue.

Niklas Fiekas’s picture

Issue tags: +Coding standards

Adding coding standards tag.

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Ignoring patches in comments #1-8 above, because they seem to be doing something other than the simple patch in #10 (which matches the issue that was actually submitted) and they also seem to be taken care of on other issues... the patch in #10 is a no-brainer cruft removal, and I committed it to Drupal 7.

It appears that $user is not used in 6.x either, so moving to their for backport consideration.

pfrenssen’s picture

Status: Patch (to be ported) » Needs review
FileSize
442 bytes

Rolled patch for D6.

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, pfrenssen.

(Obviously http://api.drupal.org/api/drupal/modules%21node%21node.module/function/n... indeed doesn't use that variable.)

star-szr’s picture

Issue tags: -Novice

Nothing more for a novice to do here…

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: 813146-15-node_submit_cruft_d6.patch, failed testing.

star-szr’s picture

Component: node.module » ajax system
Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
star-szr’s picture

Component: ajax system » node system

node.module component went away.

Status: Reviewed & tested by the community » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.