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.
Problem/Motivation
I just tried updating a Drupal v8.3.7 site to v8.4.4 and when running drush updb I get this error
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL [error]
server version for the right syntax to use near 'SET content_translation_source='und'
WHERE content_translation_source IS NULL' at line 1: UPDATE {} SET content_translation_source=:db_update_placeholder_0
WHERE content_translation_source IS NULL; Array
(
[:db_update_placeholder_0] => und
)
Performing content_translation_update_8400 [ok]
It says the "content_translation_update_8400" is ok but that is not true. Every update hook after this one does not get invoked. This causes a very big problem when updating Drupal and the Drupals sites I am maintaining need to be update-to-date.
So, what is the problem here?
Steps to reproduce
Proposed resolution
So far, there are two ways to resolve this
1. Make sure that the entity type definition has a 'data_table' defined in its annotation. See #6.
2. Add a hook to your module, the details are in #8.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#3 | 2937676.patch | 912 bytes | jcisio |
Comments
Comment #2
cilefen CreditAttribution: cilefen as a volunteer commentedNo data is lost according to the issue summary so this is not critical without further analysis.
Comment #3
jcisio CreditAttribution: jcisio at Axess Open Web Services commentedThe problem is, \Drupal::entityDefinitionUpdateManager()->getDataTable() somehow returns NULL instead of the table name for the entity.
The following patch does not intend to be a fix, but it does not make the problem worse.
Comment #4
martinpe CreditAttribution: martinpe commented+1
I did a similar direct hack.
Comment #5
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedThe patch applies cleanly.
Comment #6
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI think this is actually a problem which needs to be handled elsewhere, most likely for each individual site.
content_translation_update_8400()
only loops over entity types which are managed by the content translation manager, which implies that your entity type is translatable. That, in turn, means that the entity type definition needs to provide adata_table
in its annotation, at least until #2232465: Deprecate table names from entity definitions is fixed.Comment #7
jcisio CreditAttribution: jcisio at Axess Open Web Services commentedFYI, if we use the normal way, we get correctly the data table. It's just \Drupal::entityDefinitionUpdateManager()->getDataTable() that doesn't work here. I didn't try further, as the attached patch worked for this one-shot problem.
Comment #8
facine CreditAttribution: facine as a volunteer and at Cambrico commentedHi, there is any custom entity without 'data_table', I solved this with a custom update:
@see https://www.drupal.org/project/drupal/issues/2328565
Comment #13
quietone CreditAttribution: quietone at PreviousNext commentedIs anyone still experiencing this problem?
The comment in #5 explains that a cause of this would be that an entity type definition is not providing a data_table in its annotation. And thus a solution would be to add the annotation. Also, another workaround using hooks is provided in #8.
Right now I think this could be changed to a support request and 'fixed'.
I'll check first.
Comment #14
quietone CreditAttribution: quietone at PreviousNext commentedUpdating the IS. And for now changing to a support request.
If you are experiencing this problem, add a comment.
Comment #15
quietone CreditAttribution: quietone at PreviousNext commentedAdding update tag.
Comment #16
cilefen CreditAttribution: cilefen as a volunteer commented