Problem/Motivation

Attempting to apply the crm_simpsons recipe when crm is not already installed results in failure / error. Workaround is to enable crm before applying the crm_simpsons recipe, but this should not be necessary because the recipe depends on crm.

Steps to reproduce

  1. git clone git@git.drupal.org:project/crm.git simpsons
  2. cd simpsons
  3. ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=simpsons
  4. ddev add-on get ddev/ddev-drupal-contrib
  5. ddev start
  6. ddev poser
  7. ddev symlink-project
  8. ddev drush site:install -y ../recipes/crm_simpsons (or ddev drush site:install -y && ddev drush recipe ../recipes/crm_simpsons)

[ERROR] There were errors validating the config synchronization.
Unable to uninstall the CRM module because: There is content for the entity type:
Contact Method. Remove contact methods..
Unable to uninstall the CRM module because: There is content for the entity type:
Contact. Remove contacts..

[error] Error: Call to a member function label() on null in Drupal\crm\Entity\Contact->preSave() (line 129 of /var/www/html/src/Entity/Contact.php) #0 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(567): Drupal\crm\Entity\Contact->preSave()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(882): Drupal\Core\Entity\EntityStorageBase->doPreSave()
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(522): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave()
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(370): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#5 /var/www/html/crm.install(61): Drupal\Core\Entity\EntityBase->save()
#6 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(829): crm_install()
#7 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(451): Drupal\Core\Extension\ModuleInstaller->invoke()
#8 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(229): Drupal\Core\Extension\ModuleInstaller->doInstall()
#9 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install()
#10 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeRunner.php(275): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install()
#11 [internal function]: Drupal\Core\Recipe\RecipeRunner::installModule()
#12 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeCommand.php(99): call_user_func_array()
#13 /var/www/html/vendor/symfony/console/Command/Command.php(341): Drupal\Core\Recipe\RecipeCommand->execute()
#14 /var/www/html/vendor/symfony/console/Application.php(1102): Symfony\Component\Console\Command\Command->run()
#15 /var/www/html/vendor/drush/drush/src/Application.php(201): Symfony\Component\Console\Application->doRunCommand()
#16 /var/www/html/vendor/symfony/console/Application.php(356): Drush\Application->doRunCommand()
#17 /var/www/html/vendor/symfony/console/Application.php(195): Symfony\Component\Console\Application->doRun()
#18 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(113): Symfony\Component\Console\Application->run()
#19 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#20 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#21 /var/www/html/vendor/bin/drush.php(119): include('...')
#22 {main}.

Issue fork crm-3573023

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jdleonard created an issue. See original summary.

bluegeek9 made their first commit to this issue’s fork.

bluegeek9’s picture

Assigned: Unassigned » bluegeek9

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Flagging CRM as a favorite on the project page to help others discover it and show your support.
  • Review the Developer Docs for accuracy and clarity.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • bluegeek9 committed 3c88bc55 on 1.0.x
    feat: #3573023 crm_simpsons recipe fails to install when crm is not...
jdleonard’s picture

Status: Fixed » Active

Recipe install is still failing.

In FieldStorageConfigStorage.php line 167:

  Unable to determine class for field type 'comment' found in the 'field.storage.0' configuration


In DiscoveryTrait.php line 53:

  The "comment" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\FieldTypePluginManager are: address, address_country, address_zone, crm_relationship_statistics, datetime, name, primary_entity_refer
  ence, telephone, boolean, changed, created, decimal, email, entity_reference, float, integer, language, map, password, string, string_long, timestamp, uri, uuid


Failed to run drush site:install ../recipes/crm_simpsons: exit status 1
bluegeek9’s picture

Status: Active » Postponed (maintainer needs more info)
ddev drush site:install -y && ddev drush recipe ../recipes/crm_simpsons 
 You are about to:
 * DROP all tables in your 'db' database.

 // Do you want to continue?: yes.                                                                                      

 [notice] Starting Drupal installation. This takes a while.
 [notice] Performed install task: install_select_language
 [notice] Performed install task: install_select_profile
 [notice] Performed install task: install_load_profile
 [notice] Performed install task: install_verify_requirements
 [notice] Performed install task: install_verify_database_ready
 [notice] Performed install task: install_base_system
 [notice] Performed install task: install_bootstrap_full
 [notice] Performed install task: install_profile_modules
 [notice] Performed install task: install_profile_themes
 [notice] Performed install task: install_install_profile
 [notice] Performed install task: install_configure_form
 [notice] Performed install task: install_finished
 [success] Installation complete. (Admin)
 [success] User name: admin  User password: pDWY4NNLcg
9/9 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓]
Applied CRM Simpsons Sample Data recipe.

                                                                                                                        
 [OK] CRM Simpsons Sample Data applied successfully 
jdleonard’s picture

Not at my computer, but I followed the steps to reproduce with ddev drush site:install -y ../recipes/crm_simpsons

jcandan’s picture

Title: crm_simpsons recipe fails to install when crm is not already installed » Fix call to a member function label on null in Contact
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

I experience this error from a fresh install, no recipe. Generate a vanilla database dump from a fresh standard install, then enable CRM, export config, drop the database, import the fresh-standard database, import config...boom, error.

jcandan’s picture

Status: Active » Postponed (maintainer needs more info)

Having acquired the dev branch with ddev composer require drupal/crm:1.0.x-dev, this issue is resolved.

@jdleonard, I hope you don't mind that I changed the scope of this issue away from being crm_simpsons-recipe focused. Being the error was generalized to config-import, it seemed fitting.

Could this new FieldStorageConfigStorage error warrant a new issue?

bluegeek9’s picture

Status: Postponed (maintainer needs more info) » Active

bluegeek9 changed the visibility of the branch 1.0.x to hidden.

bluegeek9’s picture

I was not able to reproduce the issue on the dev branch.

ddev drush site:install standard -y
ddev drush sql:dump > init.sql
ddev drush en crm -y
ddev drush config:export -y
ddev drush sql:drop -y
ddev drush sqlc < init.sql
ddev drush config:import -y
...
[success] The configuration was imported successfully.
jdleonard’s picture

Assigned: Unassigned » jdleonard

ddev composer config minimum-stability dev causes ddev composer require drupal/crm drush/drush to install the latest release of stability dev or higher. At the time of writing this comment, that is 1.0.0-beta4.

What @jcandan is encountering has already been fixed in the 1.0.x branch, but no release has yet been made containing that fix. I verified this by:

  1. Reproducing the error following the steps @jcandan provided (noting that beta4 was installed); and
  2. Failing to reprode the error via ddev composer require drupal/crm:dev-1.0.x drush/drush, which requires the latest code from the 1.0.x branch (colloquially referred to as the "dev branch")

The change in scope to an already fixed issue has made this issue too confusing to follow. I'm going to revert the issue title and description then follow up shortly on the FieldStorageConfigStorage error, which is related to the original scope.

jdleonard’s picture

Title: Fix call to a member function label on null in Contact » crm_simpsons recipe fails to install when crm is not already installed
Assigned: Unassigned » jdleonard
Issue summary: View changes

jdleonard’s picture

Assigned: jdleonard » Unassigned
Status: Active » Needs review

Per Claude:

Here's the problem: the recipe's config: import: crm: '*' imports all config provided by the crm module, including optional config that depends on the comment module. The strict: false setting controls
whether existing config causes errors — it does not skip config with unmet module dependencies.

Running the install again, I now get the error:

In FieldConfig.php line 318:                                                                                                                         
                                                                                                                                                                                                       
    Attempted to create, modify or delete an instance of field with name comment_body on entity type comment when the field storage does not exist.

Claude:

This config depends on field.storage.comment.comment_body, which is provided by the comment module's default config. But it also depends on the text module (for the text_long field type). The comment
module itself depends on text, but the recipe may be importing this config before the comment module's own field storage is fully set up.

The fix is to also install text in the recipe so the field type is available

The fix required three changes to recipe.yml:

1. text added to install — provides the text_long field type
2. comment added to install — provides the comment field type
3. comment: '*' added to config: import — ensures field.storage.comment.comment_body is created before the crm module's config references it

I verified the fix, which is in https://git.drupalcode.org/project/crm/-/merge_requests/199

This makes it possible to apply the recipe using ddev drush site:install -y ../recipes/crm_simpsons (though it results in a pretty barren install as the recipe takes the place of the default "standard" recipe, but at least it doesn't error).

An alternative approach would be for the recipe to only apply the config it strictly needs.

jdleonard’s picture

For completeness...

This is not working against 1.0.x:

  1. git clone git@git.drupal.org:project/crm.git simpsons4
  2. cd simpsons4
  3. ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=simpsons4
  4. ddev add-on get ddev/ddev-drupal-contrib
  5. ddev start
  6. ddev poser
  7. ddev symlink-project
  8. ddev drush site:install ../recipes/crm_simpsons -y
ddev drush site:install ../recipes/crm_simpsons -y
 You are about to:
 * DROP all tables in your 'db' database.

 // Do you want to continue?: yes.

 [notice] Starting Drupal installation. This takes a while.
 [notice] Performed install task: install_select_language
 [notice] Performed install task: install_select_profile
 [notice] Performed install task: install_load_profile
 [notice] Performed install task: install_verify_requirements
 [notice] Performed install task: install_verify_database_ready
 [notice] Performed install task: install_base_system
 [notice] Performed install task: install_bootstrap_full
 [notice] Performed install task: install_recipe_required_modules

In FieldStorageConfigStorage.php line 167:

  Unable to determine class for field type 'comment' found in the 'field.storage.0' configuration


In DiscoveryTrait.php line 53:

  The "comment" plugin does not exist. Valid plugin IDs for Drupal\Core\Field\FieldTypePluginManager are: address, address_country, address_zone, crm_relationship_statistics, datetime, file, file_uri, image, nam
  e, primary_entity_reference, telephone, boolean, changed, created, decimal, email, entity_reference, float, integer, language, map, password, string, string_long, timestamp, uri, uuid


Failed to run drush site:install ../recipes/crm_simpsons -y: exit status 1

The MR referenced in my previous comment addresses this.

bluegeek9’s picture

Status: Needs review » Needs work

The issue looks to be a problem with recipes. You need to install crm before using the recipe.

# First, install a basic site
ddev drush si standard -y

# Then, apply the recipe
ddev drush recipe ../recipes/crm_simpsons

We are not add comments are a dependency.

jdleonard’s picture

I don't think there is evidence here of a problem with recipes in general. Recipes should be able to be installed via drush site:install without erroring.

Comments would only be a dependency of the sample data recipe, right? Not sure I see any problem with that.

The (theoretical) approach of only importing optional config that the recipe actually needs would resolve this issue without making the recipe dependent on comments. I have no objection to that approach.

  • bluegeek9 committed 4b212906 on 1.0.x
    feat: #3573023 crm_simpsons recipe fails to install when crm is not...
bluegeek9’s picture

Status: Needs work » Fixed

I added the configs individually instead of a wildcard, and the erros does not occur.

Because the site is not installed first, there are no themes, or other items from the standard profile. Not a bug, but something to be aware of.

ddev drush site:install ../recipes/crm_simpsons -y

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.