Commit 55c34581 authored by catch's avatar catch

Issue #2248991 by marco, tstoeckler, xjm: Rename the 'log' field to...

Issue #2248991 by marco, tstoeckler, xjm: Rename the 'log' field to 'revision_log' in Node and CustomBlock.
parent ac9286a4
......@@ -256,9 +256,11 @@ public function getTableMapping() {
// log.
// @todo Provide automatic definitions for revision metadata fields in
// https://drupal.org/node/2248983.
// @todo Rename 'log' to 'revision_log' in
// https://drupal.org/node/2248991.
$revision_metadata_fields = array_intersect(array('revision_timestamp', 'revision_uid', 'log'), $all_fields);
$revision_metadata_fields = array_intersect(array(
'revision_timestamp',
'revision_uid',
'revision_log',
), $all_fields);
$revisionable = $this->entityType->isRevisionable();
// @todo Remove the data table check once all entity types are using
......
......@@ -18,7 +18,7 @@
// or if the checkbox doesn't exist, but the revision log does. For users
// without the "Administer content" permission the checkbox won't appear,
// but the revision log will if the content type is set to auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-log textarea').length)) {
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-revision-log textarea').length)) {
return Drupal.t('New revision');
}
......
......@@ -150,12 +150,12 @@ public function form(array $form, array &$form_state) {
if (!$block->isNewRevision()) {
$form['revision_information']['revision']['#states'] = array(
'checked' => array(
'textarea[name="log"]' => array('empty' => FALSE),
'textarea[name="revision_log"]' => array('empty' => FALSE),
),
);
}
$form['revision_information']['log'] = array(
$form['revision_information']['revision_log'] = array(
'#type' => 'textarea',
'#title' => $this->t('Revision log message'),
'#rows' => 4,
......
......@@ -37,13 +37,13 @@ public function setInfo($info);
/**
* Sets the block revision log message.
*
* @param string $log
* @param string $revision_log
* The revision log message.
*
* @return \Drupal\custom_block\CustomBlockInterface
* The class instance that this method is called on.
*/
public function setRevisionLog($log);
public function setRevisionLog($revision_log);
/**
* Sets the theme value.
......
......@@ -115,23 +115,11 @@ public function getInstances() {
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
parent::preSaveRevision($storage, $record);
if ($this->isNewRevision()) {
// When inserting either a new custom block or a new custom_block
// revision, $entity->log must be set because {block_custom_revision}.log
// is a text column and therefore cannot have a default value. However,
// it might not be set at this point (for example, if the user submitting
// the form does not have permission to create revisions), so we ensure
// that it is at least an empty string in that case.
// @todo: Make the {block_custom_revision}.log column nullable so that we
// can remove this check.
if (!isset($record->log)) {
$record->log = '';
}
}
elseif (isset($this->original) && (!isset($record->log) || $record->log === '')) {
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
// If we are updating an existing custom_block without adding a new
// revision and the user did not supply a log, keep the existing one.
$record->log = $this->original->getRevisionLog();
// revision and the user did not supply a revision log, keep the existing
// one.
$record->revision_log = $this->original->getRevisionLog();
}
}
......@@ -186,9 +174,9 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('The block type.'))
->setSetting('target_type', 'custom_block_type');
$fields['log'] = FieldDefinition::create('string_long')
$fields['revision_log'] = FieldDefinition::create('string_long')
->setLabel(t('Revision log message'))
->setDescription(t('The revision log message.'))
->setDescription(t('The log entry explaining the changes in this revision.'))
->setRevisionable(TRUE);
$fields['changed'] = FieldDefinition::create('changed')
......@@ -210,7 +198,7 @@ public function getChangedTime() {
* {@inheritdoc}
*/
public function getRevisionLog() {
return $this->get('log')->value;
return $this->get('revision_log')->value;
}
/**
......@@ -224,8 +212,8 @@ public function setInfo($info) {
/**
* {@inheritdoc}
*/
public function setRevisionLog($log) {
$this->set('log', $log);
public function setRevisionLog($revision_log) {
$this->set('revision_log', $revision_log);
return $this;
}
......
......@@ -22,7 +22,7 @@ class CustomBlockRevisionsTest extends CustomBlockTestBase {
* Stores log messages used during the test.
* @var array
*/
protected $logs;
protected $revisionLogs;
/**
* Declares test information.
......@@ -62,7 +62,7 @@ protected function setUp() {
}
$this->blocks = $blocks;
$this->logs = $logs;
$this->revisionLogs = $logs;
}
/**
......@@ -70,12 +70,12 @@ protected function setUp() {
*/
public function testRevisions() {
$blocks = $this->blocks;
$logs = $this->logs;
$logs = $this->revisionLogs;
foreach ($blocks as $delta => $revision_id) {
// Confirm the correct revision text appears.
$loaded = entity_revision_load('custom_block', $revision_id);
// Verify log is the same.
// Verify revision log is the same.
$this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision !revision', array(
'!revision' => $loaded->getRevisionId(),
)));
......
......@@ -114,7 +114,7 @@ public function submitForm(array &$form, array &$form_state) {
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = $this->nodeStorage->load($values['nid']);
$node->log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title']));
$node->revision_log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title']));
$node->title = $values['title'];
$node->book['link_title'] = $values['title'];
$node->setNewRevision();
......
......@@ -18,7 +18,7 @@
// or if the checkbox doesn't exist, but the revision log does. For users
// without the "Administer content" permission the checkbox won't appear,
// but the revision log will if the content type is set to auto-revision.
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-log textarea').length)) {
if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-revision-log textarea').length)) {
return Drupal.t('New revision');
}
......
......@@ -483,7 +483,7 @@ function node_views_data() {
);
}
$data['node_revision']['log'] = array(
$data['node_revision']['revision_log'] = array(
'title' => t('Log message'),
'help' => t('The log message entered when the revision was created.'),
'field' => array(
......
......@@ -185,7 +185,7 @@ public function revisionOverview(NodeInterface $node) {
'#account' => $revision_author,
);
$row[] = array('data' => $this->t('!date by !username', array('!date' => $this->l($this->date->format($revision->revision_timestamp->value, 'short'), 'node.view', array('node' => $node->id())), '!username' => drupal_render($username)))
. (($revision->log->value != '') ? '<p class="revision-log">' . Xss::filter($revision->log->value) . '</p>' : ''),
. (($revision->revision_log->value != '') ? '<p class="revision-log">' . Xss::filter($revision->revision_log->value) . '</p>' : ''),
'class' => array('revision-current'));
$row[] = array('data' => String::placeholder($this->t('current revision')), 'class' => array('revision-current'));
}
......@@ -195,7 +195,7 @@ public function revisionOverview(NodeInterface $node) {
'#account' => $revision_author,
);
$row[] = $this->t('!date by !username', array('!date' => $this->l($this->date->format($revision->revision_timestamp->value, 'short'), 'node.revision_show', array('node' => $node->id(), 'node_revision' => $vid)), '!username' => drupal_render($username)))
. (($revision->log->value != '') ? '<p class="revision-log">' . Xss::filter($revision->log->value) . '</p>' : '');
. (($revision->revision_log->value != '') ? '<p class="revision-log">' . Xss::filter($revision->revision_log->value) . '</p>' : '');
if ($revert_permission) {
$links['revert'] = array(
......
......@@ -85,25 +85,12 @@ public function preSave(EntityStorageInterface $storage) {
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
parent::preSaveRevision($storage, $record);
if ($this->newRevision) {
// When inserting either a new node or a new node revision, $node->log
// must be set because {node_field_revision}.log is a text column and
// therefore cannot have a default value. However, it might not be set at
// this point (for example, if the user submitting a node form does not
// have permission to create revisions), so we ensure that it is at least
// an empty string in that case.
// @todo Make the {node_field_revision}.log column nullable so that we
// can remove this check.
if (!isset($record->log)) {
$record->log = '';
}
}
elseif (isset($this->original) && (!isset($record->log) || $record->log === '')) {
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
// If we are updating an existing node without adding a new revision, we
// need to make sure $entity->log is reset whenever it is empty.
// need to make sure $entity->revision_log is reset whenever it is empty.
// Therefore, this code allows us to avoid clobbering an existing log
// entry with an empty one.
$record->log = $this->original->log->value;
$record->revision_log = $this->original->revision_log->value;
}
}
......@@ -433,8 +420,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setQueryable(FALSE)
->setRevisionable(TRUE);
$fields['log'] = FieldDefinition::create('string_long')
->setLabel(t('Log'))
$fields['revision_log'] = FieldDefinition::create('string_long')
->setLabel(t('Revision log message'))
->setDescription(t('The log entry explaining the changes in this revision.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE);
......
......@@ -108,7 +108,7 @@ public function submitForm(array &$form, array &$form_state) {
// original one for the confirmation message.
$original_revision_timestamp = $this->revision->getRevisionCreationTime();
$this->revision->log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
$this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
$this->revision->save();
......
......@@ -38,8 +38,8 @@ protected function prepareEntity() {
if (!$node->isNew()) {
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O');
// Remove the log message from the original node entity.
$node->log = NULL;
// Remove the revision log message from the original node entity.
$node->revision_log = NULL;
}
}
......@@ -91,8 +91,8 @@ public function form(array $form, array &$form_state) {
'#weight' => 99,
);
// Add a log field if the "Create new revision" option is checked, or if
// the current user has the ability to check that option.
// Add a revision log field if the "Create new revision" option is checked,
// or if the current user has the ability to check that option.
$form['revision_information'] = array(
'#type' => 'details',
'#group' => 'advanced',
......@@ -117,11 +117,11 @@ public function form(array $form, array &$form_state) {
'#group' => 'revision_information',
);
$form['log'] = array(
$form['revision_log'] = array(
'#type' => 'textarea',
'#title' => t('Revision log message'),
'#rows' => 4,
'#default_value' => !empty($node->log->value) ? $node->log->value : '',
'#default_value' => !empty($node->revision_log->value) ? $node->revision_log->value : '',
'#description' => t('Briefly describe the changes you have made.'),
'#states' => array(
'visible' => array(
......
......@@ -50,7 +50,7 @@ function setUp() {
// Create a revision for the same nid and settings with a random log.
$revision = clone $nodes[$type];
$revision->setNewRevision();
$revision->log = $this->randomName(32);
$revision->revision_log = $this->randomName(32);
$revision->save();
$this->node_revisions[$type][] = $revision;
}
......
......@@ -14,7 +14,7 @@
*/
class NodeRevisionsAllTestCase extends NodeTestBase {
protected $nodes;
protected $logs;
protected $revisionLogs;
protected $profile = "standard";
public static function getInfo() {
......@@ -55,7 +55,7 @@ function setUp() {
// Create three revisions.
$revision_count = 3;
for ($i = 0; $i < $revision_count; $i++) {
$logs[] = $node->log = $this->randomName(32);
$logs[] = $node->revision_log = $this->randomName(32);
// Create revision with a random title and body and update variables.
$node->title = $this->randomName();
......@@ -71,7 +71,7 @@ function setUp() {
}
$this->nodes = $nodes;
$this->logs = $logs;
$this->revisionLogs = $logs;
}
/**
......@@ -79,7 +79,7 @@ function setUp() {
*/
function testRevisions() {
$nodes = $this->nodes;
$logs = $this->logs;
$logs = $this->revisionLogs;
// Get last node for simple checks.
$node = $nodes[3];
......@@ -100,10 +100,11 @@ function testRevisions() {
$this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view");
$this->assertText($node->body->value, 'Correct text displays for version.');
// Confirm the correct log message appears on "revisions overview" page.
// Confirm the correct revision log message appears on the "revisions
// overview" page.
$this->drupalGet("node/" . $node->id() . "/revisions");
foreach ($logs as $log) {
$this->assertText($log, 'Log message found.');
foreach ($logs as $revision_log) {
$this->assertText($revision_log, 'Revision log message found.');
}
// Confirm that this is the current revision.
......
......@@ -14,7 +14,7 @@
*/
class NodeRevisionsTest extends NodeTestBase {
protected $nodes;
protected $logs;
protected $revisionLogs;
public static function getInfo() {
return array(
......@@ -55,7 +55,7 @@ function setUp() {
// Create three revisions.
$revision_count = 3;
for ($i = 0; $i < $revision_count; $i++) {
$logs[] = $node->log = $this->randomName(32);
$logs[] = $node->revision_log = $this->randomName(32);
// Create revision with a random title and body and update variables.
$node->title = $this->randomName();
......@@ -71,7 +71,7 @@ function setUp() {
}
$this->nodes = $nodes;
$this->logs = $logs;
$this->revisionLogs = $logs;
}
/**
......@@ -79,7 +79,7 @@ function setUp() {
*/
function testRevisions() {
$nodes = $this->nodes;
$logs = $this->logs;
$logs = $this->revisionLogs;
// Get last node for simple checks.
$node = $nodes[3];
......@@ -90,8 +90,8 @@ function testRevisions() {
// Confirm the correct log message appears on "revisions overview" page.
$this->drupalGet("node/" . $node->id() . "/revisions");
foreach ($logs as $log) {
$this->assertText($log, 'Log message found.');
foreach ($logs as $revision_log) {
$this->assertText($revision_log, 'Revision log message found.');
}
// Confirm that this is the default revision.
......@@ -165,8 +165,8 @@ function testRevisions() {
*/
function testNodeRevisionWithoutLogMessage() {
// Create a node with an initial log message.
$log = $this->randomName(10);
$node = $this->drupalCreateNode(array('log' => $log));
$revision_log = $this->randomName(10);
$node = $this->drupalCreateNode(array('revision_log' => $revision_log));
// Save over the same revision and explicitly provide an empty log message
// (for example, to mimic the case of a node form submitted with no text in
......@@ -176,17 +176,17 @@ function testNodeRevisionWithoutLogMessage() {
$node = clone $node;
$node->title = $new_title;
$node->log = '';
$node->revision_log = '';
$node->setNewRevision(FALSE);
$node->save();
$this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
$node_revision = node_load($node->id(), TRUE);
$this->assertEqual($node_revision->log->value, $log, 'After an existing node revision is re-saved without a log message, the original log message is preserved.');
$this->assertEqual($node_revision->revision_log->value, $revision_log, 'After an existing node revision is re-saved without a log message, the original log message is preserved.');
// Create another node with an initial log message.
$node = $this->drupalCreateNode(array('log' => $log));
// Create another node with an initial revision log message.
$node = $this->drupalCreateNode(array('revision_log' => $revision_log));
// Save a new node revision without providing a log message, and check that
// this revision has an empty log message.
......@@ -195,12 +195,12 @@ function testNodeRevisionWithoutLogMessage() {
$node = clone $node;
$node->title = $new_title;
$node->setNewRevision();
$node->log = NULL;
$node->revision_log = NULL;
$node->save();
$this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
$node_revision = node_load($node->id(), TRUE);
$this->assertTrue(empty($node_revision->log->value), 'After a new node revision is saved with an empty log message, the log message for the node is empty.');
$this->assertTrue(empty($node_revision->revision_log->value), 'After a new node revision is saved with an empty log message, the log message for the node is empty.');
}
}
......@@ -192,7 +192,7 @@ function testPagePreviewWithRevisions() {
$edit[$title_key] = $this->randomName(8);
$edit[$body_key] = $this->randomName(16);
$edit[$term_key] = $this->term->id();
$edit['log'] = $this->randomName(32);
$edit['revision_log'] = $this->randomName(32);
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
// Check that the preview is displaying the title, body and term.
......@@ -206,8 +206,8 @@ function testPagePreviewWithRevisions() {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
// Check that the log field has the correct value.
$this->assertFieldByName('log', $edit['log'], 'Log field displayed.');
// Check that the revision log field has the correct value.
$this->assertFieldByName('revision_log', $edit['revision_log'], 'Revision log field displayed.');
}
}
......@@ -123,7 +123,7 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name
$node_type_settings = $this->nodeTypeStorage->load($entity->bundle())->getModuleSettings('node');
$options = (isset($node_type_settings['options'])) ? $node_type_settings['options'] : array();
$entity->setNewRevision(!empty($options['revision']));
$entity->log = NULL;
$entity->revision_log = NULL;
}
$form_state['entity'] = $entity;
......@@ -186,8 +186,8 @@ protected function buildEntity(array $form, array &$form_state) {
// @todo Refine automated log messages and abstract them to all entity
// types: http://drupal.org/node/1678002.
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && !isset($entity->log)) {
$entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && !isset($entity->revision_log)) {
$entity->revision_log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
}
return $entity;
......
......@@ -60,7 +60,7 @@ protected function setUp() {
'format' => 'filtered_html',
)
),
'log' => $this->randomString(),
'revision_log' => $this->randomString(),
));
// Create 2 users, the only difference being the ability to use in-place
......@@ -146,7 +146,7 @@ public function testUserWithPermission() {
$node = node_load(1);
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
$this->assertIdentical(1, count($vids), 'The node has only one revision.');
$original_log = $node->log->value;
$original_log = $node->revision_log->value;
// Retrieving the metadata should result in a 200 JSON response.
$htmlPageDrupalSettings = $this->drupalSettings;
......@@ -240,7 +240,7 @@ public function testUserWithPermission() {
$node = node_load(1);
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
$this->assertIdentical(1, count($vids), 'The node has only one revision.');
$this->assertIdentical($original_log, $node->log->value, 'The revision log message is unchanged.');
$this->assertIdentical($original_log, $node->revision_log->value, 'The revision log message is unchanged.');
// Now configure this node type to create new revisions automatically,
// then again retrieve the field form, fill it, submit it (so it ends up
......@@ -289,9 +289,9 @@ public function testUserWithPermission() {
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds(node_load(1));
$this->assertIdentical(2, count($vids), 'The node has two revisions.');
$revision = node_revision_load($vids[0]);
$this->assertIdentical($original_log, $revision->log->value, 'The first revision log message is unchanged.');
$this->assertIdentical($original_log, $revision->revision_log->value, 'The first revision log message is unchanged.');
$revision = node_revision_load($vids[1]);
$this->assertIdentical('Updated the <em class="placeholder">Body</em> field through in-place editing.', $revision->log->value, 'The second revision log message was correctly generated by Quick Edit module.');
$this->assertIdentical('Updated the <em class="placeholder">Body</em> field through in-place editing.', $revision->revision_log->value, 'The second revision log message was correctly generated by Quick Edit module.');
}
}
......
......@@ -490,11 +490,11 @@ public function testGetTableMappingRevisionableWithFields(array $entity_keys) {
array(),
array('revision_timestamp'),
array('revision_uid'),
array('log'),
array('revision_log'),
array('revision_timestamp', 'revision_uid'),
array('revision_timestamp', 'log'),
array('revision_uid', 'log'),
array('revision_timestamp', 'revision_uid', 'log'),
array('revision_timestamp', 'revision_log'),
array('revision_uid', 'revision_log'),
array('revision_timestamp', 'revision_uid', 'revision_log'),
);
foreach ($test_cases as $revision_metadata_field_names) {
$this->setUp();
......@@ -797,11 +797,11 @@ public function testGetTableMappingRevisionableTranslatableWithFields(array $ent
array(),
array('revision_timestamp'),
array('revision_uid'),
array('log'),
array('revision_log'),
array('revision_timestamp', 'revision_uid'),
array('revision_timestamp', 'log'),
array('revision_uid', 'log'),
array('revision_timestamp', 'revision_uid', 'log'),
array('revision_timestamp', 'revision_log'),
array('revision_uid', 'revision_log'),
array('revision_timestamp', 'revision_uid', 'revision_log'),
);
foreach ($test_cases as $revision_metadata_field_names) {
$this->setUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment