Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
workflow
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
workflow
Commits
465a6059
Commit
465a6059
authored
Apr 11, 2024
by
John Voskuilen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3440229
: Creation state is not deleted when deleting a Workflow type
parent
7c5bc454
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#143968
passed with warnings
Apr 11, 2024
Stage: build
Stage: validate
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Entity/Workflow.php
+19
-15
19 additions, 15 deletions
src/Entity/Workflow.php
src/Entity/WorkflowInterface.php
+9
-1
9 additions, 1 deletion
src/Entity/WorkflowInterface.php
src/Form/WorkflowConfigTransitionRoleForm.php
+2
-3
2 additions, 3 deletions
src/Form/WorkflowConfigTransitionRoleForm.php
with
30 additions
and
19 deletions
src/Entity/Workflow.php
+
19
−
15
View file @
465a6059
...
@@ -138,7 +138,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
...
@@ -138,7 +138,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
$status
=
parent
::
save
();
$status
=
parent
::
save
();
// Make sure a Creation state exists, when saving a Workflow.
// Make sure a Creation state exists, when saving a Workflow.
if
(
$status
==
SAVED_NEW
)
{
if
(
$status
==
SAVED_NEW
)
{
$this
->
get
CreationState
();
$this
->
create
CreationState
();
}
}
return
$status
;
return
$status
;
...
@@ -153,7 +153,6 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
...
@@ -153,7 +153,6 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
// Better performance, together with Annotation static_cache = TRUE.
// Better performance, together with Annotation static_cache = TRUE.
// Load the states, and set the creation state.
// Load the states, and set the creation state.
$workflow
->
getStates
();
$workflow
->
getStates
();
$workflow
->
getCreationState
();
}
}
}
}
...
@@ -239,6 +238,21 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
...
@@ -239,6 +238,21 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
return
$this
->
id
();
return
$this
->
id
();
}
}
/**
* {@inheritdoc}
*/
public
function
createCreationState
()
{
if
(
\Drupal
::
isConfigSyncing
())
{
// Do not create the default state while configuration are importing.
}
elseif
(
!
$this
->
creation_state
)
{
$state
=
$this
->
createState
(
WORKFLOW_CREATION_STATE_NAME
);
$this
->
creation_state
=
$state
;
$this
->
creation_sid
=
$state
->
id
();
}
return
$this
->
creation_state
;
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
...
@@ -274,17 +288,8 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
...
@@ -274,17 +288,8 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
}
}
}
}
}
}
// If not found, create it.
// Then, create it.
$this
->
createCreationState
();
if
(
\Drupal
::
isConfigSyncing
())
{
// Do not create the default state while configuration are importing.
}
elseif
(
!
$this
->
creation_state
)
{
$state
=
$this
->
createState
(
WORKFLOW_CREATION_STATE_NAME
);
$this
->
creation_state
=
$state
;
$this
->
creation_sid
=
$state
->
id
();
}
return
$this
->
creation_state
;
return
$this
->
creation_state
;
}
}
...
@@ -293,8 +298,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
...
@@ -293,8 +298,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
*/
*/
public
function
getCreationSid
()
{
public
function
getCreationSid
()
{
if
(
!
$this
->
creation_sid
)
{
if
(
!
$this
->
creation_sid
)
{
$state
=
$this
->
getCreationState
();
$this
->
getCreationState
();
return
$state
->
id
();
}
}
return
$this
->
creation_sid
;
return
$this
->
creation_sid
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Entity/WorkflowInterface.php
+
9
−
1
View file @
465a6059
...
@@ -41,6 +41,14 @@ interface WorkflowInterface extends EntityInterface {
...
@@ -41,6 +41,14 @@ interface WorkflowInterface extends EntityInterface {
*/
*/
public
function
isDeletable
();
public
function
isDeletable
();
/**
* Creates the initial state for a new Workflow.
*
* @return \Drupal\workflow\Entity\WorkflowState
* The initial state.
*/
public
function
createCreationState
();
/**
/**
* Create a new state for this workflow.
* Create a new state for this workflow.
*
*
...
@@ -61,7 +69,7 @@ interface WorkflowInterface extends EntityInterface {
...
@@ -61,7 +69,7 @@ interface WorkflowInterface extends EntityInterface {
* Gets the initial state for a newly created entity.
* Gets the initial state for a newly created entity.
*
*
* @return \Drupal\workflow\Entity\WorkflowState
* @return \Drupal\workflow\Entity\WorkflowState
* The intial state.
* The in
i
tial state.
*/
*/
public
function
getCreationState
();
public
function
getCreationState
();
...
...
This diff is collapsed.
Click to expand it.
src/Form/WorkflowConfigTransitionRoleForm.php
+
2
−
3
View file @
465a6059
...
@@ -133,21 +133,20 @@ class WorkflowConfigTransitionRoleForm extends WorkflowConfigTransitionFormBase
...
@@ -133,21 +133,20 @@ class WorkflowConfigTransitionRoleForm extends WorkflowConfigTransitionFormBase
}
}
// Make sure 'author' is checked for (creation) -> [something].
// Make sure 'author' is checked for (creation) -> [something].
$creation_state
_id
=
$this
->
workflow
->
getCreationState
()
->
id
()
;
$creation_state
=
$this
->
workflow
->
getCreationState
();
$author_has_permission
=
FALSE
;
$author_has_permission
=
FALSE
;
foreach
(
$form_state
->
getValue
(
$this
->
entitiesKey
)
as
$from_sid
=>
$to_data
)
{
foreach
(
$form_state
->
getValue
(
$this
->
entitiesKey
)
as
$from_sid
=>
$to_data
)
{
foreach
(
$to_data
as
$to_sid
=>
$transition_data
)
{
foreach
(
$to_data
as
$to_sid
=>
$transition_data
)
{
if
(
empty
(
$transition_data
[
'roles'
][
WORKFLOW_ROLE_AUTHOR_RID
]))
{
if
(
empty
(
$transition_data
[
'roles'
][
WORKFLOW_ROLE_AUTHOR_RID
]))
{
continue
;
continue
;
}
}
if
(
$from_sid
==
$creation_state
_id
&&
$from_sid
!=
$to_sid
)
{
if
(
$from_sid
==
$creation_state
->
id
()
&&
$from_sid
!=
$to_sid
)
{
$author_has_permission
=
TRUE
;
$author_has_permission
=
TRUE
;
break
;
break
;
}
}
}
}
}
}
if
(
!
$author_has_permission
)
{
if
(
!
$author_has_permission
)
{
$creation_state
=
$this
->
workflow
->
getCreationState
();
$form_state
->
setErrorByName
(
'id'
,
$this
->
t
(
'Please give the author permission to go from %creation to at least one state!'
,
$form_state
->
setErrorByName
(
'id'
,
$this
->
t
(
'Please give the author permission to go from %creation to at least one state!'
,
[
'%creation'
=>
$creation_state
->
label
()]));
[
'%creation'
=>
$creation_state
->
label
()]));
}
}
...
...
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