CraftCMSのアップグレードが失敗する

Aug 21 2020

コントロールパネルから3.3.15-> 3.5.5にアップグレードしようとしています。

Docker経由で実行しているので、composer.lockファイルを更新して正しい依存関係を設定するだけで、次にイメージを再構築するときにすべてが正常になりますが、何か奇妙なことが起こっています。

アップグレードを選択した後、数分間実行された後、内部サーバーエラーが発生します。以下をログに記録します。

craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Class 'Yii' not found in /app/vendor/yiisoft/yii2/validators/IpValidator.php:218"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "Stack trace:"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#0 /app/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\validators\IpValidator->init()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#1 /app/vendor/yiisoft/yii2/web/Request.php(345): yii\base\BaseObject->__construct()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#2 /app/vendor/yiisoft/yii2/web/Request.php(1877): yii\web\Request->getIpValidator()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#3 /app/vendor/yiisoft/yii2/web/Request.php(1859): yii\web\Request->getSecureForwardedHeaderTrustedParts()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#4 /app/vendor/yiisoft/yii2/web/Request.php(1084): yii\web\Request->getSecureForwardedHeaderTrustedPart('proto')"
craft_1        | 2020/08/21 07:38:50 [error] 139#139: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Class 'Yii' not found in /app/vendor/yiisoft/yii2/validators/IpValidator.php:218

これは少し奇妙ですが、このようにアップグレードすると依存関係が消えるのはなぜですか?このアップグレードの試行後、インストールは壊れた状態のままになり、すべての要求に対して500エラー(および同じエラー、Yiiが見つかりません)が発生します。composer.json + composer.lockファイルを元に戻し、依存関係を再インストールすると、機能が復元されます。

3.4にアップグレードしようとしたときに同じ問題が発生しましたが、他の優先順位があったため、その時点でアップグレードを延期しました。

このイメージに問題なく、ストアからプラグインを追加、削除、アップグレードできます。私はcomposer.jsonとcomposer.lockを書き込み可能であり、ベンダーフォルダー、ストレージ、および移行もあります。

編集:3.3.16での変更がこれを引き起こしているようです。yiiが2.0.30にアップグレードされています。これを行う:

bash-4.4# composer require craftcms/cms:3.3.16
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - craftcms/cms 3.3.16 requires yiisoft/yii2 ~2.0.30.0 -> satisfiable by yiisoft/yii2[2.0.30].
    - Installation request for craftcms/cms 3.3.16 -> satisfiable by craftcms/cms[3.3.16].
    - Installation request for yiisoft/yii2 (locked at 2.0.21) -> satisfiable by yiisoft/yii2[2.0.21].


Installation failed, reverting ./composer.json to its original content.

yii2がそのバージョンにロックされていると文句を言う理由がわかりません。composer.lockには、そのバージョンを明示的に示しているものはなく、すべて〜バージョンを使用しています。

しかし、ロックファイルとベンダーフォルダーを削除してcomposerインストールを実行しても、Yii2の2.0.30は正常にインストールされているようですが、それでもそのメッセージが表示され、composerに非常に不満を感じ始めています...

編集2:これは私の作曲者ファイルです:

{
  "repositories": [
    {
      "type": "artifact",
      "url": "composer-artifacts/"
    }
  ],
  "require": {
    "aws/aws-sdk-php": "^3.112",
    "carlcs/craft-redactorcustomstyles": "3.0.2",
    "codemix/yii2-streamlog": "^1.2",
    "craftcms/aws-s3": "^1.2",
    "craftcms/cms": "^3.3.15",
    "craftcms/redactor": "2.3.3.2",
    "dolphiq/redirect": "1.0.24",
    "mmikkel/retcon": "2.0.12",
    "thejoshsmith/craft-title-to-sidebar": "1.0.1",
    "verbb/super-table": "2.3.3",
    "vlucas/phpdotenv": "^3.4.0"
  },
  "autoload": {
    "psr-4": {
      "rex\\craft\\modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    },
    "github-oauth": {
      "github.com": "xxxxxx"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

編集3:まったく新しい3.5.5セットアップで同じセットアップを使用し、一時的な中断なしで3.5.6にアップグレードしました。3.3.15とアップグレード、またはおそらくいくつかのプラグインにいくつかの問題があるようです(composer.jsonからそれらを削除しようとしましたが、それでも失敗します)。

編集4:./craft update allコンテナ内で実行しようとしましたが、出力には次のように表示されます。

bash-5.0# ./craft update all
Fetching available updates ... done
Performing 6 updates:

    - craft 3.3.15 => 3.5.9
    - aws-s3 1.2.5 => 1.2.11
    - redactor 2.3.3.2 => 2.4.0
    - redactor-custom-styles 3.0.2 => 3.0.4
    - redirect 1.0.24 => 1.1.1
    - retcon 2.0.12 => 2.2.1

Backup the database? (yes|no) [yes]:no
Skipping database backup.
Performing update with Composer ... error: An error occurred

Output:

<warning>Package "craftcms/vue-asset" listed for update is not installed. Ignoring.</warning>
<warning>Package "danielstjules/stringy" listed for update is not installed. Ignoring.</warning>
<warning>Package "yiisoft/yii2-shell" listed for update is not installed. Ignoring.</warning>
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for carlcs/craft-redactorcustomstyles 3.0.4 -> satisfiable by carlcs/craft-redactorcustomstyles[3.0.4].
    - carlcs/craft-redactorcustomstyles 3.0.4 requires craftcms/redactor ^2.7.0 -> satisfiable by craftcms/redactor[2.7.4, 2.7.3, 2.7.2, 2.7.1, 2.7.0] but these conflict with your requirements or minimum-stability.

<warning>Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.</warning>


Revert the Composer changes? (yes|no) [yes]:

編集5:

原因を見つけましたが、これが一部のバージョンでは機能するのに他のバージョンでは機能しない理由がよくわかりません。

general.phpではyii\web\Request、「ローカル」ホスト名を把握するために使用しています

use yii\web\Request;
$request = new Request; ... '@baseUrlPrefix' => getenv('BASE_URL_PREFIX') ?: $request->getHostInfo(),

エイリアスを設定するとき。(Yiiの?わからない)特定のバージョンでは、それは何らかの理由で失敗します。

回答

2 nstCactus Sep 15 2020 at 01:32

Craftはまだ完全に初期化されていないためyii\web\Requestgeneral.phpで新しいインスタンスを作成することはできません。以前のバージョンでは機能していましたが、Craftチームが読み込み順序を変更したようです。

サイトのベースURLを定義する別の方法を見つける必要があります。

MattJenkins Sep 09 2020 at 23:36

composer.lockファイルとベンダーディレクトリを削除してから、composerの新規インストールを実行してみましたか?