Closed (fixed)
Project:
Drupal core
Version:
10.3.x-dev
Component:
workspaces.module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Dec 2019 at 20:48 UTC
Updated:
18 Mar 2024 at 10:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
smithmilner commentedThis patch gives me the ability to define skippable entity types in a custom module with a service decorator.
Example:
foo_workspaces.services.yml
FooWorkspaceManager.php
Comment #6
dspachos commentedI tested and seems to work well!
Comment #8
s_leu commentedComment #9
ranjith_kumar_k_u commentedRerolled #2 for 9.5
Comment #10
s_leu commentedI'm not sure if the proposed solution here actually makes sense. There is already an existing solution to enable/support entity types in, which are not publishable and revisionable, in workspaces by marking them as internal, see #3027598: Omit workspaces entity presave and predelete hooks for internal entities.
Given that possibility It feels relatively cumbersome to override the workspace manager just to allow some entity type to be handled inside workspaces, when compared to implementing hook_entity_type_alter() and marking an existing entity type as internal in a custom module, or even marking a custom entity type as internal right via the internal flag of the entity type annotation. IMO this feels much lighter than overriding a core service to support an entity type, so I'd personally close this as a won't fix.
Comment #11
s_leu commentedIf going for a solution like the one proposed here, I'd suggest to expose supported entity types via config or even on a settings form instead of hardcoding this inside an overridden service.
We already have something similar in place for config entity, which are supported via the wse_config submodule of the workspaces extra module. The corresponding code can be found here: https://git.drupalcode.org/project/wse/-/blob/1.0.x/modules/wse_config/w...
Comment #12
amateescu commentedMarking entity types as internal is just a temporary workaround until a proper API was created in this issue :) Also, it doesn't really work in all cases, see #3058224-3: Allow CRUD operations for Crop entities in a workspace
After getting more experience with how Workspaces is used in production sites, my proposal is to add four "workspace support states":
These support states will come in a new
workspace_informationservice, which would deprecateWorkspaceManagerInterface::isEntityTypeSupported(),::getSupportedEntityTypes()andshouldAlterOperations().Here's a patch based on the proposal above. Still needs test coverage for new service, but the code itself is ready for review.
Comment #14
amateescu commentedOops :)
Comment #16
amateescu commentedFixed that last fail.
Comment #18
amateescu commentedComment #19
smustgrave commentedWill this still need tests?
Could new functions be typehinted?
Didn't do a full code review (not as familar with workspaces)
Comment #20
amateescu commentedRolled this patch on top of #3092247: Prevent content from being deleted when there is an active workspace, for those who need it.
This definitely still needs some test coverage, I'll look into that next.
Comment #21
amateescu commentedSame patch as above, for who needs it to apply against Drupal 9.5.x.
Comment #22
raystuart commentedTo apply the 9.5.x patch in #3101671-21: Add mechanism to have workspaces skip processing entity types I also needed to apply these patches before:
* #3129762-20: Creating an unpublished entity in a workspace does not set the workspace field on the revision
* #3092247-57: Prevent content from being deleted when there is an active workspace
Comment #24
cedricl commentedFor drupal core 9.5.x i'm getting
Cannot apply patch https://www.drupal.org/project/drupal/issues/3101671#comment-14976504 (https://www.drupal.org/files/issues/2023-03-21/3101671-21-against-deletable-9.5.x.patch)!Any fixes for this issue. I also applied the patches from #22
Comment #26
amateescu commented@CedricL, see comment #22, you also have to apply two other patches before this one.
Comment #28
amateescu commentedRerolled #16 on top of latest 11.x.
Comment #29
amateescu commentedUpdated to the latest coding standards. Leaving at NW for adding test coverage.
Comment #30
amateescu commentedFixed a few deprecated usages.
Comment #31
webdrips commentedReroll #30 for 10.2.2, but would expect it to work on 11.x based on the minor change.
Comment #32
webdrips commentedHiding last patch, as it missed a directory
Comment #33
webdrips commentedTrying this again as the last patch missed a directory.
Comment #34
webdrips commentedEven with the updated patch plus #3092247-62: "[PP-1] Prevent content from being deleted when there is an active workspace", I'm not able to upload images in the non-default workspace.
I get the following error via Ajax:
Comment #35
amateescu commented@webdrips this patch only adds the possibility to "ignore" entity types in a workspace, it doesn't yet do it for the File entity type. That will probably happen in #3025785: Cannot create entity with image in a workspace.
Here's a fairly extensive update after using this patch in production for several years. The problem with the initial approach (using constants on
WorkspaceInformationInterface) was that an entity type could not declare its workspace support when the Workspaces module wasn't installed, since the interface couldn't be loaded, so we're now using explicit entity handlers for supported and ignored entity types. Entity handlers can point to a non-existent class, because the class won't be loaded until someone tries to instantiate that handler.Also added test coverage, so removing the tag. I'll convert the patch to a MR, then it should be fully ready for reviews!
Comment #39
amateescu commentedUpdated the issue summary and hid all the patches because we have an MR now.
Comment #40
smustgrave commentedMade a few suggestions but they can apply to a number of the files.
But is there BC concerns for marking previously not internal files as internal? I don't know the policy around that.
Comment #41
amateescu commented@smustgrave, thanks for reviewing! Fixed your suggestions, and after scanning the code again for similar changes that could be done to other constructors, I think I would prefer to "modernize" them all in a separate issue.. this MR is already big enough IMO.
Updated the CR as well.
FWIW, this is the #1 issue in the (somewhat short) list of blockers for marking Workspaces as stable, which I hope we can do in 10.3 :)
Comment #42
amateescu commentedComment #43
smustgrave commentedChanges look good and test updates. CR reads well
Comment #46
catchAdding a handler is a good idea, and the entity type/entity split handles block content entities nicely - flexibility but without a lot of messing about for entity types that don't need it.
Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!