Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3424701
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3424701
Commits
86b2f9e2
Commit
86b2f9e2
authored
2 months ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3498115
by amateescu: Fix usage of temporary entity data in Workspaces
parent
017ad48a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/workspaces/src/Hook/EntityOperations.php
+9
-6
9 additions, 6 deletions
core/modules/workspaces/src/Hook/EntityOperations.php
with
9 additions
and
6 deletions
core/modules/workspaces/src/Hook/EntityOperations.php
+
9
−
6
View file @
86b2f9e2
...
@@ -21,6 +21,11 @@
...
@@ -21,6 +21,11 @@
*/
*/
class
EntityOperations
{
class
EntityOperations
{
/**
* A list of entity UUIDs that were created as published in a workspace.
*/
protected
array
$initialPublished
=
[];
public
function
__construct
(
public
function
__construct
(
protected
EntityTypeManagerInterface
$entityTypeManager
,
protected
EntityTypeManagerInterface
$entityTypeManager
,
protected
WorkspaceManagerInterface
$workspaceManager
,
protected
WorkspaceManagerInterface
$workspaceManager
,
...
@@ -113,11 +118,9 @@ public function entityPresave(EntityInterface $entity): void {
...
@@ -113,11 +118,9 @@ public function entityPresave(EntityInterface $entity): void {
// - An unpublished default revision in the default ('live') workspace.
// - An unpublished default revision in the default ('live') workspace.
// - A published pending revision in the current workspace.
// - A published pending revision in the current workspace.
if
(
$entity
->
isNew
()
&&
$entity
->
isPublished
())
{
if
(
$entity
->
isNew
()
&&
$entity
->
isPublished
())
{
// Keep track of the publishing status in a dynamic property for
// Keep track of the initially published entities for ::entityInsert(),
// ::entityInsert(), then unpublish the default revision.
// then unpublish the default revision.
// @todo Remove this dynamic property once we have an API for associating
$this
->
initialPublished
[
$entity
->
uuid
()]
=
TRUE
;
// temporary data with an entity: https://www.drupal.org/node/2896474.
$entity
->
_initialPublished
=
TRUE
;
$entity
->
setUnpublished
();
$entity
->
setUnpublished
();
}
}
}
}
...
@@ -147,7 +150,7 @@ public function entityInsert(EntityInterface $entity): void {
...
@@ -147,7 +150,7 @@ public function entityInsert(EntityInterface $entity): void {
// does not 'leak' into the live site. This differs from edits to existing
// does not 'leak' into the live site. This differs from edits to existing
// entities where there is already a valid default revision for the live
// entities where there is already a valid default revision for the live
// workspace.
// workspace.
if
(
isset
(
$
entity
->
_
initialPublished
))
{
if
(
isset
(
$
this
->
initialPublished
[
$entity
->
uuid
()]
))
{
// Ensure that the default revision of an entity saved in a workspace is
// Ensure that the default revision of an entity saved in a workspace is
// unpublished.
// unpublished.
if
(
$entity
->
isPublished
())
{
if
(
$entity
->
isPublished
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment