Added 'do_generated_content' module with provision script for non-production content generation.#154
Conversation
…duction content generation.
📝 WalkthroughWalkthroughAdds a new Drupal module Changes
Sequence Diagram(s)sequenceDiagram
participant Script as Provision Script
participant Drush as Drush
participant Drupal as Drupal App
participant DB as Database
Script->>Drush: check environment via php-eval
Script->>Script: evaluate VORTEX_PROVISION_OVERRIDE_DB / GENERATED_CONTENT_SKIP
alt enable flow
Script->>Drush: drush en do_generated_content
Drush->>Drupal: enable module
Drupal->>DB: record schema/module enabled
Drupal->>GeneratedPlugins: invoke generation (when run)
GeneratedPlugins->>Drupal: create Files, Media, Nodes, Terms
Drupal->>DB: persist entities
else skip/production
Script->>Script: log skip
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
This comment has been minimized.
This comment has been minimized.
|
Code coverage (GitHub Actions) |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/modules/custom/do_generated_content/do_generated_content.info.yml`:
- Around line 6-7: The module metadata is missing the do_base dependency which
can break install/enable order; update the dependencies block in
do_generated_content.info.yml (the dependencies: list for the
do_generated_content module that currently contains
generated_content:generated_content) to include do_base (e.g., add
do_base:do_base or the appropriate do_base machine name entry) so that the
do_generated_content module declares and enforces the required base module at
install time.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3a03f1bb-bb16-441b-9e2a-1182843cb42f
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
composer.jsonscripts/custom/provision-20-generated-content.shweb/modules/custom/do_generated_content/do_generated_content.info.ymlweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/MediaCivicthemeImage.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/NodeCivicthemePage.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php
| dependencies: | ||
| - generated_content:generated_content |
There was a problem hiding this comment.
Add missing do_base dependency declaration.
The module metadata currently omits do_base, even though this feature set assumes base content model availability. Without explicit dependency, enable/install order can break and generators can fail at runtime.
🔧 Proposed fix
dependencies:
- generated_content:generated_content
+ - do_base:do_base📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| dependencies: | |
| - generated_content:generated_content | |
| dependencies: | |
| - generated_content:generated_content | |
| - do_base:do_base |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@web/modules/custom/do_generated_content/do_generated_content.info.yml` around
lines 6 - 7, The module metadata is missing the do_base dependency which can
break install/enable order; update the dependencies block in
do_generated_content.info.yml (the dependencies: list for the
do_generated_content module that currently contains
generated_content:generated_content) to include do_base (e.g., add
do_base:do_base or the appropriate do_base machine name entry) so that the
do_generated_content module declares and enforces the required base module at
install time.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php`:
- Around line 41-47: Ensure you null-check and validate the result of
helper::createFile before using it: after calling $file =
$this->helper::createFile($type, [...]) verify that $file is an instance of
FileInterface (mirroring the MediaCivicthemeImage pattern) and only then push to
$entities and call $this->helper::log('Created file: %s', $file->getFilename());
otherwise skip logging/adding or handle the error path accordingly so no null
pointer occurs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 827c13dd-c41d-46d0-94b8-b0d03e88a357
📒 Files selected for processing (4)
web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/MediaCivicthemeImage.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/NodeCivicthemePage.phpweb/modules/custom/do_generated_content/src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php
| $file = $this->helper::createFile($type, [ | ||
| 'width' => $width, | ||
| 'height' => $height, | ||
| ]); | ||
|
|
||
| $entities[] = $file; | ||
| $this->helper::log('Created file: %s', $file->getFilename()); |
There was a problem hiding this comment.
Add null check before using $file.
If helper::createFile() fails or returns null, calling $file->getFilename() on line 47 will cause a null pointer exception. The MediaCivicthemeImage plugin demonstrates the defensive pattern by checking if (!$file instanceof FileInterface).
🛡️ Proposed fix to add validation
$file = $this->helper::createFile($type, [
'width' => $width,
'height' => $height,
]);
+ if ($file === NULL) {
+ continue;
+ }
+
$entities[] = $file;
$this->helper::log('Created file: %s', $file->getFilename());📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $file = $this->helper::createFile($type, [ | |
| 'width' => $width, | |
| 'height' => $height, | |
| ]); | |
| $entities[] = $file; | |
| $this->helper::log('Created file: %s', $file->getFilename()); | |
| $file = $this->helper::createFile($type, [ | |
| 'width' => $width, | |
| 'height' => $height, | |
| ]); | |
| if ($file === NULL) { | |
| continue; | |
| } | |
| $entities[] = $file; | |
| $this->helper::log('Created file: %s', $file->getFilename()); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php`
around lines 41 - 47, Ensure you null-check and validate the result of
helper::createFile before using it: after calling $file =
$this->helper::createFile($type, [...]) verify that $file is an instance of
FileInterface (mirroring the MediaCivicthemeImage pattern) and only then push to
$entities and call $this->helper::log('Created file: %s', $file->getFilename());
otherwise skip logging/adding or handle the error path accordingly so no null
pointer occurs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #154 +/- ##
========================================
Coverage 87.73% 87.73%
========================================
Files 11 11
Lines 163 163
========================================
Hits 143 143
Misses 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Added the
do_generated_contentcustom Drupal module to provide programmatic content generation for non-production environments (local, dev, CI). The module uses thedrupal/generated_contentpackage (added as a Composer dependency) and defines plugins that generate files, image media, taxonomy terms, and CivicTheme page nodes with realistic paragraph components. A provision script is included to enable the module automatically during environment provisioning when a fresh database override is detected.Changes
New custom module:
web/modules/custom/do_generated_content/do_generated_content.info.yml— Module definition declaring dependency ongenerated_contentanddo_base.src/Plugin/GeneratedContent/FileFile.php— Generates 20 random JPG/PNG image files at varying dimensions.src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php— Creates 10 predefined topic taxonomy terms (Drupal, DevOps, CI/CD, etc.) with weight 11.src/Plugin/GeneratedContent/MediaCivicthemeImage.php— Creates 10civictheme_imagemedia entities using randomly selected generated files, with weight 1.src/Plugin/GeneratedContent/NodeCivicthemePage.php— Creates 10civictheme_pagenodes (weight 30) with paragraph components (content, accordion, promo, callout) and random topic/thumbnail assignments.New provision script:
scripts/custom/provision-20-generated-content.shChecks the current environment (dev/ci/local) and, when a fresh DB override is active and
GENERATED_CONTENT_SKIPis not set, enables thedo_generated_contentmodule withGENERATED_CONTENT_CREATE=1to trigger content generation.Composer dependency
composer.json/composer.lock— Addeddrupal/generated_content: ^2(version 2.0.0).Summary by CodeRabbit
New Features
Chores