Skip to content

[4.0][Workflow] Remove com_content defaults from workflow code#21641

Merged
wilsonge merged 25 commits intojoomla:4.0-devfrom
HLeithner:workflow-nocomcontent
Sep 8, 2018
Merged

[4.0][Workflow] Remove com_content defaults from workflow code#21641
wilsonge merged 25 commits intojoomla:4.0-devfrom
HLeithner:workflow-nocomcontent

Conversation

@HLeithner
Copy link
Copy Markdown
Member

This is a cleanup PR to remove com_content references

Summary of Changes

Remove all 'com_content' constants from workflow code.

Testing Instructions

Create, Delete, Edit

for com_content

  • articles

for com_workflow

  • stages
  • transitions
  • workflows

Expected result

All works fine

@HLeithner
Copy link
Copy Markdown
Member Author

This PR is based on #21585

@brianteeman
Copy link
Copy Markdown
Contributor

I thought it looks familiar - so can you close that one please


defined('_JEXEC') or die;

use Joomla\Component\Content\Administrator\Extension\ContentComponent;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphas sort

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in Update in #21585

/**
* @package Joomla.Administrator
* @subpackage com_workflow
*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the @Package @subpackage

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we sill have this header? because all other Fields doen't have it. Anyway would be part of the other PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're adding a new file (as the GitHub diff seems to imply here) then the header really should be correct from the beginning.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in Update in #21585

protected $type = 'Workflowcondition';

/**
* The extension where we're
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please correct to we are

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in Update in #21585

@@ -163,22 +204,125 @@ public function filterTransitions($transitions, $pk): array
*/
public function countItems(array $items, string $section)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this code be the same for every extension which want's to implement workflow? If yes, please move it either to the CategoriesServiceTrait or the WorkflowServiceTrait. Otherwise every component needs to copy the same code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function exists already in several components in joomla it is/was in the helper class (com_fields-> FieldsHelper, com_contact ->ContactHelper, com_newsfeeds -> NewsfeedsHelper) also it was in the com_content helper and has been moved here by the parent PR #21585

All countItems functions are different, countItems() is already implemented in CategoriesServiceTrait, but can't handle workflow conditions at the moment.

If its ok for you I would create a new PR to migrate all existing function to the component container and try to remove redundancy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually just look on com_content (or banners) as the others have not being migrated because of some open pull requests which would lead to conflicts. But they will use the CategoriesTrait as the countItems code is the same on all of them, except the table name. No need to copy things over and over again.

All countItems functions are different

What is the difference? I mean all workflow related extensions will have the same code, except column and row names, or not?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only skimmed the functions and the looked a bit different that's the reason why I would like to do this a separate PR for all components. I will do it after #21585 is merged.

In the end hopefully all component uses the traits function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When #20693 gets merged then I will do com_contact and com_newsfeeds. com_banners is already done and com_fields doesn't use categories at all.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

com_workflow also have countItems but this does something different then the other components.

If com_fields doesn't use why we have the function in
administrator/components/com_fields/helpers/fields.php:560

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is dead code, should be removed as we have now groups.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #21663.

…ntent

# Conflicts:
#	administrator/components/com_content/Model/FeaturedModel.php
#	libraries/src/Form/Field/WorkflowconditionField.php
#	libraries/src/Workflow/WorkflowServiceTrait.php
@HLeithner
Copy link
Copy Markdown
Member Author

So #21585 is merged now this PR much smaller maybe I we get some testers here?

The countItems function rewrite @laoneo mentioned will get it's own PR.

@ghost
Copy link
Copy Markdown

ghost commented Aug 17, 2018

I have tested this item 🔴 unsuccessfully on 76535dc

Delete an Stage got Error (see Screenshot), but Stage is trashed.

screen shot 2018-08-17 at 15 12 29


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21641.

@HLeithner
Copy link
Copy Markdown
Member Author

Delete an Stage got Error (see Screenshot), but Stage is trashed.

Not sure if this is related, does this not happen with the dev-4.0 branch?

@ghost
Copy link
Copy Markdown

ghost commented Aug 17, 2018

it happen with applied Pull Request.

@HLeithner
Copy link
Copy Markdown
Member Author

This is unrelated seams to be a problem with state->stage renaming please open a new issue.

*/
protected $extension;

protected $workflowStage;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc block for this please

@bembelimen
Copy link
Copy Markdown
Contributor

Not sure about this PR, the idea was to use com_content as fallback like in categories. If we remove this fallback (which is OK with me), we have to add checks and throw an error if extension is missing.

@HLeithner
Copy link
Copy Markdown
Member Author

There is ni reason to let com content be the fallback, this only makes it more error prone.

I found 3 places where a 3rd party component would fail to use the workflow because com_content was hardcoded or the default fallback.

In my opinion the same should be done for categories.

@wilsonge
Copy link
Copy Markdown
Contributor

I agree with this PR - we should remove com_content as the default but @bembelimen is correct we should probably hard bail if we can't find an extension.

@HLeithner
Copy link
Copy Markdown
Member Author

Sure it should have correct amd useful error messages I will adopt this PR

* @throws \InvalidArgumentException when no extension or workflow id is set
*/
public function __construct(array $config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the array typehint?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpstorm 1 me 0

'index.php?option=' . $this->option . '&view=' . $this->view_list
. $extensionURL . '&workflow_id=' . $workflow_id, false
. '&extension=' . $this->extension
. $extensionURL . '&workflow_id=' . $this->workflowId, false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just deleted $extensionURL

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$extensionURL will be removed

…ntent

# Conflicts:
#	administrator/components/com_workflow/Model/WorkflowModel.php
@wilsonge wilsonge merged commit df09dc0 into joomla:4.0-dev Sep 8, 2018
@wilsonge wilsonge added this to the Joomla 4.0 milestone Sep 8, 2018
@wilsonge
Copy link
Copy Markdown
Contributor

wilsonge commented Sep 8, 2018

LGTM!

@HLeithner
Copy link
Copy Markdown
Member Author

that was a bit too early... I create a new PR fixing 2 things

@HLeithner HLeithner deleted the workflow-nocomcontent branch September 8, 2018 13:12
brianteeman pushed a commit to brianteeman/joomla-cms that referenced this pull request Sep 8, 2018
…a#21641)

* Add component specific workflow conditions.

* Archived articles should not be visible when not filtered (=> 3.x behavior)

* CS

* Fixed missing namespace.

* CS

* Doc fixes and removed archive state from featured published filter.

* Make drone happy

* Drone...

* cs

* Postgresql update, add extension parameter to getCondictions()

* Fix condition filter

* Remove com_content references in workflow

* cs

* Use quoteName

* Fix workflow edit link

* Throw an exception if no extension is set in workflow controller.

* Fixed type hint and leftover variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants