summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/book/book.module7
-rw-r--r--modules/node/node.module22
2 files changed, 20 insertions, 9 deletions
diff --git a/modules/book/book.module b/modules/book/book.module
index a2281ff4e..cf53e2f0a 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 c370c368a..5e35ddb9d 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',