[4.0] Workflow prevent trashing of used stages/workflows#21579
[4.0] Workflow prevent trashing of used stages/workflows#21579wilsonge merged 33 commits intojoomla:4.0-devfrom
Conversation
plugins/content/joomla/joomla.php
Outdated
| private function _canDeleteStage($pk) | ||
| { | ||
| // Check if this function is enabled. | ||
| if (!$this->params->def('check_states_workflow', 1)) |
There was a problem hiding this comment.
Why do we need this parameter? Why not just use the com_content enabled parameter (and when it's disabled it should always stop you from deleting a stage)
There was a problem hiding this comment.
The category check uses their own parameter, too. So it was a "copy&extend".
There was a problem hiding this comment.
Then we need to fix that too :P Like the parameters here need to respect their extensions helper values - not have their own
There was a problem hiding this comment.
So to be clear: it should not be possible to disable this function (beside deactivating the plugin)?
There was a problem hiding this comment.
Correct. If workflows is enabled in the relevant component, then this is enabled
| use Joomla\Component\Content\Administrator\Table\ArticleTable; | ||
| use Joomla\CMS\Workflow\Workflow; | ||
| use Joomla\Utilities\ArrayHelper; | ||
| use Joomla\Component\Workflow\Administrator\Table\StageTable; |
There was a problem hiding this comment.
Please sort in alpha order. See this PR #21577.
plugins/content/joomla/joomla.php
Outdated
| } | ||
|
|
||
| return $result; | ||
|
|
plugins/content/joomla/joomla.xml
Outdated
| class="switcher" | ||
| label="PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_LABEL" | ||
| description="PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_DESC" | ||
| label="PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_WORKFLOW_LABEL" |
There was a problem hiding this comment.
Per Joomla Coding Standards:
The four attributes
name,type,labelanddescriptionshould be written in this order and at the top of the element definition.
| COM_WORKFLOW_MSG_DELETE_DEFAULT="You are trying to delete the default item." | ||
| COM_WORKFLOW_MSG_FROM_TO_STAGE="From Stage and To Stage must have different names." | ||
| COM_WORKFLOW_MSG_DELETE_IS_ASSIGNED="This item is in use by the component." | ||
| COM_WORKFLOW_MSG_DELETE_IS_DEFAULT="You can't delete the default item" |
There was a problem hiding this comment.
please add a . at the end
|
unable to test due to 500 error |
| PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_LABEL="Check Category Deletion" | ||
| PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_DESC="Check that states are not assigned to an item before they are deleted." | ||
| PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_LABEL="Check States Deletion" | ||
| PLG_CONTENT_JOOMLA_FIELD_CHECK_STATES_WORKFLOW_DESC="Check that stages/workflows are not assigned to an item before they are deleted." |
|
Looks like a merge bug? That string shouldn't exist in this branch (because this hasn't been synced since last night and JM only introduced that string with ea4064a today). Either way I just merged 4.0-dev into this PR again so that should be fixed? |
|
I don't get this String either. |
|
I have tested this item 🔴 unsuccessfully on ff70dc6
expected result: actual result: This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21579. |
|
I have tested this item ✅ successfully on ff70dc6
-> Error message appeared: "This item is in use by the component." This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21579. |
…prevent-trashing # Conflicts: # plugins/content/joomla/joomla.php
…mla-cms into workflow-prevent-trashing
Refactor the code
|
Thanks @f-hamel for this find, could you test again. |
|
|
||
| defined('JPATH_PLATFORM') or die; | ||
|
|
||
| use Joomla\CMS\Factory; |
|
I'll do another review tomorrow. It's changed a lot since I first reviewed this |
|
I have tested this item ✅ successfully on 10d8bc0 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21579. |
|
@lavipr can you please retest? |
|
I have tested this item ✅ successfully on 10d8bc0
|
|
Ready to Commit after two successful tests. @bembelimen please resolve conflicting Files, thanks. |
…prevent-trashing # Conflicts: # administrator/language/en-GB/en-GB.com_workflow.ini
|
I resolved the conflict, but let's wait for @wilsonge review |
…prevent-trashing # Conflicts: # plugins/content/joomla/joomla.php
|
Thanks :) |

Pull Request for Issue # .
Summary of Changes
This PR prevents the trashing of workflows/stages when articles are assigned to them
Testing Instructions
Create different stages/workflows and articles assigned to them. Then try to trash the articles
Expected result
Error messages when an article is in the workflow/stage