patch provided also pushed to issue fork at https://git.drupalcode.org/issue/field_group_table-3426539/-/commits/8.x...
b.ravanbakhsh β created an issue.
Hi @gigimaor, issue fork is created. are you happy for me to convert patch to git commit or you'd like to git push.
b.ravanbakhsh β made their first commit to this issueβs fork.
patch applied and fixed the error in our `drush cron`
thanks
b.ravanbakhsh β created an issue.
b.ravanbakhsh β created an issue.
have anyone found any js replacement?
b.ravanbakhsh β created an issue.
'moderation_state on entity type Content' the error is your probably node_field_data table has moderation_state columns. there needs to be some steps run to clean up columns or third-party dangling fields before you can uninstall workbench or install content moderation. please check comments 6, 7 at https://www.drupal.org/project/wbm2cm/issues/3042445#comment-14999909 π Field moderation_state is unknown. Needs review
what I did was not run the "clear" task. the clear command resaves the contents. I totally do not run the clear as the drupal uninstallation of workbench moderation clears out all columns and left over so no need run clear.
it is tested and works correctly. it can be merged to 2.x.
reply to #4 @karenann comment to where put these codes and the sequence. I have a hook_post_update and run the migration like this sequence.
function ua_post_update_wbm2cm_migrate() {
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['wbm2cm']);
_ua_wbm2cm_save();
// Clear work bench moderation can be skipped, as drupal uninstall workbench moderation will do the job.
// _ua_wbm2cm_clear(FALSE);
$fields = \Drupal::service('wbm2cm.migration_controller')->getOverriddenFields();
if ($fields) {
\Drupal::logger('ua')->info('It looks like you have overridden the moderation_state base field. These overrides will be reverted because they are incompatible with Content Moderation. You will also need to delete these from your exported config.');
/** @var \Drupal\Core\Field\Entity\BaseFieldOverride $field */
foreach ($fields as $field) {
$field->delete();
$message = sprintf('Reverted %s. Delete %s.yml from your exported config.', $field->id(), $field->getConfigDependencyName());
_ua_logger($message);
\Drupal::logger('ua')->info($message);
}
}
$table_names = _add_missing_moderation_state_column();
\Drupal::logger('ua')->info('Uninstalling Workbench Moderation...');
$module_installer->uninstall(['workbench_moderation']);
foreach ($table_names as $table_name) {
$schema->dropField($table_name, 'moderation_state');
}
$module_installer->install(['workflows']);
$splitFile = 'workflows.workflow.editorial';
$config_path = realpath('../config-export');
$source = new FileStorage($config_path);
$config_storage->write($splitFile, $source->read($splitFile));
\Drupal::logger('ua')->info('Installing Content Moderation...');
$module_installer->install(['content_moderation']);
_ua_wbm2cm_restore();
$module_installer->uninstall(['wbm2cm']);
}
In my case also like comment #3 Web-Beest we had some lingering configuration that added workbench_moderation as third-party settings in DB. so I create a code snippet to drop those fields and let the workbench moderation module uninstalled. also in some cases the uninstall was blocked by the field that was missing, ao this snippet adds the missing too.
$table_names = _add_missing_moderation_state_column();
foreach ($table_names as $table_name) {
$schema->dropField($table_name, 'moderation_state');
}
**
* Add moderation_state to database entity tables.
*
* Some tables in database like linky, block_field_data, .. don't have the
* moderation_state field, and it makes the uninstallation of
* workbench moderation module fails. This function adds the field to tables.
*/
function _add_missing_moderation_state_column() {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$entity_field_manager = \Drupal::service('entity_field.manager');
$entity_type_manager = \Drupal::entityTypeManager();
$schema = \Drupal::database()->schema();
$moderationStateColumnSpec = [
'type' => 'varchar',
'description' => 'workbench migration',
'length' => 255,
'not null' => FALSE,
];
$table_names = [];
foreach ($entity_type_manager->getDefinitions() as $entity_type) {
if ($entity_type->entityClassImplements(FieldableEntityInterface::CLASS)) {
foreach ($entity_field_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
if ($storage_definition->getProvider() == 'workbench_moderation') {
$table_name = $entity_type->getDataTable() ?? $entity_type->getProvider();
if ($table_name && $schema->fieldExists($table_name, 'moderation_state') === FALSE) {
$schema->addField($table_name, 'moderation_state', $moderationStateColumnSpec);
$table_names[] = $table_name;
}
}
}
}
}
return $table_names;
}
Tested and it worked for me. please merge to 2.x brnach.