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

  1. 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.
  2. Add a drush command to delete moderation state data for an entity type + optional bundle.
  3. Update the README with uninstall instructions. (Requires adding a README)

User interface changes

none

API changes

none

Data model changes

none

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jaesin created an issue. See original summary.

dawehner’s picture

IMHO 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.

Crell’s picture

Title: It's not possible to uninstall moderation state after a revision has been created. » It's not possible to uninstall workbench moderation after a revision has been created.
Project: Moderation State » Workbench Moderation
Version: » 8.x-1.x-dev
Crell’s picture

Issue tags: +Release blocker

.

Crell’s picture

Title: It's not possible to uninstall workbench moderation after a revision has been created. » It's not possible to uninstall workbench moderation after a revision has been created
Priority: Normal » Major

Dropping 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.

dawehner’s picture

Oh yeah, we can't even know whether the forward revisions might have been created by other modules.

Crell’s picture

Title: It's not possible to uninstall workbench moderation after a revision has been created » Delete moderation_state fields when uninstalling workbench_moderation
Assigned: Unassigned » becw

And also add a README note about it.

becw’s picture

becw’s picture

Issue summary: View changes

Based 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.

MartinMa’s picture

I 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)

becw’s picture

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)

MartinMa -- 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.

MartinMa’s picture

@#11: Thanks for the quick response. Unfortunately it doesnt work in my case ...

TheodorosPloumis’s picture

jibran’s picture

Issue tags: +Needs tests

If this is a release blocker then it is a major bug imo.

anthony.bouch’s picture

I'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?

timmillwood’s picture

@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?

anthony.bouch’s picture

@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).

anthony.bouch’s picture

A 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

timmillwood’s picture

moderation state should be in all the node and block_content tables.

I think solving the 8.2 upgrade issue would be easier.

anthony.bouch’s picture

Just as a follow up: dropping moderation_state columns does NOT work.

SandraL’s picture

I 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.

timmillwood’s picture

What's the upgrade error? maybe we can focus on fixing that?

acrosman’s picture

I 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.

anthony.bouch’s picture

I'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

...
Performing views_update_8200               [ok]
Performing path_update_8200                 [ok]
Performing system_update_8201              [ok]
Performing block_content_update_8003   [ok]
Performing comment_update_8200    	[ok]

Recoverable fatal error: Argument 2 passed to Drupal\workbench_moderation\ParamConverter\EntityRevisionConverter::__construct() must implement interface Drupal\workbench_moderation\ModerationInformationInterface, none given, called in public/core/lib/Drupal/Component/DependencyInjection/Container.php on line 268 and defined in /modules/contrib/workbench_moderation/src/ParamConverter/EntityRevisionConverter.php on line 33 #0 public/core/includes/bootstrap.inc(548): _drupal_error_handler_real(4096, 'Argument 2 pass...', '/Users/x/Cli...', 33, Array)

Argument 2 passed to Drupal\workbench_moderation\ParamConverter\EntityRevisionConverter::__construct() must       [error]
implement interface Drupal\workbench_moderation\ModerationInformationInterface, none given, called in
public/core/lib/Drupal/Component/DependencyInjection/Container.php
on line 268 and defined EntityRevisionConverter.php:33

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.

anthony.bouch’s picture

https://www.drupal.org/node/2796871 fixes the failed upgrade.

Would still be grateful for advice on how to remove the module.

deminy’s picture

I 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

anthony.bouch’s picture

Category: Task » Bug report
anthony.bouch’s picture

Priority: Major » Critical
anthony.bouch’s picture

I'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.

timmillwood’s picture

@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.

SylvainM’s picture

timmillwood’s picture

Status: Needs review » Needs work

Awesome 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.

SylvainM’s picture

Thanks @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.

SylvainM’s picture

Here is a new patch, without unused variables.

For the tests, I agree, but I don't know where to start...

timmillwood’s picture

@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.

deminy’s picture

Just tried #34 and looked good. There are two steps involved:

  1. Remove field values (moderation_state on entity type Content).
  2. Remove the module.

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:

The listed configuration will be updated.

Content type

SomeNodeType
// ......

Entity form display

node.some_node_type.default
// ......

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".

Oulalahakabu’s picture

#34 work for me with php5.6/7 and pgsql

steveoliver’s picture

Looks 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.

anthony.bouch’s picture

Thanks @SylvainM @deminy #34 worked for me as well, along with @deminy's heads up regarding form display settings.

Anybody’s picture

Patch #34 helped me very very much. Finally I was able to uninstall the module. Please finalize it soon, thank you all so much!!

Anonymous’s picture

#34 worked a treat. Thank you very much @SylvainM

MartinMa’s picture

Patch #34 applied, but dont still work.

I allways get the message

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'moderation_state' in 'where clause': SELECT 1 AS expression FROM {profile} t WHERE moderation_state IS NOT NULL LIMIT 1 OFFSET 0; Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->countFieldData() (Zeile 1714 in /drupal8-composer/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

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?)

MartinMa’s picture

Strange enough, now I get the following error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'is_default' in 'where clause': SELECT 1 AS expression FROM {profile} t WHERE is_default IS NOT NULL LIMIT 1 OFFSET 0; Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->countFieldData() (Zeile 1714 in /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

With grep i dont find such a statement in the code of modules ...

MattHalo’s picture

After 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.

MartinMa’s picture

@ #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....') ...

MartinMa’s picture

Now 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).

captaindav’s picture

I 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:

>drush pmu workbench_moderation
The following extensions will be uninstalled: workbench_moderation
Do you really want to continue? (y/n): y
exception 'Drupal\Core\Extension\ModuleUninstallValidatorException' with message 'The following reasons prevent the modules from being uninstalled: There is data for the field   [error]
moderation_state on entity type Content, <a href="/admin/modules/uninstall/workbench_moderation">Remove field values</a>: moderation_state on entity type Content.' in
/var/www/agency/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php:365
Stack trace:
#0 /var/www/agency/docroot/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(91): Drupal\Core\Extension\ModuleInstaller->uninstall(Array, true)
#1 /var/www/agency/vendor/drush/drush/commands/core/drupal/environment.inc(227): Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall(Array)
#2 /var/www/agency/vendor/drush/drush/commands/core/drupal/pm_8.inc(79): drush_module_uninstall(Array)
#3 /var/www/agency/vendor/drush/drush/commands/pm/pm.drush.inc(1250): _drush_pm_uninstall(Array)
#4 [internal function]: drush_pm_uninstall('workbench_moder...')
#5 /var/www/agency/vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_pm_uninst...', Array)
#6 /var/www/agency/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command('workbench_moder...')
#8 /var/www/agency/vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#9 /var/www/agency/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#10 /var/www/agency/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /var/www/agency/vendor/drush/drush/drush.php(12): drush_main()
captaindav’s picture

Is 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.

timmillwood’s picture

Status: Needs work » Closed (outdated)

This is fixed in 8.5.x which will be out soon, so closing this as outdated.

See https://www.drupal.org/node/2907785

ARUN AK’s picture

Status: Closed (outdated) » Active

Still 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.

timmillwood’s picture

Assigned: becw » Unassigned
Status: Active » Closed (outdated)

I 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.

adamschan’s picture

I'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

timmillwood’s picture

Just upgrade to 8.5.0-rc1, then you'll be able to uninstall, simple!

rick_p’s picture

@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.

rick_p’s picture

@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.

adamschan’s picture

Finally 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.

criscom’s picture

#56 did it for me. Thank you!

diamondsea’s picture

For 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.

ramalingam07’s picture

Hi @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

ramalingam07’s picture

Hi @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.

sharif.elshobkshy’s picture

Solved 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:

use Drupal\Core\Database\Database;
/**
 * Add missing fields that allows Workbench Moderation to be uninstalled.
 */
function myModule_update_8023() {
  $schema = Database::getConnection()->schema();
  $definition = [
    'type' => 'varchar',
    'length' => 45,
  ];
  $tables = [
    'taxonomy_term_field_data',
    'block_content_field_data',
    'crop_field_data',
    'media_field_data',
    'node_field_data',
    'paragraphs_item_field_data',
  ];
  foreach ($tables as $table) {
    if (!$schema->fieldExists($table, 'moderation_state')) {
      $schema->addField($table, 'moderation_state', $definition);
    }
  }
}

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.

joshua.boltz’s picture

Can 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...

joshua.boltz’s picture

FileSize
8.73 KB

Re-rolls #34 patch to include D9 deprecation fixes.

timfletcher’s picture

#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:

$ drush pmu workbench_moderation

   In SqlContentEntityStorageSchema.php line 773:

  The field moderation_state has already been deleted and it is in the process of being purged.

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 and content_moderation
2. Run drush cr then drush 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; and update node_field_revision set moderation_state = null;.
6. Finally, uninstall WBM with drush pmu workbench_moderation

Thankyou!!