Drupal8.7リビジョンアップで複数の困難があった

hagi に投稿

Drupal8.7からTaxonomy TermとMenuにリビジョン管理が追加された。

機能自身は望ましい事だし、当然対応しなければいけないのだが、リビジョンアップのスクリプトが複数個所で失敗した。そのため、8.7をブロックして8.6.16で運用を続けていたのだが、その間に8.7.4までリリースが進んだので、もう本腰をいれて取り組むことにした。これはそのトラブルシュートの記録である。

まず、リビジョンアップをする。

composer require drupal/core:8.7.x webflo/drupal-core-require-dev:8.7.x egulias/email-validator:2.x

composer update --with-dependencies

最初のcomposerコマンドでロックが解除されるので、その後updateをかけた。もっと良い方法があるのかも知れないが、まあそれで動くので大丈夫だと思う。

次は、データベースのアップデートをかける。

vendor/drush/drush/drush updb

更新を開始すると

>  [notice] Update started: menu_link_content_post_update_make_menu_link_content_revisionable
>  [error]  Exception thrown while performing a schema update. tmp_08e168menu_link_content_revision の名前を menu_link_content_revisionに変更することは出来ません。テーブル menu_link_content_revisionはすでに存在しています。 
>  [error]  Update failed: menu_link_content_post_update_make_menu_link_content_revisionable 
 [error]  Update aborted by: menu_link_content_post_update_make_menu_link_content_revisionable 
 [error]  Finished performing updates. 

で落ちる。恥ずかしながら、以前のアップデートの失敗のタイミングでゴミが残ってしまっていたのかも知れない。

mysqlでゴミをチェックする。

MariaDB [test]> show tables like '%menu%revision%';
+--------------------------------------------+
| Tables_in_test (%menu%revision%)         |
+--------------------------------------------+
| menu_link_content_field_revision           |
| menu_link_content_revision                 |
| tmp_08e168menu_link_content_field_revision |
| tmp_08e168menu_link_content_revision       |
| tmp_48904fmenu_link_content_field_revision |
| tmp_48904fmenu_link_content_revision       |
| tmp_4ed6a0menu_link_content_field_revision |
| tmp_4ed6a0menu_link_content_revision       |
| tmp_63a647menu_link_content_field_revision |
| tmp_84b617menu_link_content_field_revision |
| tmp_84b617menu_link_content_revision       |
| tmp_a7a8f8menu_link_content_field_revision |
| tmp_a7a8f8menu_link_content_revision       |
+--------------------------------------------+
13 rows in set (0.00 sec)

これらのtableを全てdropした上で、updbを再実行する。

すると、menuは通るが、taxonomyの所で失敗する。


>  [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_9e4b0ataxonomy_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] => bible
>     [:db_insert_placeholder_3] => ja
>     [: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] => 1
> )
>  in Drupal\Core\Database\Connection->handleQueryException() (line 689 of /home/hagi/drupal/kinuta/web/core/lib/Drupal/Core/Database/Connection.php). 
>  [error]  The entity update process failed while processing the entity type taxonomy_term, ID: 1. 
>  [error]  Update failed: taxonomy_post_update_make_taxonomy_term_revisionable 
 [error]  Update aborted by: taxonomy_post_update_make_taxonomy_term_revisionable 
 [error]  Finished performing updates. 

一番最初に8.7.1の更新に失敗した時から引っかった部分で、
https://www.drupal.org/project/drupal/issues/3052464
で類似のトラブルが報告されている。私の場合は、
>  [error]  The entity update process failed while processing the entity type taxonomy_term, ID: 1.
と出ているので、tid=1のあたりが怪しいわけだ。関連するtableを念のために検索した。

MariaDB [temp]> select * from taxonomy_term_data where tid=1;
+-----+-------+--------------------------------------+----------+
| tid | vid   | uuid                                 | langcode |
+-----+-------+--------------------------------------+----------+
|   1 | bible | 3adfc4b0-e8f1-468e-ba9c-733576c5f116 | ja       |
+-----+-------+--------------------------------------+----------+
1 row in set (0.00 sec)

MariaDB [temp]> select * from taxonomy_term_field_data where tid=1;
Empty set (0.01 sec)

最初のtermを消した記憶がある。どうやら何故か、term_fieldの方は消えたがtermが消えなかったという事だろう。
delete from taxonomy_term_data where tid=1;
でterm_dataを消した。その上で、updbを再実行する。

これで、無事成功。念のため再実行して問題ない事を確認し、キャッシュをクリア。

Termの表示を含めて動作を確認して、無事アップデートを終了した。

 

 

タグ