Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
895db7dd
Unverified
Commit
895db7dd
authored
Jan 06, 2018
by
larowlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2934517
by Berdir: Setting a revision ID on a new entity sets the newRevision flag to false
parent
128cb262
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
core/lib/Drupal/Core/Entity/ContentEntityBase.php
core/lib/Drupal/Core/Entity/ContentEntityBase.php
+1
-1
core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
...ystem/tests/src/Functional/Entity/EntityRevisionsTest.php
+10
-0
No files found.
core/lib/Drupal/Core/Entity/ContentEntityBase.php
View file @
895db7dd
...
...
@@ -768,7 +768,7 @@ public function onChange($name) {
// If the revision identifier field is being populated with the original
// value, we need to make sure the "new revision" flag is reset
// accordingly.
if
(
$key
===
'revision'
&&
$this
->
getRevisionId
()
==
$this
->
getLoadedRevisionId
())
{
if
(
$key
===
'revision'
&&
$this
->
getRevisionId
()
==
$this
->
getLoadedRevisionId
()
&&
!
$this
->
isNew
()
)
{
$this
->
newRevision
=
FALSE
;
}
}
...
...
core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
View file @
895db7dd
...
...
@@ -256,6 +256,16 @@ public function testNewRevisionRevert() {
$this
->
assertNull
(
$entity
->
getRevisionId
());
$this
->
assertEquals
(
$revision_id
,
$entity
->
getLoadedRevisionId
());
$this
->
assertTrue
(
$entity
->
isNewRevision
());
// Check that calling setNewRevision() on a new entity without a revision ID
// and then with a revision ID does not unset the revision ID.
$entity
=
EntityTestMulRev
::
create
([
'name'
=>
'EntityLoadedRevisionTest'
]);
$entity
->
set
(
'revision_id'
,
NULL
);
$entity
->
set
(
'revision_id'
,
5
);
$this
->
assertTrue
(
$entity
->
isNewRevision
());
$entity
->
setNewRevision
();
$this
->
assertEquals
(
5
,
$entity
->
get
(
'revision_id'
)
->
value
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment