Problem/Motivation
If you have created moderated revisions of any content, it is not possible to uninstall moderation state.
Proposed resolution
It is OK to leave forward revisions laying around. Revisions can have their own published state set but the moderation state field values have to be removed for all content entities (nodes and custom blocks, at this point) before the module would uninstall properly.
Adding an interface to delete moderation_state field data will make workbench_moderation uninstallable.
Remaining tasks
- Add a "delete moderation state data" link to entity bundle moderation config forms. This link will go to a confirm form to delete the moderation state field data for that bundle.
- Add a drush command to delete moderation state data for an entity type + optional bundle.
- Update the README with uninstall instructions. (Requires adding a README)
User interface changes
none
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#63 | 2627012-35-with-d9.patch | 8.73 KB | joshua.boltz |
#34 | workbench_moderation-fix_uninstall-2627012-34.patch | 8.24 KB | SylvainM |
#31 | workbench_moderation-fix_uninstall-2627012-31.patch | 8.72 KB | SylvainM |
Comments
Comment #2
dawehnerIMHO its fine to keep the forward revisions, especially given that its technically an API feature of core itself.
Regarding the state field, I think its indeed the right idea to drop the data from the database and deal with that.
Comment #3
Crell CreditAttribution: Crell at Palantir.net commentedComment #4
Crell CreditAttribution: Crell at Palantir.net for Acquia commented.
Comment #5
Crell CreditAttribution: Crell at Palantir.net for Acquia commentedDropping the data from the field seems consistent with what Drupal 8 now recommends. I'm not entirely convinced on what we do with forward revisions, though. Leaving them in place means they become inaccessible except from the Revisions tab, and all you can do is "forward revert" one of them. Which... I suppose isn't so bad. So yeah, leave them. Maybe we also add a note to the README file about that, so people know what's going on if they uninstall.
Comment #6
dawehnerOh yeah, we can't even know whether the forward revisions might have been created by other modules.
Comment #7
Crell CreditAttribution: Crell at Palantir.net for Acquia commentedAnd also add a README note about it.
Comment #8
becw CreditAttribution: becw at Palantir.net for Acquia commentedComment #9
becw CreditAttribution: becw at Palantir.net for Acquia commentedBased on discussions over the past 2 days, it sounds like we should add some UI functionality to delete the contents of the moderation_state field, which will make workbench_moderation uninstallable. I've updated the issue summary to reflect this solution.
Comment #10
MartinMa CreditAttribution: MartinMa as a volunteer commentedI can't deinstall workbench too. In my "field report" there is no moderation_state field ...
I have disabled first workbench on every content type but get also this message:
"There is data for the field moderation_state on entity type Content"
I wanted to deinstall workbench because after installing workbench in taxonomy fields i can only put in one term and not as many as i wanted (and i dont know if this has to do with workbench) and i usually need more tags than one ... (use taxonomy for tagging)
Comment #11
becw CreditAttribution: becw at Palantir.net for Acquia commentedMartinMa -- this issue should be resolved by #2650388: Using Inline Entity Form widget on Moderated type causes "LogicException: The database connection is not serializable. ", which has been committed.
Comment #12
MartinMa CreditAttribution: MartinMa as a volunteer commented@#11: Thanks for the quick response. Unfortunately it doesnt work in my case ...
Comment #13
TheodorosPloumisMe too. I have the patch from #2650388: Using Inline Entity Form widget on Moderated type causes "LogicException: The database connection is not serializable. " but still no luck.
Comment #14
jibranIf this is a release blocker then it is a major bug imo.
Comment #15
anthony.bouch CreditAttribution: anthony.bouch as a volunteer commentedI've just run into the exact same problem as @MartinMa. I've disabled moderation for all content types, as well as removed all workflow states, but I cannot uninstall this module. "'The following reasons prevent the modules from being uninstalled: There is data for the field moderation_state on entity type Content"
AFAICT - this is also preventing a Drupal 8.2 upgrade.
I don't mind manually deleting whatever fields need to be cleared in the DB, via MySQL console - but can someone on this project please offer some guidance here?
Comment #16
timmillwood@blue_waters - Deleting all 'moderation_state' columns from the database might work, another option would be to delete all content.
I'm interested to know why this is blocking an upgrade to 8.2?
Comment #17
anthony.bouch CreditAttribution: anthony.bouch as a volunteer commented@timmillwood - on an initial upgrade to 8.2 the site broke, with an error about expected number of parameters for Workbench Moderation. I reverted, assuming I could uninstall workbench_moderation before attempting the upgrade again (and so I did not keep a copy of the error message after upgrade).
Deleting all content is not an option - the site is already in production (we're working on the development version, with config-export pushing changes to the live site).
Which tables contain 'moderation_state' columns? (Content types I presume).
Comment #18
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedA quick search against an SQL source file and I see moderation_state in main_cache_discovery -
but no place else..Also in:
main_block_content_field_data
main_block_content_field_revision
main_node_field_data
main_node_field_revision
Comment #19
timmillwoodmoderation state should be in all the node and block_content tables.
I think solving the 8.2 upgrade issue would be easier.
Comment #20
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedJust as a follow up: dropping moderation_state columns does NOT work.
Comment #21
SandraL CreditAttribution: SandraL commentedI have the same problem as blue_waters. First attempt to upgrade a website to 8.2 led to workbench moderation parameter errors and a very broken website. Restored everything from backup with the intent of uninstalling Workbench Moderation and trying again, but I get the "There is data for the field moderation_state on entity type Content" message and cannot uninstall.
Deleting all content is not a realistic option for me or for most users of this module, I would think. We need a functional workaround ASAP.
Comment #22
timmillwoodWhat's the upgrade error? maybe we can focus on fixing that?
Comment #23
acrosmanI haven't had any trouble that's new after updating to 8.2, but I would like to find a way to switch to core's Content Moderation to try to resolve some other issues that came up recently on a site using Workbench moderation (likely #2789003: Saving a draft unpublishes the content for pre-exsiting content or similar). Perhaps if there were a migration path to Content Moderation than uninstall would easier to resolve since elements could be migrated forward, values cleared from Workbench Moderation's fields, and then the module could potentially uninstall.
Any 8.2 related bugs seem like they should be their own issues.
Comment #24
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedI've been away for two weeks - back now and have rerun the upgrade process.
I'd also like to add that we no longer need this module, and would still very much like to remove/uninstall. Nor do we need any of the revisions for any of the content types on the site, and so given this - I would be extremely grateful for instructions/advice/suggestions from the module authors on how we can remove this module.
Here are the steps I've taken and the error that occurs when I try to upgrade the client site to Drupal 8.2.1.
1) Created a complete copy including DB dump of the problem site.
2) Created a test installation from the dump and copy, and tested the site - all okay.
3) Disabled moderation states for all content types (test that the site is still fine).
4) Perform a drush upgrade (this is a multisite)
drush -l http://svmk-dev.akhua.net/ up
Core update proceeds.
Database updates starts
Again - I'd be extremely grateful for replies, suggestions as we have a broken upgrade process and and a module that's no longer needed on a production site.
Comment #25
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedhttps://www.drupal.org/node/2796871 fixes the failed upgrade.
Would still be grateful for advice on how to remove the module.
Comment #26
deminyI also tried to uninstall the module after upgraded to Drupal core 8.2.x, and noticed it's kind of dangerous even to uninstall it manually (by deleting tables/columns manually). Really appreciate if there is a hook for uninstalling, or an instruction on how to uninstall it.
Thanks
Comment #27
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedComment #28
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedComment #29
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedI've been looking at the module install script for this module. Is it possible to EntityDefinitionUpdateManagerInterface::uninstallFieldStorageDefinition for all revisionable content types? I'm guessing not, and that the data in moderation_state will have to be removed first? There are also serialized objects in the database that contain moderation_state fields.
I'd be happy to take a stab at creating a rough uninstall script if I could receive a little guidance from the authors.
In our case, we do NOT need to keep any revisions (forward or previous) for the content types we previously created revisions for.
Again - would like to remove this module. There must be someone here that can highlight the steps required.
Comment #30
timmillwood@blue_waters - I think uninstallFieldStorageDefinition is what you need, you will need to null all the data in the columns first. This could be implemented as a drush command, or as route/controller which uninstalls the module via a confirmation form. It's not possible to do this in any hooks.
Comment #31
SylvainM CreditAttribution: SylvainM at Axess Open Web Services commentedDid this with that patch, please review.
Comment #32
timmillwoodAwesome work @SylvainM that looks pretty close.
Think it needs some tests to make sure it works. Has it been manually tested? I assumed EntityDefinitionUpdateManagerInterface::uninstallFieldStorageDefinition would need to be called rather than just setting all the values to null.
Comment #33
SylvainM CreditAttribution: SylvainM at Axess Open Web Services commentedThanks @timmillwood
It has been manually tested, yes.
EntityDefinitionUpdateManagerInterface::uninstallFieldStorageDefinition does not work:
Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: Unable to delete a field (moderation_state in node entity) with data that cannot be purged.
Comment #34
SylvainM CreditAttribution: SylvainM at Axess Open Web Services commentedHere is a new patch, without unused variables.
For the tests, I agree, but I don't know where to start...
Comment #35
timmillwood@SylvainM - I guess the values need to be set to null before calling uninstallFieldStorageDefinition. With the current patch does the column get removed from the database table?
My thinking for the patch would be to enable Workbench moderation, add a number of moderated entities, run the uninstaller, then test the column doesn't exist in the table.
Comment #36
deminyJust tried #34 and looked good. There are two steps involved:
However, removing this module could have side effects on your CMS! Some pages in your CMS might be changed!
When uninstalling the module, you may see some notifications like:
Then if you go to tab "Manage form display" of above node types after uninstalling the module, you will see that some (or all) fields might be changed to hidden on node adding/editing forms.
To see a list of changes made when uninstalling the module, you may use Drush command config-export or admin panel "Configuration Synchronization".
Comment #37
Oulalahakabu CreditAttribution: Oulalahakabu commented#34 work for me with php5.6/7 and pgsql
Comment #38
steveoliver CreditAttribution: steveoliver at Circatree commentedLooks good. Using this approach to deal with the field data problem in another module.
1 nitpick:
The docblock for PrepareUninstallForm::__construct() is labeled incorrectly.
Still needs test.
Comment #39
anthony.bouch CreditAttribution: anthony.bouch as a volunteer and commentedThanks @SylvainM @deminy #34 worked for me as well, along with @deminy's heads up regarding form display settings.
Comment #40
AnybodyPatch #34 helped me very very much. Finally I was able to uninstall the module. Please finalize it soon, thank you all so much!!
Comment #41
Anonymous (not verified) CreditAttribution: Anonymous as a volunteer commented#34 worked a treat. Thank you very much @SylvainM
Comment #42
MartinMa CreditAttribution: MartinMa as a volunteer commentedPatch #34 applied, but dont still work.
I allways get the message
Maybe some times ago i manually removed the column moderation_state
The big problem is, that I can't uninstall any module since some times because calling the uninstall page results in this error ... :-(
How to manually install the column again? I cant find a sql file in the modules folder ... (strange, how is the database updated by the module?)
Comment #43
MartinMa CreditAttribution: MartinMa as a volunteer commentedStrange enough, now I get the following error:
With grep i dont find such a statement in the code of modules ...
Comment #44
MattHalo CreditAttribution: MattHalo commentedAfter patching with #34 against latest dev snapshot, I'm getting:
Symfony\Component\DependencyInjection\Exception\LogicException: Service 'moderation_state_uninstall_validator' for consumer 'drupal.proxy_original_service.module_installer' does not implement Drupal\Core\Extension\ModuleUninstallValidatorInterface. in [error]
Can't get anywhere near any pages to do the steps mentioned in #36.
Comment #45
MartinMa CreditAttribution: MartinMa as a volunteer commented@ #42 + #43
Just found following messages in db-log:
Warning: include_once(): Failed opening '/drupal8-composer/modules/contrib/workbench_moderation/workbench_moderation.module' for inclusion (include_path='.:/usr/local/php7.0/lib/php') in include_once() (line 140 of /drupal8-composer/core/lib/Drupal/Core/Extension/Extension.php) #0 /drupal8-composer/core/includes/bootstrap.inc(566): _drupal_error_handler_real(2, 'include_once():...', '/drupa...', 140, Array) #1 /drupal8-composer/core/lib/Drupal/Core/Extension/Extension.php(140): _drupal_error_handler(2, 'include_once():...', '/drupa...', 140, Array) ....
Warning: include_once(/drupal8-composer/modules/contrib/workbench_moderation/workbench_moderation.module): failed to open stream: No such file or directory in include_once() (line 140 of /drupal8-composer/core/lib/Drupal/Core/Extension/Extension.php) #0 /drupal8-composer/core/includes/bootstrap.inc(566): _drupal_error_handler_real(2, 'include_once(/m...', '/drupa...', 140, Array)
Error: Class 'Drupal\workbench_moderation\ParamConverter\EntityRevisionConverter' not found in Drupal\Component\DependencyInjection\Container->createService() (line 266 of /drupal8-composer/core/lib/Drupal/Component/DependencyInjection/Container.php) #0 /drupal8-composer/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\Component\DependencyInjection\Container->createService(Array, 'paramconverter....') ...
Comment #46
MartinMa CreditAttribution: MartinMa as a volunteer commentedNow I can call uninstall modules. I updated to no dev-Version and applied patch again.
Uninstalling just doesnt work. Fatal error. In db-log:
Location /admin/modules/uninstall/workbench_moderation
Referrer /admin/modules/uninstall
Message InvalidArgumentException: The controller for URI "" is not callable. in Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition() (Zeile 77 in /drupal8-composer/core/lib/Drupal/Core/Controller/ControllerResolver.php).
Comment #47
captaindav CreditAttribution: captaindav commentedI just applied the patch to the latest workbench_moderation Dev release (jan 10). When I try to uninstall the module with drush, I am still getting the " There is data for the field moderation_state on entity type Content" error:
Comment #48
captaindav CreditAttribution: captaindav commentedIs there a work-around for this issue, perhaps I could install the Core Content Moderation module and leave Workbench Moderation installed? I don't want to keep any old moderation data from Workbench Moderation, I just want to move forward with the new Core Content Moderation module, so migration of legacy moderation data is not an issue.
Comment #49
timmillwoodThis is fixed in 8.5.x which will be out soon, so closing this as outdated.
See https://www.drupal.org/node/2907785
Comment #50
ARUN AK CreditAttribution: ARUN AK commentedStill a stable release is not available for 8.5.x I think we can keep this as active.
Even after applying the patch given in #34, still getting same error and not able to uninstall workbench_moderation module.
Comment #51
timmillwoodI don't think many people will be keen to work on a patch for this seeing as it's fixed in 8.5.0 which will have a stable release in just 3 weeks.
Now should be the time you're upgrading your site on you development environment to 8.5.0-beta1 which was released last week, to make sure your site is fully working with 8.5.0.
Comment #52
adamschan CreditAttribution: adamschan commentedI'm facing the same issue and can't get workbench_moderation uninstalled. I'll give #34 a try and get back.
To #48, I have both content_moderation and workbench_moderation in place. Again, it gives me the other issue:
https://www.drupal.org/project/workbench_moderation/issues/2943168
Comment #53
timmillwoodJust upgrade to 8.5.0-rc1, then you'll be able to uninstall, simple!
Comment #54
rick_p CreditAttribution: rick_p commented@timmillwood, It's not simple, if you're on core version 8.2.7 or below and have used content moderation, then an upgrade will fail until you remove all moderation states from all nodes. I have even tried changing all nodes to a (presumably default) published state to see if that would permit the uninstall but no luck there either, it still "sees" the moderation state fields in the DB or whatever.
On the uninstall page, the content moderation module says: There is content for the entity type: Content moderation state. Remove content moderation states (link to /admin/modules/uninstall/entity/content_moderation_state). But that link results in the following error.
The website encountered an unexpected error. Please try again later.
InvalidArgumentException: The controller for URI "" is not callable. in Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition() (line 77 of core/lib/Drupal/Core/Controller/ControllerResolver.php).
Drupal\Core\Controller\TitleResolver->getTitle(Object, Object) (Line: 197)
Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build(Object) (Line: 83)
Drupal\Core\Breadcrumb\BreadcrumbManager->build(Object) (Line: 72)
Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 203)
Drupal\block\BlockViewBuilder::preRender(Array)
call_user_func('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 376)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 59)
__TwigTemplate_f8a17f041581af9829850fd45db45c2b69d8b3a60b80408d416da5d23dbccb61->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/seven/templates/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_be8c7bbb9c824f2826368d7c8da984c6279779db72a67fd8056a00bb23b816f2->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 57)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
So I beg to differ that this is easy, it's anything but.
Comment #55
rick_p CreditAttribution: rick_p commented@timmillwood, I managed to install 8.5 on my local with Content Management still enabled. The site was riddled with errors related to Content Management but I was able to get to the Uninstall page. However, the message on that page about uninstalling Content management...
The following reason prevents Content Moderation from being uninstalled:
There is content for the entity type: Content moderation state. Remove content moderation states.
The link to "Remove content moderation states." still returns a generic error for me: The website encountered an unexpected error. Please try again later.
Comment #56
adamschan CreditAttribution: adamschan commentedFinally got a solution to fix the "There is data for the field moderation_state on entity type Content" (maybe block, paragraph, etc).
1. Update the lightning version by version as detailed in the UPDATE.md
2. Make sure you have run drush updb and drush entup respectively
3. Enable the content_moderation as well as WBM2CM module
4. Run drush wbm2cm-migrate (it should give you the above said error)
5. Run drush sql-cli
6. Depends on whether you have data in content or block, run a SQL command to set the moderation_state field empty. For "content", run the followings:
a) update node_field_data set moderation_state = null;
b) update node_field_revision set moderation_state = null;
7. You should now be able to uninstall workbench_moderation using UI or the following drush command:
drush pmu workbench_moderation -y
BTW, you may need to double check if the /admin/content view is working properly after this.
Hope it helps.
Comment #57
criscom#56 did it for me. Thank you!
Comment #58
diamondseaFor non-Lightning distributions and Core below 8.5 versions, I used this https://www.drupal.org/project/workbench_moderation/issues/2762777#comme... to clean up the database so I could uninstall Workbench Moderation so I could start using the core Content Moderation.
Comment #59
ramalingam07 CreditAttribution: ramalingam07 commentedHi @adamschan,
I followed the same steps mention in commit number #56.
I clear the cache but still I am facing this issue on admin/content page.
can you please help me to resolve this issue or please provide any suggestion
Comment #60
ramalingam07 CreditAttribution: ramalingam07 commentedHi @criscom,
I am not able to resolved this issue, I am using drupal core version 8.5.
Can you please tell me what steps you have followed in addition to #56.
Comment #61
sharif.elshobkshy CreditAttribution: sharif.elshobkshy as a volunteer commentedSolved by adding a hook_update that adds the missing fields/columns.
After running the update, I'm able to disable the "Workbench Moderation".
hook_update:
Note: The above tables were blocking me when trying to disable the module. It could happen that you need to add less/more tables in your code.
Hope this helps.
Regards.
Comment #62
joshua.boltz CreditAttribution: joshua.boltz at Mediacurrent commentedCan we go ahead and make this patch D9 ready by fixing the deprecations, like drupal_set_message(), which will be removed from Drupal 9
https://api.drupal.org/api/drupal/core%21includes%21database.inc/functio...
Comment #63
joshua.boltz CreditAttribution: joshua.boltz at Mediacurrent commentedRe-rolls #34 patch to include D9 deprecation fixes.
Comment #64
timfletcher CreditAttribution: timfletcher as a volunteer commented#56 saved me, but read on as my situation was a bit unique:
I'm running Drupal 8.9.14. I ran into issues importing nodes from a D7 site - the moderation state would be ignored and everything showed up as 'unpublished'.
The fix was disabling Content Moderation while importing, so I switched to Workbench Moderation. This gave me the same issue, but now I couldn't uninstall WBM:
After attempting the uninstall, most of my blocks disappeared.
After a bunch of research, here's what finally worked:
1. Install
devel
,devel_entity_updates
,wbm2cm
andcontent_moderation
2. Run
drush cr
thendrush entup
3. Run
drush wbm2cm-migrate
(this just hung for me and never completed, so I killed it and kept going)4. Run
drush sql-cli
5. Inside MySQL, run
update node_field_data set moderation_state = null;
andupdate node_field_revision set moderation_state = null;
.6. Finally, uninstall WBM with
drush pmu workbench_moderation
Thankyou!!