Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1216
diff -u -p -r1.1216 node.module
--- modules/node/node.module	15 Jan 2010 10:59:21 -0000	1.1216
+++ modules/node/node.module	18 Jan 2010 00:31:51 -0000
@@ -920,9 +920,8 @@ function node_submit($node) {
   global $user;
 
   // A user might assign the node author by entering a user name in the node
-  // form, which we then need to translate to a user ID, unless we've already
-  // been provided a user ID by other means.
-  if (!empty($node->name) && !isset($node->uid)) {
+  // form, which we then need to translate to a user ID.
+  if (isset($node->name)) {
     if ($account = user_load_by_name($node->name)) {
       $node->uid = $account->uid;
     }
@@ -930,6 +929,7 @@ function node_submit($node) {
       $node->uid = 0;
     }
   }
+
   $node->created = !empty($node->date) ? strtotime($node->date) : REQUEST_TIME;
   $node->validated = TRUE;
 
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.111
diff -u -p -r1.111 node.pages.inc
--- modules/node/node.pages.inc	13 Jan 2010 04:35:28 -0000	1.111
+++ modules/node/node.pages.inc	18 Jan 2010 00:31:51 -0000
@@ -230,12 +230,9 @@ function node_form($form, &$form_state, 
     '#title' => t('Authored on'),
     '#maxlength' => 25,
     '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the timezone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'O'))),
+    '#default_value' => !empty($node->date) ? $node->date : '',
   );
 
-  if (isset($node->date)) {
-    $form['author']['date']['#default_value'] = $node->date;
-  }
-
   // Node options for administrators
   $form['options'] = array(
     '#type' => 'fieldset',
@@ -265,14 +262,6 @@ function node_form($form, &$form_state, 
     '#default_value' => $node->sticky,
   );
 
-  // These values are used when the user has no administrator access.
-  foreach (array('uid', 'created') as $key) {
-    $form[$key] = array(
-      '#type' => 'value',
-      '#value' => $node->$key,
-    );
-  }
-
   // Add the buttons.
   $form['actions'] = array(
     '#type' => 'container',
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.68
diff -u -p -r1.68 node.test
--- modules/node/node.test	13 Jan 2010 12:58:47 -0000	1.68
+++ modules/node/node.test	18 Jan 2010 00:31:52 -0000
@@ -212,6 +212,9 @@ class NodeRevisionsTestCase extends Drup
 }
 
 class PageEditTestCase extends DrupalWebTestCase {
+  protected $web_user;
+  protected $admin_user;
+
   public static function getInfo() {
     return array(
       'name' => 'Node edit',
@@ -223,14 +226,16 @@ class PageEditTestCase extends DrupalWeb
   function setUp() {
     parent::setUp();
 
-    $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
-    $this->drupalLogin($web_user);
+    $this->web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
+    $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes'));
   }
 
   /**
    * Check node edit functionality.
    */
   function testPageEdit() {
+    $this->drupalLogin($this->web_user);
+
     $langcode = LANGUAGE_NONE;
     $title_key = "title";
     $body_key = "body[$langcode][0][value]";
@@ -291,6 +296,51 @@ class PageEditTestCase extends DrupalWeb
     $second_node_version = node_load($node->nid, $revised_node->vid);
     $this->assertNotIdentical($first_node_version->revision_uid, $second_node_version->revision_uid, 'Each revision has a distinct user.');
   }
+
+  /**
+   * Check changing node authored by fields.
+   */
+  function testPageAuthoredBy() {
+    $this->drupalLogin($this->admin_user);
+
+    // Create node to edit.
+    $langcode = LANGUAGE_NONE;
+    $body_key = "body[$langcode][0][value]";
+    $edit = array();
+    $edit['title'] = $this->randomName(8);;
+    $edit[$body_key] = $this->randomName(16);
+    $this->drupalPost('node/add/page', $edit, t('Save'));
+
+    // Check that the node was authored by the currently logged in user.
+    $node = $this->drupalGetNodeByTitle($edit['title']);
+    $this->assertIdentical($node->uid, $this->admin_user->uid, 'Node authored by admin user.');
+
+    // Try to change the 'authored by' field to an invalid user name.
+    $edit = array(
+      'name' => 'invalid-name',
+    );
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+    $this->assertText('The username invalid-name does not exist.');
+
+    // Change the authored by field to an empty string, which should assign
+    // authorship to the anonymous user (uid 0).
+    $edit['name'] = '';
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+    $node = node_load($node->nid, NULL, TRUE);
+    $this->assertIdentical($node->uid, '0', 'Node authored by anonymous user.');
+
+    // Change the authored by field to another user's name (that is not
+    // logged in).
+    $edit['name'] = $this->web_user->name;
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+    $node = node_load($node->nid, NULL, TRUE);
+    $this->assertIdentical($node->uid, $this->web_user->uid, 'Node authored by normal user.');
+
+    // Check that normal users cannot change the authored by information.
+    $this->drupalLogin($this->web_user);
+    $this->drupalGet('node/' . $node->nid . '/edit');
+    $this->assertNoFieldByName('name');
+  }
 }
 
 class PagePreviewTestCase extends DrupalWebTestCase {
