1

I freshly installed Drupal 9.4.8 a few days ago. I was following the instructions on how to generate temporary content for testing from this video and received a fatal error. I need to know how to fix the error so I can generate some temporary content.

The steps to reproduce

1 Install devel module

Use composer to install the module. According to the docs this should work with Drupal 9.

composer require 'drupal/devel:^5.0'

In the drupal admin/modules control panel, install Devel and Devel Generate.

2 Go to drupal admin/config to generate content

visit admin/config and click Generate Content option. Select your desired content types -- in my case, custom Events and User Groups content types. I specified these settings:

  • generate 50 nodes
  • go back 1 year
  • 2 words per title

All other settings are default.

Click Generate.

THIS PRODUCES THE PROBLEM

In my browser, all I see is this:

The website encountered an unexpected error. Please try again later.

I looked in the apache log and see this error message:

[Tue Nov 01 15:11:22.216372 2022] [proxy_fcgi:error] [pid 344518:tid 140018374911744] [client 127.0.0.1:39852] AH01071: Got error 'PHP message: Error: Class 'Drush\Utils\StringUtils' not found in /var/www/example/public/modules/contrib/devel/devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php on line 391 #0 /var/www/example/public/modules/contrib/devel/devel_generate/src/Form/DevelGenerateForm.php(95): Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate->settingsFormValidate()\n#1 [internal function]: Drupal\devel_generate\Form\DevelGenerateForm->validateForm()\n#2 /var/www/example/public/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array()\n#3 /var/www/example/public/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->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

I'm not at all sure, but it looks like there is some prerequisite expected by Devel which I do not have. I'd appreciate anyone telling me the best way to fix this fatal error.

S. Imp
  • 2,833
  • 11
  • 24
  • 1
    Is "drush" (latest version is recommended) installed? Does not hurt to try. – Balde Binos Nov 02 '22 at 17:36
  • @BaldeBinos It does appear to be drush that is missing, but I'm not sure I agree that simply installing unfamiliar extensions/modules is ever a good approach. – S. Imp Nov 02 '22 at 21:29
  • @SImp Do you really consider “drush” in the category of “unfamiliar extensions/modules”? – Balde Binos Nov 03 '22 at 14:21
  • @BaldeBinos it is not a core extension, does not appear among the extensions when you install it, and I have never dealt with it before in my life. So yes, I do consider it unfamiliar. Furthermore, it has nearly a score of dependencies when you install it. This leaves a lot of surface area for problems to affect your drupal install. Any one of those dependencies might have a bug, might be deprecated, might be compromised by malware, might stop working in a new version of PHP. – S. Imp Nov 03 '22 at 23:59

1 Answers1

1

As suggested by @BaldeBinos in comments, I installed drush using composer as described here. This involved connecting via CLI, switching my working directory to where I have drupal installed, and running a composer command:

cd /var/www/mydrupal
composer require drush/drush

This and downloads and installs various perhaps 20 archives, the last of which is 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

It seems to be all that is required but NOTE that drush does not appear among my installed modules at /admin/modules. After this one composer command, I was able to repeat the steps in my original post and the temporary/test content was generated successfully.

S. Imp
  • 2,833
  • 11
  • 24