Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using this patch
- Upgrade core from 8.3.3 or later to 8.4.0, then apply the patch.
- Run drush updb.
- Export your sites configuration (if applicable).
- Remove the patch and dial back the content_moderation schema version using:
drush ev "drupal_set_installed_schema_version('content_moderation', 8401);"
Some of your sites code and configuration will need some updates to work with the changes made to content moderation:
- Any views with a relationship to the latest revision from the base table will need to be recreated with revision table as the base, see The 'content_revision_tracker' table from Content Moderation has been removed
- Method calls related to state/transitions on the workflow entity will need to be updated: Workflow type plugins are now responsible for state and transition schema
For sites with lots of views that need to convert from a base table to the revision table because of the change record above, manually converting the configuration can follow roughly the following steps:
- Change
base_table
key from the base to the revision table. - Change the
base_field
key from the ID column to the revision ID column. - Replace all instances of
table: OLD_BASE
withtable: NEW_BASE
(for revisionable fields). - Changes instances of
relationship: latest_revision__ENTITY_TYPE
torelationship: none
. - Once converted add an additional "latest revision" filter to the view.
- Remove the
latest_revision__ENTITY_TYPE
from the "relationships" section.
Comment | File | Size | Author |
---|---|---|---|
#42 | 2896630-13.patch | 670.83 KB | Sam152 |
#13 | 2896630-13.patch | 670.83 KB | Sam152 |
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #4
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedA first pass of this.
Comment #6
xjmI think we should at least mention this upgrade path in the release notes.
Comment #7
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #8
jibranI updated a site to 8.4.x and saw some errors. I think we should document on d.o how to fix it manually.
Comment #9
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #10
xjm@jibran, can you be more specific?
Comment #11
jibranAs seen in the upgrade path that we have to set the states and transitions names after the upgrade.
Comment #12
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThat shouldn't be necessary, not sure what is going on but I can add some more to the test case.
Comment #13
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedReroll plus adding to the test to prove we don't need to update labels.
Comment #14
jibranThanks, for the update. FWIW, I was talking about machine name.
Comment #15
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThose shouldn't have changed either?
Comment #16
jibranOk, let me clarify. After updating to rc1 states were missing the labels and I have to re-add all the transitions.
Comment #17
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI see, so you're saying without the patch, if you want to fix it manually, there should be documentation for that?
Comment #18
jibranYes.
Comment #19
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #20
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #21
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #22
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #23
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #24
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #25
rferguson CreditAttribution: rferguson commentedHey, I'm trying to use this patch to go from 8.3.7 to 8.4, and I'm having trouble applying the patch. So far I've tried placing the patch in the drupal root directory and using patch -p0 < 2896630-13.patch or -p1 with no success. It just says "can't find file to patch at input line 5". It looks like there is no .install file in 8.3.7 for content moderation to start with, not sure if that makes any difference? I've also tried using git apply but it fails silently, and there shouldn't be much different between that and the patch command?
Any help is much appreciated!
Comment #26
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHi @rferguson, this patch applies on top of 8.4.0. You should upgrade your site, as you would normally to this version, then apply the patch before running "updb".
Comment #27
rferguson CreditAttribution: rferguson commentedComment #28
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThank you for clarifying the issue summary.
Comment #29
rferguson CreditAttribution: rferguson commentedOne more thing you can maybe help with. The above worked, however for the longest time now I've been having this other issue, possibly it seems related to a previous patch I didn't apply.
On the status page I see this:
ENTITY/FIELD DEFINITIONS
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Content moderation state
The Content moderation state entity type needs to be updated.
Then running drush entity-updates I get this output:
The following updates are pending:
content_moderation_state entity type :
The Content moderation state entity type needs to be updated.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax [error]
error or access violation: 1071 Specified key was too long; max key length is 767 bytes: ALTER TABLE
{content_moderation_state_field_data} ADD UNIQUE KEY `content_moderation_state__lookup` (`content_entity_type_id`,
`content_entity_id`, `content_entity_revision_id`, `workflow`, `langcode`); Array
(
)
in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of
/vagrant/src/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Failed: Drupal\Core\Entity\EntityStorageException: !message in [error]
Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1513 of
/vagrant/src/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Cache rebuild complete. [ok]
Finished performing updates. [ok]
I'm wondering if there's something quick I can do to fix this? Is it just a matter of changing the column size in the db?
Comment #30
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHere is some context on your issue: https://www.drupal.org/node/2890189#comment-12148013
If you used this patch to come from a version 8.3.3 or earlier, and you didn't use the above upgrade path, the "content_entity_type_id" column in the "content_moderation_state_field_data" and "content_moderation_state_field_revision" table will be too long and should be adjusted to "32". I believe updating the tables manually will leave you in an invalid state however because the entity storage schema is persisted in other places, so there will still be a mismatch.
I would look at running the update steps in #2890189: Unofficial content_moderation 8.3.2 to 8.3.3 upgrade path. That patch will no longer apply, but each of the three update hooks should still be valid if you can get them to run.
Resetting your content_moderation schema version to "8401" (as in 8.4 HEAD) and then renaming them to be 8402, 8403 and 8404 respectively should do the trick.
Comment #31
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe last production site I am responsible for moved to 8.4 today with this patch. I don't have anything further to add to these, so unless anyone else runs into issues I think these can be closed.
Comment #32
Rop CreditAttribution: Rop as a volunteer commentedI Applied patch as suggested yet I keep getting these warnings:
updated to 8.4.4 after patching
Comment #33
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedDid you run updb and follow the other steps in the issue summary? You also need to confirm your schema version was at "8401" before running updb and applying the patch.
Comment #34
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedCan I ask if following the steps in #33 worked?
Comment #35
Rop CreditAttribution: Rop as a volunteer commented@Sam152
I am not sure actually. I did (try to) follow the steps and I did run updb. But it is possible that I messed up since I had trouble in my git setup with branch differences and configuration diffenrences. ...I know..
The question is how can I either revert applied updates or check/revert my schemaversion without getting really messy, since updates have been added after the patch updates.
Or maybe the question is, can I manually fix the above issues?
Sorry for bothering you with my clumbsy questions.
Comment #36
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHappy to help in any way I can! Schema version is per module, so you can dial the content_moderation one back or forward without impacting anything else. No update hooks have been created for content moderation after the patch was created, so it should be safe.
Comment #37
Rop CreditAttribution: Rop as a volunteer commentedAh..ok. Not too familiar with the update version system..
Cool I'll give it a try.
Comment #38
Stephen OllmanGetting error after applying the patch and running update.php
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /update.php/start?id=2740&op=do_nojs&op=do
StatusText: Internal Server Error
ResponseText:
Nothing is saved to the watchdog table.
Running via drush gives:
Error: Class 'NestedArray' not found in
/home/devboxco/public_html/asada/core/modules/content_moderation/content_moderation.install, line 28
Comment #39
Stephen OllmanMy bad... I missed the new code at the top.
Comment #40
Rop CreditAttribution: Rop as a volunteer commentedmhh...still having trouble with this.
All my workflow transitions are gone and I cannot recreate them.
When I run update_8402 I get:
but I guess that's because there are null transitions,
Trying to add a new transition results in:
Also trying to import the older config file fails, because the entity allready exist, yet I cannot delete it because it's being used by some of my nodes.
So I am not sure what to do.
Comment #41
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedSimilar issues were reported in #2937527: "Argument 1 passed to Drupal\workflows\Plugin\WorkflowTypeBase::getNextWeight() must be of the type array, null given" when adding a workflow transition. I provided some steps to try and resolve this:
Comment #42
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedQueueing up another test run for this, given that's twice someone has run into this issue.
Comment #43
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #44
Rop CreditAttribution: Rop as a volunteer commentedThank you sam for that reference!
I think I've managed to get everything back in order. I have my state transitions and no errors.
I did, like Stephen https://www.drupal.org/project/drupal/issues/2937527#comment-12433588
just manually edit the blob from a backup.
I compared it with the new string and found that (besides all transition) that the uuid was NULL
a:10:{s:4:"uuid";N;s:8:"langcode";s:2:"en";...
So all I did was replace the uuid in the old file with 'N' and then pasted that into the updated database. That gave me only the default transitions back, and all of the state-labels where empty.
After that I ran the 8401 update, this restored all the labels and transitions. Hooray!
The only thing that worries me is, should the workflow not have an uuid?
Comment #45
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedModifying data directly in a backup seems kind of risky but glad you got it to a workable state. As far as the UUID, I suppose you could install a fresh copy and compare it with what you have, I'm not sure what the state of that blob should be in off the top of my head.
Comment #46
Rop CreditAttribution: Rop as a volunteer commentedI agree, it is not the most elegant or safest way to fix things. And I suppose not having that id is not ok.
It is not a recommended solution,
Het is vallen en opstaan :-)
Comment #47
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedComment #48
tamarpe CreditAttribution: tamarpe commentedApplied the patch and it works well! thank you :)
Comment #49
Greg BoggsSo, I tried the patch and everything seems to have gone smoothly, but then I noticed on reports that it says the moderation entity is out of date. So, I tried drush entity-updates.
Any ideas?
```
The following updates are pending:
content_moderation_state entity type :
The Content moderation state entity type needs to be updated.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: Exception thrown while [error]
performing a schema update. SQLSTATE[HY000]: General error: 1709
Index column size too large. The maximum column size is 767 bytes.:
ALTER TABLE {content_moderation_state_field_data} ADD UNIQUE KEY
`content_moderation_state__lookup` (`content_entity_type_id`,
`content_entity_id`, `content_entity_revision_id`, `workflow`,
`langcode`); Array
(
)
in
Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException()
(line 1513 of
/mnt/www/html/shatterproofdev/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
```
Comment #50
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHi @Greg Boggs, it looks like you skipped one of the earlier patches: #2890189: Unofficial content_moderation 8.3.2 to 8.3.3 upgrade path. They will run fine out of sequence, but I suggest you simply copy the code out into some custom modules install file. Rerolling and reverting schema is going to be a pain.
Comment #51
Greg BoggsThanks Sam!
Comment #52
wturrell CreditAttribution: wturrell as a volunteer commentedFor anybody still fixing a broken site, here's a sandbox with Sam152's 8.3.2->8.3.3 patches (see #30 and #50) rolled up into a module you can just install.
https://www.drupal.org/sandbox/wturrell/3000331
git clone --branch master git@git.drupal.org:sandbox/wturrell-3000331 content_moderation_patch