Download & Extend

Node form has wrong UID on initial creation of profile of another uer

Project:Content Profile
Version:6.x-1.0
Component:Base module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

<?php
function content_profile_page_edit($type, $account) {
  ....
  if (!
$node) {
   
$node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
  }
?>

<?php
function node_object_prepare(&$node) {
  ...
  if (!isset(
$node->nid)) {
    ...
   
$node->uid = $user->uid; // eeeekkkkkkkk
   
$node->created = time();
?>

http://api.drupal.org/api/function/node_object_prepare/6

I have a sinking feeling this is a duplicate but couldn't find it, sorry if that's the case.

Patch resets the uid based on name in prepare.

AttachmentSize
content_profile_uid.patch697 bytes

Comments

#1

Status:needs review» needs work

Right, if statement above will sometimes invalidate if statement below.

#2

Status:needs work» needs review

Updated patch, haven't tested other than passing validation, but using similar code elsewhere.

AttachmentSize
941994_content_profile_uid.patch 858 bytes

#3

subscribing

#4

That user_load should likely be

<?php
  $uid
= db_result(db_query("SELECT uid from {users} where name = '%s'", $node->name));
?>

user_load isn't cached.

However, the patch is still valid, it could benefit more from being reviewed.

#5

The patch worked great =)
Anyone else able to review?

#6

I found that I also needed to set the form value for name and uid during form alter, depending on how you are passing the other user's uid in the URL.

I guess that also has to do with the fact that there are different URLs for the same thing in this module. I attached a patch that includes my additions as well.

AttachmentSize
content_profile-941994.patch 1.34 KB