Comments

yongt9412 created an issue. See original summary.

johnchque’s picture

Status: Active » Needs review
StatusFileSize
new54.95 KB

Adding patch combined with the one in #2951436: Fix integration with content moderation in multi-lingual scenarios. :) Will need to check how to ensure running the tests with the update applied.

Status: Needs review » Needs work

The last submitted patch, 2: remove_content_moderation_fields-2975366-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new959 bytes

Adding patch with the differences with the combined.

johnchque’s picture

This should work. Gonna test better.

johnchque’s picture

#novicefail :)

berdir’s picture

Status: Needs review » Needs work

Yeah, like that.

We already have a content translation test for the non-translation use case (currently hiding in paragraphs_library). This still passes, so that's good. Lets extend that by making sure that it is not possible to select paragraphs in the workflow UI.

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB
new1.79 KB
new959 bytes

Adding basic tests. :)

Status: Needs review » Needs work

The last submitted patch, 8: remove_content_moderation_fields-2975366-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new1.69 KB
new1019 bytes

Trying simplifying the tests.

Status: Needs review » Needs work

The last submitted patch, 11: remove_content_moderation_fields-2975366-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

Thanks to @Berdir could run my tests locally again, this passes locally, let's try it out. :)

The last submitted patch, 13: remove_content_moderation_fields-2975366-13-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/paragraphs.module
@@ -488,6 +488,16 @@ function paragraphs_migration_plugins_alter(array &$migrations) {
+function paragraphs_entity_type_alter(array &$entity_types) {
+  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
+  // Remove the handler class for moderation so the fields are never added to
+  // Paragraphs.
+  $entity_types['paragraph']->setHandlerClass('moderation', '');

The comment can be improved a bit, but we can do that on commit I'd say.

The field is a side effect, the main point is that we do not want to support applying content moderation directly to paragraphs but only through the host.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

Committed with an improved comment.

mpp’s picture

After reinstalling I got this notice:

Notice: Undefined index: moderation_state in /web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php on line 167

Call Stack:
    0.0003     389184   1. {main}() /vendor/drush/drush/drush:0
    0.0006     397016   2. require('/vendor/drush/drush/drush.php') /vendor/drush/drush/drush:4
    0.0126    2147456   3. Drush\Runtime\Runtime->run() /vendor/drush/drush/drush.php:66
    0.0126    2147456   4. Drush\Runtime\Runtime->doRun() /vendor/drush/drush/src/Runtime/Runtime.php:41
    0.1472    9721408   5. Drush\Application->run() /vendor/drush/drush/src/Runtime/Runtime.php:112
    0.1551    9787832   6. Drush\Application->doRun() /vendor/symfony/console/Application.php:148
    0.1554    9787784   7. Drush\Application->doRunCommand() /vendor/symfony/console/Application.php:248
    0.1637    9836488   8. Consolidation\AnnotatedCommand\AnnotatedCommand->run() /vendor/symfony/console/Application.php:964
    0.1682   10014568   9. Consolidation\AnnotatedCommand\AnnotatedCommand->execute() /vendor/symfony/console/Command/Command.php:255
    0.1685   10032608  10. Consolidation\AnnotatedCommand\CommandProcessor->process() /vendor/consolidation/annotated-command/src/AnnotatedCommand.php:404
    0.1685   10032608  11. Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter() /vendor/consolidation/annotated-command/src/CommandProcessor.php:150
    2.2195   11228064  12. Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback() /vendor/consolidation/annotated-command/src/CommandProcessor.php:181
    2.2198   11231056  13. call_user_func_array:{/vendor/consolidation/annotated-command/src/CommandProcessor.php:235}() /vendor/consolidation/annotated-command/src/CommandProcessor.php:235
    2.2198   11231464  14. Drush\Commands\core\SiteInstallCommands->install() /vendor/consolidation/annotated-command/src/CommandProcessor.php:235
    2.2246   11618248  15. drush_op() /vendor/drush/drush/src/Commands/core/SiteInstallCommands.php:144
    2.2248   11619024  16. drush_call_user_func_array() /vendor/drush/drush/includes/drush.inc:223
    2.2248   11619024  17. install_drupal() /vendor/drush/drush/includes/drush.inc:238
    3.5797   26257688  18. install_run_tasks() /web/core/includes/install.core.inc:125
   11.9690   53352000  19. install_run_task() /web/core/includes/install.core.inc:584
   12.2774   59645080  20. batch_process() /web/core/includes/install.core.inc:666
   12.2847   59752520  21. _batch_process() /web/core/includes/form.inc:882
  251.7135  120720888  22. config_install_batch_process() /web/core/includes/batch.inc:294
  251.7135  120720888  23. Drupal\Core\Config\ConfigImporter->doSyncStep() /web/profiles/contrib/config_installer/config_installer.profile:140
  251.7136  120720888  24. Drupal\Core\Config\ConfigImporter->processConfigurations() /web/core/lib/Drupal/Core/Config/ConfigImporter.php:496
  251.7238  120721264  25. Drupal\Core\Config\ConfigImporter->processConfiguration() /web/core/lib/Drupal/Core/Config/ConfigImporter.php:592
  251.7238  120721264  26. Drupal\Core\Config\ConfigImporter->importInvokeOwner() /web/core/lib/Drupal/Core/Config/ConfigImporter.php:765
  251.7252  120727408  27. Drupal\Core\Field\BaseFieldOverrideStorage->importCreate() /web/core/lib/Drupal/Core/Config/ConfigImporter.php:979
  251.7253  120731384  28. Drupal\Core\Field\Entity\BaseFieldOverride->save() /web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:364
  251.7253  120731384  29. Drupal\Core\Field\Entity\BaseFieldOverride->save() /web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:632
  251.7253  120731384  30. Drupal\Core\Field\BaseFieldOverrideStorage->save() /web/core/lib/Drupal/Core/Entity/Entity.php:390
  251.7253  120731464  31. Drupal\Core\Field\BaseFieldOverrideStorage->save() /web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:263
  251.7253  120731464  32. Drupal\Core\Field\BaseFieldOverrideStorage->doPreSave() /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:426
  251.7269  120731464  33. Drupal\Core\Field\Entity\BaseFieldOverride->preSave() /web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:471
  251.7273  120734104  34. Drupal\Core\Field\Entity\BaseFieldOverride->getBaseFieldDefinition() /web/core/

Followed by this error:

TypeError: Argument 2 passed to Drupal\Core\Entity\ContentEntityStorageBase::onFieldDefinitionUpdate() must implement interface Drupal\Core\Field\FieldDefinitionInterface, null given, called in /web/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php on line 207 in /web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php on line 424

Call Stack:
    0.0003     389184   1. {main}() /vendor/drush/drush/drush:0
    0.0006     397016   2. require('/vendor/drush/drush/drush.php') /vendor/drush/drush/drush:4
    0.0126    2147456   3. Drush\Runtime\Runtime->run() /vendor/drush/drush/drush.php:66
    0.0126    2147456   4. Drush\Runtime\Runtime->doRun() /vendor/drush/drush/src/Runtime/Runtime.php:41
    0.1472    9721408   5. Drush\Application->run() /vendor/drush/drush/src/Runtime/Runtime.php:112
    0.1551    9787832   6. Drush\Application->doRun() /vendor/symfony/console/Application.php:148
    0.1554    9787784   7. Drush\Application->doRunCommand() /vendor/symfony/console/Application.php:248

Removing these files should solve this issue: core.base_field_override.paragraph.*.moderation_state.yml

johnchque’s picture

I just tested this again with Drupal 8.6.1 and latest Paragraphs, I cannot reproduce what you described, @mpp, what core version are you using?

Is there any extra step we should consider besides just reinstalling? Was it when reinstalling Paragraphs or Paragraphs demo?

berdir’s picture

@mpp left out that he is using config_installer with existing configuration. This can also happen when updating existing sites, see #3005263: Add upgrade path for sites that have existing base field overrides for moderation_state field.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sam152’s picture

I am attempting to fix the root cause of this issue here if anyone would like to review it: #2915383: The moderation_state base field is added to all revisionable entity types even if they do not have moderation enabled.

frederickjh’s picture

I believe I have run into an issue with this code not being able to do its job to remove the fields.

I am working on updating a Drupal site that is currently on 8.7.5 and was preparing to upgrade to version 8.8 when I realized that paragraphs was pinned to version 1.2. Looking through the releases I saw that version 1.10 says "Compatibility with Drupal 8.8" so I though it would be good to upgrade to at least that version of paragraphs before upgrading Drupal core.

Attempts to upgrade to versions 1.10 and then later to 1.5, 1.3, and 1.4, resetting the develop environment before each attempt, gave the same result. The site status report contained the following error:

Paragraphs Mismatched entity and/or field definitions in Status Report

Running drush entity-updates seems that everything goes okay as no error is return but the status report error remains and running `drush entity-updates` again in finds the same fields to remove.

I am not sure if this has to do with the fact that in Drupal version 8.7 support for automatic entity updates was removed. I tried downgrading the Drupal version to just below 8.7 but there have been too many changes to the database and a number of errors are returned when trying to run drush entity-updates and it just exits.

The other curious thing that I noticed is that the error message "finds" four fields to remove but the last two do not have their names in the error message. This is more evident in the terminal as there you see the double spaces (one on either side of the empty variable) where as in the Status Report in the HTML his is reduced to one space.

paragraph entity updates drush

I could not figure out from the patch code which fields need to be removed. If anyone can give my a push in the right direction as to how to remove these fields even if that means removing them manually from the database, I would appreciate it.

In looking at the database I noticed what looks like a revisions table for each field used in paragraphs these all start with paragraph_revision__field_ followed by the machine name of the field. I have to wonder if these can also safely be removed as there are quite a few.