OSSミドルな戯れ
JUGEMテーマ:インターネット
# Drupal 9.5 から 10.1 への移行
## 前準備
### 動作確認
11月5日、JPUGサイトのバックアップを取得し、手元のサーバにインストールしてアップデートの試行をおこなった。
ubuntu 22.04 の上で、PHP8.1 での動作確認をした。
* PHP8.1 で JPUGサイトのコピー(Drupal 9.5.x)が動作することを確認。
* PHP8.1でDrupal 10.1が動作することを確認。
## Drupal10 をインストール
いつものスクリプトで、そのまま移行し、トップページにアクセスしてみたらエラーが起きた。
```
TypeError: Drupal¥Core¥Render¥Renderer::doTrustedCallback(): Argument #1 ($callback) must be of type callable, array given, called in /home/juk/Drupal/html+/core/lib/Drupal/Core/Render/Renderer.php on line 797 in Drupal¥Core¥Render¥Renderer->doTrustedCallback() (line 57 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php).
```
"Renderer.php on line 797" のエラーを検索すると、エラー箇所をtry〜catch にして回避する、次の投稿が見つかった。
cf. https://www.drupal.org/forum/support/upgrading-drupal/2023-05-30/migration-from-959-to-101
さらに、アップデートスクリプト(http://localhost/update.php)を試みると、使っているテーマ(Burtikをカスタムしたjpugと管理用のSeven)が Drupal10 でサポートとされなくなっていることが判明。さらに、幾つかの拡張モジュールも互換性がなくなっていた。
メッセージ:
```
Status Details
Errors found
Incompatible theme
The following theme is installed, but it is incompatible with Drupal 10.1.6:
JPUG
Review the suggestions for resolving this incompatibility to repair your installation, and then re-run update.php.
Removed core modules
You must add the following contributed modules and reload this page.
CKEditor
Quick Edit
RDF
These modules are installed on your site but are no longer provided by Core.
For more information read the documentation on deprecated modules.
Removed core theme
You must add the following contributed theme and reload this page.
Seven
This theme is installed on your site but is no longer provided by Core.
For more information read the documentation on deprecated themes.
```
## Drupal9からDrupal10への移行準備(追加)
一旦、もとの Drupal9 の状態に戻した。
### 1. Drupal10対応テーマを追加
Drupal10の標準テーマで、Drupal9 でも使えるテーマ、 Olivero と Claro をインストールして、「Olivero」を [デフォルトに設定] した。
(http://localhost/admin/appearance)
* Olivero
* Claro
さらに、jpug(Burtikのカスタム) と Seven はアンインストールした。
- jpug
- Seven
その他の使っていないテーマもアンインストールした。
- Bartik 9.5.11 (Deprecated)
- Stark 9.5.11
そして、管理用テーマに 「Claro」を選択して [構成を保存] した。
### 2. 拡張モジュールをアンインストール
管理者権限でログインし、拡張機能のアンインストール頁(http://localhost/admin/modules/uninstall)にて、"(Deprecated)" とされているモジュールをすべてチェックし、「アンインストール」を実行した。
- CKEditor
- Quick Edit
- RDF
### 3. 一時的にDevelモジュールをインストールし、キャッシュをクリア(※再々試行時)
Develモジュールの最新版(Devel-5.1.2) をインストールした。
拡張機能のリスト頁(http://localhost/admin/modules)にて、「Devel]にチェックして [インストール] を実行する。
トップメニューの [Devel] ボタンを押し、表示されたサブメニューの [Clear Cache] を押す。
拡張機能のアンインストール頁(http://localhost/admin/modules/uninstall)にて、"Devel" モジュールをチェックし、「アンインストール」を実行した。
コマンドラインでデータベースにアクセスし、キャッシュテーブルをすべてクリアした。
```
$ psql drupal8
TRUNCATE cache_bootstrap;
TRUNCATE cache_config;
TRUNCATE cache_container;
TRUNCATE cache_data;
TRUNCATE cache_default;
TRUNCATE cache_discovery;
TRUNCATE cache_dynamic_page_cache;
TRUNCATE cache_entity;
TRUNCATE cache_markdown;
TRUNCATE cache_menu;
TRUNCATE cache_render;
TRUNCATE cache_toolbar;
```
## Drupal10を再インストール
### 1. Drupal10 を再インストール
### 2.エラー箇所をtry〜catch にして回避。
(※再々試行時はエラーは出なかったので、そのまま。)
前出の "Renderer.php on line 797" のエラーの対策についての記述に従い、ソースコードを改修した。
```php
try {
return $this->doTrustedCallback($callback, $args, $message, TrustedCallbackInterface::THROW_EXCEPTION, RenderCallbackInterface::class);
}
catch (¥Throwable $e) {
//devel_dump($callback);
//ddebug_backtrace(FALSE,0,0);
}
```
※ devel_dump() と ddebug_backtrace() は Devel 拡張モジュールのファンクションなので、最初はコメントアウト。
リロードすると、"Renderer.php on line 797" のエラーは出ないが、次のエラーとなった。テーマの画面レイアウトは効いていなかった。
```
Warning: Trying to access array offset on value of type null in Drupal¥Core¥Render¥Element¥HtmlTag::preRenderHtmlTag() (line 97 of core/lib/Drupal/Core/Render/Element/HtmlTag.php).
```
### 3. 開発用モジュールをインストール
"Renderer.php on line 797" のエラー対処についての記事にあった Devel モジュールをインストールした。
(https://ftp.drupal.org/files/projects/devel-5.0.2.tar.gz)
拡張機能のリスト頁(http://localhost/admin/modules)にて、「Devel]にチェックして [インストール] を実行した。
インストールはできたが、次のエラーが出るようになった。
(※再々試行時はエラーは出なかった。)
```
Warning: Trying to access array offset on value of type null in Drupal¥Core¥Render¥Element¥HtmlTag::preRenderHtmlTag() (line 86 of core/lib/Drupal/Core/Render/Element/HtmlTag.php).
```
### 4. キャッシュのクリア
トップメニューに追加された [Devel] を押し、現れた開発用メニューの「cache clear」を押した。
すると、テーマの画面レイアウトが適用され、メニュー表示も日本語が適用された。
### 5. データベースの更新
「サイトの状態」のエラー(http://localhost/admin/reports/status#error) から、「データベース更新」の 「データベースのアップデートスクリプト」を実行した。
なにもしないで、「ページが見つかりません」 (http://localhost/update.php/selection) が表示された。
(※再々試行時も同様。)
http://localhost/update.php からデータベースの更新を行った場合も上記と同様になった。
## Drupal10を再々インストール
12月5日にJPUGサイトのバックアップを取り直し、アップデートの再々試行を行った。結果は、再試行時とほぼ同様で、最後のデータベースの更新ができなかった。
drupal サイトの管理用プログラム drush をインストールし、データベースの更新を試みたところうまくいった。
```
$ cd ~/Drupal/jpug/
$ composer require --dev drush/drush
$ ./vendor/bin/drush --version
$ export PATH="$PATH:$HOME/Drupal/jpug/vendor/bin"
$ which drush
$ drush --version
$ sudo chmod -R go+rwX $HOME/Drupal/jpug101/sites/default/files/
$ drush updatedb
```
VPSのサーバの様子がおかしくなり、やたら遅い。
`apt-get update` が1時間経っても終わらない状態。VPNがなんとか使えていたので、オーバーロードというわけではなさそう。
発生したのが前日の夜、明けても状態が変わらずで、シャットダウンもできなくなっていたので、コンソールで停止してから起動しなおした。しかし、結果は変わらず。`apt-get update`をして、急に遅くなったところでpsコマンドを実行し、プロセスを見ると、bgzip がいつまでも終わらないような感じでおそらくディスクI/Oの問題とみた。
とりあえずサポートに連絡、日中は使えないまま、夜になってやっと回復した。
それでも、http死活監視のメールが止まない。調べてみると、今度はWebサーバの問題。ログを見ると次の通りuser_access() 関数が無いと言われる。CMSを更新してから数ヶ月稼働していて、もとのソースアーカイブと比較しても変更はないことを確認した。
PHP Fatal error: Call to undefined function user_access() in /home/infogres/drupal-7.59/includes/menu.inc on line 644
# yum install drupal6によって、drupal6の最新がインストールできてすごく簡単である。あとは、必要なパッケージをインストールするのだが、それらに関しては以下のポインタを参照して欲しい。
# tar xvfz ja-6.x-1.4.tar.gz言語ファイルのアップロードは
# find . -name"*.po" | xarts cat >> /tmp/ja-all.po
host all all 127.0.0.1/32 md5(postgresのユーザ作成時にMD5パスワードの設定をしていない場合には、)管理ユーザでpostgresに接続して、次のようにパスワード(ここではhimitsu)を設定する。
hostssl all all 127.0.0.1/32 md5
postgres$ psqlパスワードの設定をしたら、手動で接続できることを確認する。
postgres=# alter user drupal with password 'himitsu';
postgres$ psql -h localhost -U drupal drupal6
ユーザ drupal のパスワード: himitsu