diff --git a/modules/book/book.module b/modules/book/book.module index a2281ff4ee3142e514620c9a5e39d1f07a2789b3..cf53e2f0ad449a19ff0977b44e853b812193accb 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -232,13 +232,6 @@ function book_form(&$node) { ); $form['body_filter']['format'] = filter_form($node->format); - $form['log'] = array( - '#type' => 'textarea', - '#title' => t('Log message'), - '#weight' => 5, - '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'), - ); - if (user_access('administer nodes')) { $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), diff --git a/modules/node/node.module b/modules/node/node.module index c370c368aecdaed7d6ec2094dabe2501caa6893c..5e35ddb9d1c06c432d4dea0ecfc573c90873e6b4 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -571,12 +571,18 @@ function node_save(&$node) { // Split off revisions data to another structure $revisions_table_values = array('nid' => $node->nid, 'vid' => $node->vid, 'title' => $node->title, 'body' => $node->body, - 'teaser' => $node->teaser, 'log' => $node->log, 'timestamp' => $node->changed, + 'teaser' => $node->teaser, 'timestamp' => $node->changed, 'uid' => $user->uid, 'format' => $node->format); $revisions_table_types = array('nid' => '%d', 'vid' => '%d', 'title' => "'%s'", 'body' => "'%s'", - 'teaser' => "'%s'", 'log' => "'%s'", 'timestamp' => '%d', + 'teaser' => "'%s'", 'timestamp' => '%d', 'uid' => '%d', 'format' => '%d'); + if (!empty($node->log)) { + // Only store the log message if there's something to store; this prevents existing + // log messages from being unintentionally overwritten by a blank message. + $revisions_table_values['log'] = $node->log; + $revisions_table_types['log'] = "'%s'"; + } $node_table_values = array('nid' => $node->nid, 'vid' => $node->vid, 'title' => $node->title, 'type' => $node->type, 'uid' => $node->uid, 'status' => $node->status, 'created' => $node->created, @@ -1955,6 +1961,18 @@ function node_form($node, $form_values = NULL) { } $form['#node'] = $node; + // Add a log field if the "Create new revisions" option is checked, or if the + // current user has the ability to check that option. + if ($node->revision || user_access('administer nodes')) { + $form['log'] = array( + '#type' => 'textarea', + '#title' => t('Log message'), + '#rows' => 2, + '#weight' => 20, + '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'), + ); + } + // Node author information for administrators $form['author'] = array( '#type' => 'fieldset',