我几天前刚安装了Drupal 9.4.8。我按照指示如何从这个视频中生成临时内容进行测试,但收到了一个致命错误。我需要知道如何修复错误,以便生成一些临时内容。
再现的步骤
1安装开发模块
使用composer安装模块。根据文档,这应该适用于Drupal 9。
composer require 'drupal/devel:^5.0'
在drupal admin/modules控制面板中,安装Devel和DevelGenerate。
2转到drupal admin/config生成内容
访问admin/config并单击生成内容选项。选择您想要的内容类型——在我的案例中,自定义事件和用户组内容类型。我指定了这些设置:
- 生成50个节点
- 回溯1年
- 每个标题2个单词
所有其他设置都是默认设置。
单击生成。
这就产生了问题
在我的浏览器中,我看到的只是:
网站遇到意外错误。请稍后再试。
我查看了apache日志,看到了以下错误消息:
[2022年11月1日星期二15:11:22.216372][proxy_fcgi:error][pid 344518:tid 14001834911744][client 127.0.0.1:39852]AH01071:获取错误"PHP消息:错误:在第391#0行的/var/www/example/public/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.PHP中找不到类"Drush\Utils\StringUtils"/var/www/example/public/modules/contrib/devel/devel_generate/src/Form/DevelGenerateForm.php(95(:Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate->settingsFormValidate((\n#1[内部函数]:Drupal\devel_generate\Form\DevelGenerateForm->validateForm((\n#2/var/www/example/public/core/lib/Drupal/core/Form/FormValidator.php(82(:call_user_func_array;executeValidateHandlers((\n#4/var/www/example/public/core/lib/Drupal/core/Form/FormValidator.php(118(:Drupal\core\Form\FormValidator->doValidateForm((\n#5/var/www/example/public/core/lib/Drupal/core/Form/FormBuilder.php(588(:Drupal\core\Form\FormValidator->validateForm((\n#6/var/www/example/public/core/lib/Drupal/core/Form/FormBuilder.php(…',referer:http://example.com/admin/config/development/generate/content
我一点也不确定,但看起来Devel期望有一些我没有的先决条件。如果有人告诉我解决这个致命错误的最佳方法,我将不胜感激。
正如@BaldeBinos在评论中所建议的,我使用composer安装了drush,如下所述。这包括通过CLI进行连接,将我的工作目录切换到安装了drupal的位置,并运行composer命令:
cd /var/www/mydrupal
composer require drush/drush
这并下载和安装各种可能20个档案,最后一个是drush/drush:
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^11.3 for drush/drush
./composer.json has been updated
Running composer update drush/drush
Loading composer repositories with package information
Updating dependencies
Lock file operations: 22 installs, 0 updates, 0 removals
- Locking chi-teck/drupal-code-generator (2.6.1)
- Locking consolidation/annotated-command (4.6.0)
- Locking consolidation/config (2.1.2)
- Locking consolidation/filter-via-dot-access-data (2.0.2)
- Locking consolidation/log (2.1.1)
- Locking consolidation/output-formatters (4.2.3)
- Locking consolidation/robo (3.0.10)
- Locking consolidation/self-update (2.0.5)
- Locking consolidation/site-alias (4.0.0)
- Locking consolidation/site-process (4.2.1)
- Locking dflydev/dot-access-data (v3.0.2)
- Locking drush/drush (11.3.2)
- Locking enlightn/security-checker (v1.10.0)
- Locking grasmash/expander (2.0.3)
- Locking league/container (4.2.0)
- Locking nikic/php-parser (v4.15.1)
- Locking psy/psysh (v0.11.8)
- Locking symfony/filesystem (v5.4.13)
- Locking symfony/finder (v5.4.11)
- Locking symfony/polyfill-intl-grapheme (v1.26.0)
- Locking symfony/string (v5.4.15)
- Locking webflo/drupal-finder (1.2.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 22 installs, 0 updates, 0 removals
- Downloading consolidation/log (2.1.1)
- Downloading symfony/finder (v5.4.11)
- Downloading dflydev/dot-access-data (v3.0.2)
- Downloading consolidation/output-formatters (4.2.3)
- Downloading symfony/filesystem (v5.4.13)
- Downloading consolidation/self-update (2.0.5)
- Downloading webflo/drupal-finder (1.2.2)
- Downloading nikic/php-parser (v4.15.1)
- Downloading psy/psysh (v0.11.8)
- Downloading league/container (4.2.0)
- Downloading enlightn/security-checker (v1.10.0)
- Downloading grasmash/expander (2.0.3)
- Downloading consolidation/config (2.1.2)
- Downloading consolidation/site-alias (4.0.0)
- Downloading consolidation/site-process (4.2.1)
- Downloading consolidation/annotated-command (4.6.0)
- Downloading consolidation/robo (3.0.10)
- Downloading consolidation/filter-via-dot-access-data (2.0.2)
- Downloading symfony/polyfill-intl-grapheme (v1.26.0)
- Downloading symfony/string (v5.4.15)
- Downloading chi-teck/drupal-code-generator (2.6.1)
- Downloading drush/drush (11.3.2)
- Installing consolidation/log (2.1.1): Extracting archive
- Installing symfony/finder (v5.4.11): Extracting archive
- Installing dflydev/dot-access-data (v3.0.2): Extracting archive
- Installing consolidation/output-formatters (4.2.3): Extracting archive
- Installing symfony/filesystem (v5.4.13): Extracting archive
- Installing consolidation/self-update (2.0.5): Extracting archive
- Installing webflo/drupal-finder (1.2.2): Extracting archive
- Installing nikic/php-parser (v4.15.1): Extracting archive
- Installing psy/psysh (v0.11.8): Extracting archive
- Installing league/container (4.2.0): Extracting archive
- Installing enlightn/security-checker (v1.10.0): Extracting archive
- Installing grasmash/expander (2.0.3): Extracting archive
- Installing consolidation/config (2.1.2): Extracting archive
- Installing consolidation/site-alias (4.0.0): Extracting archive
- Installing consolidation/site-process (4.2.1): Extracting archive
- Installing consolidation/annotated-command (4.6.0): Extracting archive
- Installing consolidation/robo (3.0.10): Extracting archive
- Installing consolidation/filter-via-dot-access-data (2.0.2): Extracting archive
- Installing symfony/polyfill-intl-grapheme (v1.26.0): Extracting archive
- Installing symfony/string (v5.4.15): Extracting archive
- Installing chi-teck/drupal-code-generator (2.6.1): Extracting archive
- Installing drush/drush (11.3.2): Extracting archive
Cleaning: symfony/finder
Cleaning: symfony/filesystem
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Generating autoload files
Hardening vendor directory with .htaccess and web.config files.
53 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Cleaning installed packages.
No security vulnerability advisories found
这似乎是所需的全部内容,但请注意,drush并没有出现在我安装的模块/admin/modules中。在这一个composer命令之后,我能够重复我原来帖子中的步骤,并且成功地生成了临时/测试内容。