0

Customer bought a D8 theme with Drupal Commerce installed with it. Every time I start out to build a custom module, at some point the site goes down with what I suspect is due to a misconfiguration involving the profile module which is a dependency of the Commerce Suite according to composer.lock. The latest is a simple custom form and when I hit submit I get a stacktrace. The general form is the same for every page where it seems to be attempting to build a SQL query involving the profiles table. This is the top of the stack trace for this Drupal home page.

Error: Call to a member function getType() on null in
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::propertyDefinitions() (line 73 of
 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php).
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::propertyDefinitions(Object) (Line: 118)
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema(Object) (Line: 713)
Drupal\Core\Field\BaseFieldDefinition->getSchema() (Line: 736)
Drupal\Core\Field\BaseFieldDefinition->getColumns() (Line: 388)
Drupal\Core\Entity\Sql\DefaultTableMapping->getColumnNames('uid') (Line: 310)
Drupal\Core\Entity\Sql\DefaultTableMapping->getAllColumns('profile') (Line: 428)
Drupal\Core\Entity\Query\Sql\Tables->getTableMapping('profile', 'profile') (Line: 207)
Drupal\Core\Entity\Query\Sql\Tables->addField('status', 'INNER', NULL) (Line: 52)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 162)

My efforts to uninstall the Commerce Suite crash the site attempting to uninstall one of its dependencies, like Price or Product. Of course, I attempt to click the link to remove all data from that dependency, usually returning a 500 error.

I'm sure I'm not understanding how Entity can be modified and how to fix this, but when this happens the site is hosed and no UI can be used since emptying the cache.* tables and drush pm:uninstall mycustommodule have been run. The only way I've been able to get out of this crashed state was to import an old database.

Looking at the stacktrace, is it the profile module that's causing the crash here?

  • It seems like on your site, the profile entity doesn't have an id property. I would check the version of profile that's installed and make sure it's up-to-date or there are no entity updates pending. – mradcliffe Feb 12 at 3:18
  • Thank you for suggesting entity updates, as that escaped me. The version in the code matches what drupal.org/projects/profile indicates is current. Running drush entity:update does update a lot of commerce, but not this module. Then cache rebuild, running cron, still does not alter the stacktrace returned for all pages. – sam452 Feb 12 at 16:17
  • The other alternative is that the entity type is missing in the database for that entity reference field or the target id is missing. – mradcliffe Feb 12 at 22:04
  • That is very likely correct. Since the UI crashes when attempting to uninstall these modules, I have been successful in using drush pm:uninstall after truncating the dependent tables, including the profile module. Now my stacktrace is smaller and explicitly is aware that the entity "profile" is missing. Working through the stacktrace last night, I see something that is new to me: cache_tag table. In it I see several rows with 'profile' in them and this suggests to me that these may be prompting Drupal to look for this entity. Docs don't suggest how to remove them. – sam452 Feb 13 at 15:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.