Issue #2248991 by marco, tstoeckler, xjm: Rename the 'log' field to 'revision_log' in Node and CustomBlock.
parent
ac9286a47d
commit
55c34581e4
|
@ -256,9 +256,11 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S
|
||||||
// log.
|
// log.
|
||||||
// @todo Provide automatic definitions for revision metadata fields in
|
// @todo Provide automatic definitions for revision metadata fields in
|
||||||
// https://drupal.org/node/2248983.
|
// https://drupal.org/node/2248983.
|
||||||
// @todo Rename 'log' to 'revision_log' in
|
$revision_metadata_fields = array_intersect(array(
|
||||||
// https://drupal.org/node/2248991.
|
'revision_timestamp',
|
||||||
$revision_metadata_fields = array_intersect(array('revision_timestamp', 'revision_uid', 'log'), $all_fields);
|
'revision_uid',
|
||||||
|
'revision_log',
|
||||||
|
), $all_fields);
|
||||||
|
|
||||||
$revisionable = $this->entityType->isRevisionable();
|
$revisionable = $this->entityType->isRevisionable();
|
||||||
// @todo Remove the data table check once all entity types are using
|
// @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
|
// or if the checkbox doesn't exist, but the revision log does. For users
|
||||||
// without the "Administer content" permission the checkbox won't appear,
|
// without the "Administer content" permission the checkbox won't appear,
|
||||||
// but the revision log will if the content type is set to auto-revision.
|
// 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');
|
return Drupal.t('New revision');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,12 +150,12 @@ class CustomBlockForm extends ContentEntityForm {
|
||||||
if (!$block->isNewRevision()) {
|
if (!$block->isNewRevision()) {
|
||||||
$form['revision_information']['revision']['#states'] = array(
|
$form['revision_information']['revision']['#states'] = array(
|
||||||
'checked' => 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',
|
'#type' => 'textarea',
|
||||||
'#title' => $this->t('Revision log message'),
|
'#title' => $this->t('Revision log message'),
|
||||||
'#rows' => 4,
|
'#rows' => 4,
|
||||||
|
|
|
@ -37,13 +37,13 @@ interface CustomBlockInterface extends ContentEntityInterface, EntityChangedInte
|
||||||
/**
|
/**
|
||||||
* Sets the block revision log message.
|
* Sets the block revision log message.
|
||||||
*
|
*
|
||||||
* @param string $log
|
* @param string $revision_log
|
||||||
* The revision log message.
|
* The revision log message.
|
||||||
*
|
*
|
||||||
* @return \Drupal\custom_block\CustomBlockInterface
|
* @return \Drupal\custom_block\CustomBlockInterface
|
||||||
* The class instance that this method is called on.
|
* The class instance that this method is called on.
|
||||||
*/
|
*/
|
||||||
public function setRevisionLog($log);
|
public function setRevisionLog($revision_log);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the theme value.
|
* Sets the theme value.
|
||||||
|
|
|
@ -115,23 +115,11 @@ class CustomBlock extends ContentEntityBase implements CustomBlockInterface {
|
||||||
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
|
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
|
||||||
parent::preSaveRevision($storage, $record);
|
parent::preSaveRevision($storage, $record);
|
||||||
|
|
||||||
if ($this->isNewRevision()) {
|
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
|
||||||
// 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 we are updating an existing custom_block without adding a new
|
// 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.
|
// revision and the user did not supply a revision log, keep the existing
|
||||||
$record->log = $this->original->getRevisionLog();
|
// one.
|
||||||
|
$record->revision_log = $this->original->getRevisionLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,9 +174,9 @@ class CustomBlock extends ContentEntityBase implements CustomBlockInterface {
|
||||||
->setDescription(t('The block type.'))
|
->setDescription(t('The block type.'))
|
||||||
->setSetting('target_type', 'custom_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'))
|
->setLabel(t('Revision log message'))
|
||||||
->setDescription(t('The revision log message.'))
|
->setDescription(t('The log entry explaining the changes in this revision.'))
|
||||||
->setRevisionable(TRUE);
|
->setRevisionable(TRUE);
|
||||||
|
|
||||||
$fields['changed'] = FieldDefinition::create('changed')
|
$fields['changed'] = FieldDefinition::create('changed')
|
||||||
|
@ -210,7 +198,7 @@ class CustomBlock extends ContentEntityBase implements CustomBlockInterface {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getRevisionLog() {
|
public function getRevisionLog() {
|
||||||
return $this->get('log')->value;
|
return $this->get('revision_log')->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,8 +212,8 @@ class CustomBlock extends ContentEntityBase implements CustomBlockInterface {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setRevisionLog($log) {
|
public function setRevisionLog($revision_log) {
|
||||||
$this->set('log', $log);
|
$this->set('revision_log', $revision_log);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CustomBlockRevisionsTest extends CustomBlockTestBase {
|
||||||
* Stores log messages used during the test.
|
* Stores log messages used during the test.
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $logs;
|
protected $revisionLogs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares test information.
|
* Declares test information.
|
||||||
|
@ -62,7 +62,7 @@ class CustomBlockRevisionsTest extends CustomBlockTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->blocks = $blocks;
|
$this->blocks = $blocks;
|
||||||
$this->logs = $logs;
|
$this->revisionLogs = $logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,12 +70,12 @@ class CustomBlockRevisionsTest extends CustomBlockTestBase {
|
||||||
*/
|
*/
|
||||||
public function testRevisions() {
|
public function testRevisions() {
|
||||||
$blocks = $this->blocks;
|
$blocks = $this->blocks;
|
||||||
$logs = $this->logs;
|
$logs = $this->revisionLogs;
|
||||||
|
|
||||||
foreach ($blocks as $delta => $revision_id) {
|
foreach ($blocks as $delta => $revision_id) {
|
||||||
// Confirm the correct revision text appears.
|
// Confirm the correct revision text appears.
|
||||||
$loaded = entity_revision_load('custom_block', $revision_id);
|
$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(
|
$this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision !revision', array(
|
||||||
'!revision' => $loaded->getRevisionId(),
|
'!revision' => $loaded->getRevisionId(),
|
||||||
)));
|
)));
|
||||||
|
|
|
@ -114,7 +114,7 @@ class BookAdminEditForm extends FormBase {
|
||||||
// Update the title if changed.
|
// Update the title if changed.
|
||||||
if ($row['title']['#default_value'] != $values['title']) {
|
if ($row['title']['#default_value'] != $values['title']) {
|
||||||
$node = $this->nodeStorage->load($values['nid']);
|
$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->title = $values['title'];
|
||||||
$node->book['link_title'] = $values['title'];
|
$node->book['link_title'] = $values['title'];
|
||||||
$node->setNewRevision();
|
$node->setNewRevision();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// or if the checkbox doesn't exist, but the revision log does. For users
|
// or if the checkbox doesn't exist, but the revision log does. For users
|
||||||
// without the "Administer content" permission the checkbox won't appear,
|
// without the "Administer content" permission the checkbox won't appear,
|
||||||
// but the revision log will if the content type is set to auto-revision.
|
// 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');
|
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'),
|
'title' => t('Log message'),
|
||||||
'help' => t('The log message entered when the revision was created.'),
|
'help' => t('The log message entered when the revision was created.'),
|
||||||
'field' => array(
|
'field' => array(
|
||||||
|
|
|
@ -185,7 +185,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
|
||||||
'#account' => $revision_author,
|
'#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)))
|
$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'));
|
'class' => array('revision-current'));
|
||||||
$row[] = array('data' => String::placeholder($this->t('current revision')), 'class' => array('revision-current'));
|
$row[] = array('data' => String::placeholder($this->t('current revision')), 'class' => array('revision-current'));
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
|
||||||
'#account' => $revision_author,
|
'#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)))
|
$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) {
|
if ($revert_permission) {
|
||||||
$links['revert'] = array(
|
$links['revert'] = array(
|
||||||
|
|
|
@ -85,25 +85,12 @@ class Node extends ContentEntityBase implements NodeInterface {
|
||||||
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
|
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
|
||||||
parent::preSaveRevision($storage, $record);
|
parent::preSaveRevision($storage, $record);
|
||||||
|
|
||||||
if ($this->newRevision) {
|
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
|
||||||
// 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 we are updating an existing node without adding a new revision, we
|
// 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
|
// Therefore, this code allows us to avoid clobbering an existing log
|
||||||
// entry with an empty one.
|
// entry with an empty one.
|
||||||
$record->log = $this->original->log->value;
|
$record->revision_log = $this->original->revision_log->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,8 +420,8 @@ class Node extends ContentEntityBase implements NodeInterface {
|
||||||
->setQueryable(FALSE)
|
->setQueryable(FALSE)
|
||||||
->setRevisionable(TRUE);
|
->setRevisionable(TRUE);
|
||||||
|
|
||||||
$fields['log'] = FieldDefinition::create('string_long')
|
$fields['revision_log'] = FieldDefinition::create('string_long')
|
||||||
->setLabel(t('Log'))
|
->setLabel(t('Revision log message'))
|
||||||
->setDescription(t('The log entry explaining the changes in this revision.'))
|
->setDescription(t('The log entry explaining the changes in this revision.'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setTranslatable(TRUE);
|
->setTranslatable(TRUE);
|
||||||
|
|
|
@ -108,7 +108,7 @@ class NodeRevisionRevertForm extends ConfirmFormBase {
|
||||||
// original one for the confirmation message.
|
// original one for the confirmation message.
|
||||||
$original_revision_timestamp = $this->revision->getRevisionCreationTime();
|
$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();
|
$this->revision->save();
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ class NodeForm extends ContentEntityForm {
|
||||||
|
|
||||||
if (!$node->isNew()) {
|
if (!$node->isNew()) {
|
||||||
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O');
|
$node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O');
|
||||||
// Remove the log message from the original node entity.
|
// Remove the revision log message from the original node entity.
|
||||||
$node->log = NULL;
|
$node->revision_log = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ class NodeForm extends ContentEntityForm {
|
||||||
'#weight' => 99,
|
'#weight' => 99,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add a log field if the "Create new revision" option is checked, or if
|
// Add a revision log field if the "Create new revision" option is checked,
|
||||||
// the current user has the ability to check that option.
|
// or if the current user has the ability to check that option.
|
||||||
$form['revision_information'] = array(
|
$form['revision_information'] = array(
|
||||||
'#type' => 'details',
|
'#type' => 'details',
|
||||||
'#group' => 'advanced',
|
'#group' => 'advanced',
|
||||||
|
@ -117,11 +117,11 @@ class NodeForm extends ContentEntityForm {
|
||||||
'#group' => 'revision_information',
|
'#group' => 'revision_information',
|
||||||
);
|
);
|
||||||
|
|
||||||
$form['log'] = array(
|
$form['revision_log'] = array(
|
||||||
'#type' => 'textarea',
|
'#type' => 'textarea',
|
||||||
'#title' => t('Revision log message'),
|
'#title' => t('Revision log message'),
|
||||||
'#rows' => 4,
|
'#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.'),
|
'#description' => t('Briefly describe the changes you have made.'),
|
||||||
'#states' => array(
|
'#states' => array(
|
||||||
'visible' => array(
|
'visible' => array(
|
||||||
|
|
|
@ -50,7 +50,7 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
|
||||||
// Create a revision for the same nid and settings with a random log.
|
// Create a revision for the same nid and settings with a random log.
|
||||||
$revision = clone $nodes[$type];
|
$revision = clone $nodes[$type];
|
||||||
$revision->setNewRevision();
|
$revision->setNewRevision();
|
||||||
$revision->log = $this->randomName(32);
|
$revision->revision_log = $this->randomName(32);
|
||||||
$revision->save();
|
$revision->save();
|
||||||
$this->node_revisions[$type][] = $revision;
|
$this->node_revisions[$type][] = $revision;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\Core\Language\Language;
|
||||||
*/
|
*/
|
||||||
class NodeRevisionsAllTestCase extends NodeTestBase {
|
class NodeRevisionsAllTestCase extends NodeTestBase {
|
||||||
protected $nodes;
|
protected $nodes;
|
||||||
protected $logs;
|
protected $revisionLogs;
|
||||||
protected $profile = "standard";
|
protected $profile = "standard";
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
|
@ -55,7 +55,7 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
|
||||||
// Create three revisions.
|
// Create three revisions.
|
||||||
$revision_count = 3;
|
$revision_count = 3;
|
||||||
for ($i = 0; $i < $revision_count; $i++) {
|
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.
|
// Create revision with a random title and body and update variables.
|
||||||
$node->title = $this->randomName();
|
$node->title = $this->randomName();
|
||||||
|
@ -71,7 +71,7 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nodes = $nodes;
|
$this->nodes = $nodes;
|
||||||
$this->logs = $logs;
|
$this->revisionLogs = $logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
|
||||||
*/
|
*/
|
||||||
function testRevisions() {
|
function testRevisions() {
|
||||||
$nodes = $this->nodes;
|
$nodes = $this->nodes;
|
||||||
$logs = $this->logs;
|
$logs = $this->revisionLogs;
|
||||||
|
|
||||||
// Get last node for simple checks.
|
// Get last node for simple checks.
|
||||||
$node = $nodes[3];
|
$node = $nodes[3];
|
||||||
|
@ -100,10 +100,11 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
|
||||||
$this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view");
|
$this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view");
|
||||||
$this->assertText($node->body->value, 'Correct text displays for version.');
|
$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");
|
$this->drupalGet("node/" . $node->id() . "/revisions");
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $revision_log) {
|
||||||
$this->assertText($log, 'Log message found.');
|
$this->assertText($revision_log, 'Revision log message found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm that this is the current revision.
|
// Confirm that this is the current revision.
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Drupal\Core\Language\Language;
|
||||||
*/
|
*/
|
||||||
class NodeRevisionsTest extends NodeTestBase {
|
class NodeRevisionsTest extends NodeTestBase {
|
||||||
protected $nodes;
|
protected $nodes;
|
||||||
protected $logs;
|
protected $revisionLogs;
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -55,7 +55,7 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
// Create three revisions.
|
// Create three revisions.
|
||||||
$revision_count = 3;
|
$revision_count = 3;
|
||||||
for ($i = 0; $i < $revision_count; $i++) {
|
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.
|
// Create revision with a random title and body and update variables.
|
||||||
$node->title = $this->randomName();
|
$node->title = $this->randomName();
|
||||||
|
@ -71,7 +71,7 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->nodes = $nodes;
|
$this->nodes = $nodes;
|
||||||
$this->logs = $logs;
|
$this->revisionLogs = $logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
*/
|
*/
|
||||||
function testRevisions() {
|
function testRevisions() {
|
||||||
$nodes = $this->nodes;
|
$nodes = $this->nodes;
|
||||||
$logs = $this->logs;
|
$logs = $this->revisionLogs;
|
||||||
|
|
||||||
// Get last node for simple checks.
|
// Get last node for simple checks.
|
||||||
$node = $nodes[3];
|
$node = $nodes[3];
|
||||||
|
@ -90,8 +90,8 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
|
|
||||||
// Confirm the correct log message appears on "revisions overview" page.
|
// Confirm the correct log message appears on "revisions overview" page.
|
||||||
$this->drupalGet("node/" . $node->id() . "/revisions");
|
$this->drupalGet("node/" . $node->id() . "/revisions");
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $revision_log) {
|
||||||
$this->assertText($log, 'Log message found.');
|
$this->assertText($revision_log, 'Revision log message found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm that this is the default revision.
|
// Confirm that this is the default revision.
|
||||||
|
@ -165,8 +165,8 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
*/
|
*/
|
||||||
function testNodeRevisionWithoutLogMessage() {
|
function testNodeRevisionWithoutLogMessage() {
|
||||||
// Create a node with an initial log message.
|
// Create a node with an initial log message.
|
||||||
$log = $this->randomName(10);
|
$revision_log = $this->randomName(10);
|
||||||
$node = $this->drupalCreateNode(array('log' => $log));
|
$node = $this->drupalCreateNode(array('revision_log' => $revision_log));
|
||||||
|
|
||||||
// Save over the same revision and explicitly provide an empty log message
|
// 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
|
// (for example, to mimic the case of a node form submitted with no text in
|
||||||
|
@ -176,17 +176,17 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
|
|
||||||
$node = clone $node;
|
$node = clone $node;
|
||||||
$node->title = $new_title;
|
$node->title = $new_title;
|
||||||
$node->log = '';
|
$node->revision_log = '';
|
||||||
$node->setNewRevision(FALSE);
|
$node->setNewRevision(FALSE);
|
||||||
|
|
||||||
$node->save();
|
$node->save();
|
||||||
$this->drupalGet('node/' . $node->id());
|
$this->drupalGet('node/' . $node->id());
|
||||||
$this->assertText($new_title, 'New node title appears on the page.');
|
$this->assertText($new_title, 'New node title appears on the page.');
|
||||||
$node_revision = node_load($node->id(), TRUE);
|
$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.
|
// Create another node with an initial revision log message.
|
||||||
$node = $this->drupalCreateNode(array('log' => $log));
|
$node = $this->drupalCreateNode(array('revision_log' => $revision_log));
|
||||||
|
|
||||||
// Save a new node revision without providing a log message, and check that
|
// Save a new node revision without providing a log message, and check that
|
||||||
// this revision has an empty log message.
|
// this revision has an empty log message.
|
||||||
|
@ -195,12 +195,12 @@ class NodeRevisionsTest extends NodeTestBase {
|
||||||
$node = clone $node;
|
$node = clone $node;
|
||||||
$node->title = $new_title;
|
$node->title = $new_title;
|
||||||
$node->setNewRevision();
|
$node->setNewRevision();
|
||||||
$node->log = NULL;
|
$node->revision_log = NULL;
|
||||||
|
|
||||||
$node->save();
|
$node->save();
|
||||||
$this->drupalGet('node/' . $node->id());
|
$this->drupalGet('node/' . $node->id());
|
||||||
$this->assertText($new_title, 'New node title appears on the page.');
|
$this->assertText($new_title, 'New node title appears on the page.');
|
||||||
$node_revision = node_load($node->id(), TRUE);
|
$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 @@ class PagePreviewTest extends NodeTestBase {
|
||||||
$edit[$title_key] = $this->randomName(8);
|
$edit[$title_key] = $this->randomName(8);
|
||||||
$edit[$body_key] = $this->randomName(16);
|
$edit[$body_key] = $this->randomName(16);
|
||||||
$edit[$term_key] = $this->term->id();
|
$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'));
|
$this->drupalPostForm('node/add/page', $edit, t('Preview'));
|
||||||
|
|
||||||
// Check that the preview is displaying the title, body and term.
|
// Check that the preview is displaying the title, body and term.
|
||||||
|
@ -206,8 +206,8 @@ class PagePreviewTest extends NodeTestBase {
|
||||||
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
|
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
|
||||||
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
|
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
|
||||||
|
|
||||||
// Check that the log field has the correct value.
|
// Check that the revision log field has the correct value.
|
||||||
$this->assertFieldByName('log', $edit['log'], 'Log field displayed.');
|
$this->assertFieldByName('revision_log', $edit['revision_log'], 'Revision log field displayed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ class QuickEditFieldForm extends FormBase {
|
||||||
$node_type_settings = $this->nodeTypeStorage->load($entity->bundle())->getModuleSettings('node');
|
$node_type_settings = $this->nodeTypeStorage->load($entity->bundle())->getModuleSettings('node');
|
||||||
$options = (isset($node_type_settings['options'])) ? $node_type_settings['options'] : array();
|
$options = (isset($node_type_settings['options'])) ? $node_type_settings['options'] : array();
|
||||||
$entity->setNewRevision(!empty($options['revision']));
|
$entity->setNewRevision(!empty($options['revision']));
|
||||||
$entity->log = NULL;
|
$entity->revision_log = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$form_state['entity'] = $entity;
|
$form_state['entity'] = $entity;
|
||||||
|
@ -186,8 +186,8 @@ class QuickEditFieldForm extends FormBase {
|
||||||
|
|
||||||
// @todo Refine automated log messages and abstract them to all entity
|
// @todo Refine automated log messages and abstract them to all entity
|
||||||
// types: http://drupal.org/node/1678002.
|
// types: http://drupal.org/node/1678002.
|
||||||
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && !isset($entity->log)) {
|
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && !isset($entity->revision_log)) {
|
||||||
$entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
|
$entity->revision_log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
|
@ -60,7 +60,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
||||||
'format' => 'filtered_html',
|
'format' => 'filtered_html',
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'log' => $this->randomString(),
|
'revision_log' => $this->randomString(),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Create 2 users, the only difference being the ability to use in-place
|
// Create 2 users, the only difference being the ability to use in-place
|
||||||
|
@ -146,7 +146,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
||||||
$node = node_load(1);
|
$node = node_load(1);
|
||||||
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
|
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
|
||||||
$this->assertIdentical(1, count($vids), 'The node has only one revision.');
|
$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.
|
// Retrieving the metadata should result in a 200 JSON response.
|
||||||
$htmlPageDrupalSettings = $this->drupalSettings;
|
$htmlPageDrupalSettings = $this->drupalSettings;
|
||||||
|
@ -240,7 +240,7 @@ class QuickEditLoadingTest extends WebTestBase {
|
||||||
$node = node_load(1);
|
$node = node_load(1);
|
||||||
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
|
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node);
|
||||||
$this->assertIdentical(1, count($vids), 'The node has only one revision.');
|
$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,
|
// Now configure this node type to create new revisions automatically,
|
||||||
// then again retrieve the field form, fill it, submit it (so it ends up
|
// then again retrieve the field form, fill it, submit it (so it ends up
|
||||||
|
@ -289,9 +289,9 @@ class QuickEditLoadingTest extends WebTestBase {
|
||||||
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds(node_load(1));
|
$vids = \Drupal::entityManager()->getStorage('node')->revisionIds(node_load(1));
|
||||||
$this->assertIdentical(2, count($vids), 'The node has two revisions.');
|
$this->assertIdentical(2, count($vids), 'The node has two revisions.');
|
||||||
$revision = node_revision_load($vids[0]);
|
$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]);
|
$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 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
|
||||||
array(),
|
array(),
|
||||||
array('revision_timestamp'),
|
array('revision_timestamp'),
|
||||||
array('revision_uid'),
|
array('revision_uid'),
|
||||||
array('log'),
|
array('revision_log'),
|
||||||
array('revision_timestamp', 'revision_uid'),
|
array('revision_timestamp', 'revision_uid'),
|
||||||
array('revision_timestamp', 'log'),
|
array('revision_timestamp', 'revision_log'),
|
||||||
array('revision_uid', 'log'),
|
array('revision_uid', 'revision_log'),
|
||||||
array('revision_timestamp', 'revision_uid', 'log'),
|
array('revision_timestamp', 'revision_uid', 'revision_log'),
|
||||||
);
|
);
|
||||||
foreach ($test_cases as $revision_metadata_field_names) {
|
foreach ($test_cases as $revision_metadata_field_names) {
|
||||||
$this->setUp();
|
$this->setUp();
|
||||||
|
@ -797,11 +797,11 @@ class ContentEntityDatabaseStorageTest extends UnitTestCase {
|
||||||
array(),
|
array(),
|
||||||
array('revision_timestamp'),
|
array('revision_timestamp'),
|
||||||
array('revision_uid'),
|
array('revision_uid'),
|
||||||
array('log'),
|
array('revision_log'),
|
||||||
array('revision_timestamp', 'revision_uid'),
|
array('revision_timestamp', 'revision_uid'),
|
||||||
array('revision_timestamp', 'log'),
|
array('revision_timestamp', 'revision_log'),
|
||||||
array('revision_uid', 'log'),
|
array('revision_uid', 'revision_log'),
|
||||||
array('revision_timestamp', 'revision_uid', 'log'),
|
array('revision_timestamp', 'revision_uid', 'revision_log'),
|
||||||
);
|
);
|
||||||
foreach ($test_cases as $revision_metadata_field_names) {
|
foreach ($test_cases as $revision_metadata_field_names) {
|
||||||
$this->setUp();
|
$this->setUp();
|
||||||
|
|
Loading…
Reference in New Issue