Problem/Motivation

I have an issue which I have mentioned in #3052464: Cannot update to 8.7.0 because of taxonomy_post_update_make_taxonomy_term_revisionable where my temporary table doesn't exist.

This seems to be because of a mismatch based on the temporary table name - as the "temporary field mapping" in sandbox has a different value for the field as the SqlContentEntityStorage.php, so we should consider getting the field values in the same way (by using EntityFieldManager rather than EntityLastInstalledSchemaRepositoryInterface.

This fixed my error which is pasted below, this will need to be tested to make sure that the hook works as expected.

>  [error]  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.tmp_28c950taxonomy_term__48ebc0df3e' doesn't exist: INSERT INTO {tmp_28c950taxonomy_term__48ebc0df3e} (entity_id, revision_id, bundle, delta, langcode, field_hide_from_landing_page_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array
> (
>     [:db_insert_placeholder_0] => 806
>     [:db_insert_placeholder_1] => 806
>     [:db_insert_placeholder_2] => themes
>     [:db_insert_placeholder_3] => 0
>     [:db_insert_placeholder_4] => en
>     [:db_insert_placeholder_5] => 0
> )
>  in Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToDedicatedTables() (line 1415 of /docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). 
>  [error]  The entity update process failed while processing the entity type taxonomy_term, ID: 806. 

Proposed resolution

Remaining tasks

Review the patch to make sure that the hook still works as expected.

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Adam_Moulsdale created an issue. See original summary.

Adam_Moulsdale’s picture

Issue summary: View changes
Adam_Moulsdale’s picture

Issue summary: View changes
Adam_Moulsdale’s picture

Status: Active » Needs review
StatusFileSize
new1.23 KB
rakesh.gectcr’s picture

Issue summary: View changes
rakesh.gectcr’s picture

Issue tags: +8.7.0 update
nishantkumar155’s picture

Status: Needs review » Needs work
StatusFileSize
new231.99 KB

@Adam i tried #4 patch , issue still exist .

Only local images are allowed.

Adam_Moulsdale’s picture

Hi nishantkumar155,

I can't fully see the screenshot, could you upload a full version of it? Also, were you experiencing this issue before?

If you were already experiencing this, it seems slightly different from the one explained.

nishantkumar155’s picture

Hi @adam ,

As per you request i am uploading the error .

 [notice] Update started: taxonomy_post_update_make_taxonomy_term_revisionable
 [error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status' cannot be null: INSERT INTO {tmp_853997taxonomy_term_field_data} (tid, revision_id, vid, langcode, status, name, description__value, description__format, weight, changed, default_langcode, revision_translation_affected) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array
(
    [:db_insert_placeholder_0] => 1
    [:db_insert_placeholder_1] => 1
    [:db_insert_placeholder_2] => category
    [:db_insert_placeholder_3] => en
    [:db_insert_placeholder_4] => 
    [:db_insert_placeholder_5] => Pets
    [:db_insert_placeholder_6] => 
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => 0
    [:db_insert_placeholder_9] => 1536043409
    [:db_insert_placeholder_10] => 1
    [:db_insert_placeholder_11] => 1
)
Adam_Moulsdale’s picture

Status: Needs work » Needs review

Hi nishantkumar155,

Have you tried the steps in #3052464: Cannot update to 8.7.0 because of taxonomy_post_update_make_taxonomy_term_revisionable that people have done to fix this issue? As your issue looks the same as the issue mentioned on that ticket - my issue was different, so I eventually created a new ticket.

Moving back to needs review.

Adam_Moulsdale’s picture

Issue summary: View changes
fenstrat’s picture

I'm not sure this is the correct approach. It looks like somehow your FieldStorageConfig has got out of sync with the entity.last_installed_schema.repository. #3061950-9: SQLContentEntityStorage::saveToDedicatedTables() doesn't correctly use storage configuration is possible solution for getting them back in sync.

As to why they're out of sync, not sure. It's quite likely a source of a quite a few of the 8.7 upgrade issues. But if you get them back in sync taxonomy_post_update_make_taxonomy_term_revisionable() update should go through without issue.

I also hit this same error, but in my case it was due to certain field.storage.taxonomy_term.* having null or unset UUIDs (not sure how, but very likely due to some previous manual creation/syncing of these config entities). So the solution was to ensure UUIDs were consistent across the storage config and last_installed_schema.

james.williams’s picture

@fenstrat I had that same issue too - my UUIDs didn't match between the last installed schema and my actual field definitions - probably due to some misguided config management a long time ago (oops!) . Even though that was a mistake, it does seem odd to have one thing define the table for creation, and another for writing to it. That just seems like unnecessary potential for problems.

Of course the expectation is that the last_installed_schema values ought to be correct, but I don't think that needs to be relied upon when the field manager could just be used (as in the patch). I wouldn't even mind if it was the other way round, to use the last installed schema definition when creating the temporary table, instead of the current field definition? I haven't thought much about which way around it should be.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

amateescu’s picture

Status: Needs review » Closed (works as designed)

#13 is correct, this approach is not viable because the point of an update function is to be able to rely on a known definition (like the one provided by installed entity definition repository), while using the live definitions (i.e. the ones returned by the field manager by default) will make an update function return unexpected/different results, depending on the time and the state of the codebase when it is run.

However, the reports about different UUID between the live and last installed definitions is interesting and I think those should show up in the mismatched entity/field definitions list on the status report page. I've opened a separate issue to track this: #3101598: Differring field storage identifiers should be reported as a missing field storage definition update