craft cms 命令行更新到版本 3.5.12.1 或更高版本失败

craft cms command line update to version 3.5.12.1 or greater fails

我运行正在执行以下命令来更新 craft cms:

php craft update craft

但是升级到版本 3.5.12.1 或更高版本失败并出现以下错误:

Performing update with Composer ... done
Applying new migrations ... error: The command "'/var/www/craft' 'migrate/all' '--no-content'" failed.

Exit Code: 1(General error)

Working directory: /var/www

Output:
================


Error Output:
================
Error: array_merge(): Expected parameter 2 to be an array, null given


Output:

我运行ning当前的craft版本是3.3.19,在docker中是运行ning,使用下面的composer.json:

. . .
 "require": {
    "aelvan/craft-cp-element-count": "^v1.0.1",
    "aelvan/imager": "v2.3.0",
    "aelvan/inlin": "^2.1",
    "aelvan/preparse-field": "v1.1.0",
    "am-impact/amcommand": "^3.1.4",
    "angellco/portal": "1.1.3",
    "angellco/spoon": "3.3.7",
    "charliedev/element-map": "^1.2",
    "charliedev/section-field": "^1.1.0",
    "craftcms/aws-s3": "1.2.5",
    "craftcms/cms": "3.3.19",
    "craftcms/feed-me": "4.1.2",
    "craftcms/redactor": "2.4.0",
    "doublesecretagency/craft-inventory": "2.0.3",
    "doublesecretagency/craft-siteswitcher": "2.1.0",
    "ether/logs": "^3.0.3",
    "ether/sidebarentrytypes": "^1.0",
    "fruitstudios/linkit": "1.1.11",
    "hashtagerrors/user-initials-photo": "1.1.1",
    "lukeyouell/craft-queue-manager": "^1.1.0",
    "marionnewlevant/snitch": "3.0.0",
    "misterbk/mix": "^1.5",
    "mmikkel/child-me": "1.0.6",
    "mmikkel/cp-field-inspect": "1.0.7",
    "mmikkel/incognito-field": "1.1.1.1",
    "monachilada/craft-matrixtoolbar": "^1.0.6",
    "nfourtythree/entriessubset": "1.2.2",
    "nystudio107/craft-cookies": "^1.1",
    "nystudio107/craft-emptycoalesce": "1.0.6",
    "nystudio107/craft-imageoptimize": "1.6.4",
    "nystudio107/craft-minify": "^1.2.9",
    "nystudio107/craft-retour": "3.1.27",
    "nystudio107/craft-scripts": "^1.2.4",
    "nystudio107/craft-seomatic": "3.2.32",
    "nystudio107/craft-typogrify": "1.1.18",
    "nystudio107/craft-webperf": "1.0.14",
    "ostark/craft-async-queue": "2.0.0",
    "page-8/craft-manytomany": "1.0.2.2",
    "putyourlightson/craft-blitz": "2.3.4",
    "rias/craft-position-fieldtype": "^1.0.13",
    "rias/craft-width-fieldtype": "^1.0",
    "spicyweb/craft-embedded-assets": "2.1.1.1",
    "spicyweb/craft-fieldlabels": "1.1.7",
    "spicyweb/craft-neo": "2.5.7",
    "superbig/craft-entry-instructions": "1.0.6",
    "topshelfcraft/environment-label": "^3.1.5",
    "verbb/cp-nav": "^2.0.9",
    "verbb/default-dashboard": "^1.0",
    "verbb/expanded-singles": "^1.0.4",
    "verbb/field-manager": "2.1.0",
    "verbb/icon-picker": "1.0.10",
    "verbb/image-resizer": "2.0.6",
    "verbb/super-table": "2.3.0",
    "vlucas/phpdotenv": "^2.4.0",
    "wbrowar/craft-communicator": "^1.0",
    "wbrowar/guide": "2.1.2",
    "yiisoft/yii2-redis": "^2.0"
  },
  "repositories": {
    "element-map": {
      "type": "path",
      "url": "./plugins/element-map"
    }
  },
  "autoload": {
    "psr-4": {
      "modules\utilitiesmodule\": "modules/utilitiesmodule/src/",
      "putyourlightson\blitz\drivers\storage\": "plugins/blitz-override"
    }
  },
  "config": {
    "optimize-autoloader": true,
    "config": {
      "process-timeout": 0
    },
    "platform": {
      "php": "7.2.5"
    },
    "sort-packages": true
  },
  "scripts": {
    "post-update-cmd": [
      "./craft migrate/all",
      "./craft clear-caches/all"
    ],
    "post-install-cmd": [
      "./craft migrate/all",
      "./craft clear-caches/all"
    ]
  }
}

我试过禁用插件,但这似乎没有什么区别。此外,我不确定“'/var/www/craft' 'migrate/all' '--no-content'”命令的来源,因为它似乎与 [=31 中的命令略有不同=].

当我尝试 运行 迁移时:

./craft migrate/all

我得到以下堆栈跟踪:

PHP Warning 'yii\base\ErrorException' with message 'array_merge(): Expected parameter 2 to be an array, null given'

in /var/www/vendor/yiisoft/yii2/web/UrlManager.php:222
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError()
#1 /var/www/vendor/yiisoft/yii2/web/UrlManager.php(222): array_merge()
#2 /var/www/vendor/yiisoft/yii2-debug/src/Module.php(290): yii\web\UrlManager->addRules()
#3 /var/www/vendor/yiisoft/yii2/base/Application.php(333): yii\debug\Module->bootstrap()
#4 /var/www/vendor/craftcms/cms/src/console/Application.php(61): yii\base\Application->bootstrap()
#5 /var/www/vendor/yiisoft/yii2/base/Application.php(279): craft\console\Application->bootstrap()
#6 /var/www/vendor/yiisoft/yii2/console/Application.php(125): yii\base\Application->init()
#7 /var/www/vendor/craftcms/cms/src/console/Application.php(47): yii\console\Application->init()
#8 /var/www/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\console\Application->init()
#9 /var/www/vendor/yiisoft/yii2/base/Application.php(212): yii\base\BaseObject->__construct()
#10 /var/www/vendor/yiisoft/yii2/console/Application.php(90): yii\base\Application->__construct()
#11 [internal function]: yii\console\Application->__construct()
#12 /var/www/vendor/yiisoft/yii2/di/Container.php(420): ReflectionClass->newInstanceArgs()
#13 /var/www/vendor/yiisoft/yii2/di/Container.php(171): yii\di\Container->build()
#14 /var/www/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#15 /var/www/vendor/craftcms/cms/bootstrap/bootstrap.php(246): yii\BaseYii::createObject()
#16 /var/www/vendor/craftcms/cms/bootstrap/console.php(51): require('/var/www/vendor...')
#17 /var/www/craft(21): require('/var/www/vendor...')
#18 {main}

这似乎是与 UrlManager 代码相关的工艺错误,但如果是这种情况,我不知道为什么其他人似乎没有遇到过它(我在我的网站上找不到任何相关信息搜索)?有人对可能出现的问题有任何建议吗?

所以我能够弄清楚问题所在。我继承了该项目,有人将 'bootstrap' => ['debug'] 添加到 config/php.app 文件,以启用 Yii 调试工具栏。此调试模块正在 UrlManager 对象上调用 addRules(),工艺代码已将此对象的规则字段设置为 null 而不是 [ ]。当调用 addRules() 时,array_merge() 对空值抛出异常(因为它期望 [ ] 而不是)。通过删除调试模块可以完全避免此代码路径。

TLDR;如果在更新到 craft 3.5.12.1 或更高版本时在 UrlManager.php 中出现 array_merge() 异常,请从 config/php.app 中移除 'debug' 模块。