Symptoms
- The error message "PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null" appears in the Drupal error log (admin/reports/dblog)
- The website takes a lot longer to load the pages on which this error occurs
Investigation
You may find the broken entity by the following drush command:
drush eval 'foreach (entity_get_info() as $entity_type => $entity_info) { empty($entity_info['label']) && var_dump($entity_type, $entity_info); };'
It will print the invalid entity type.
Causes
The cause of the slowing down is simply due to the fact that the detailed error message which is written to the log is absolutely huge, and takes a long time to compute and write! See this post for an example of such a long message.
The cause of the error is when a module (almost certainly a contributed module, unless you are working on a development version of core) does not have a title value.
Solutions
- Disable and uninstall module which provides faulty entity (check: Investigation). Make sure that you've removed all the fields related to that module..
- The tricky thing is that it not clear from the error message which module is causing the problem. See the following thread for a way to find the answer: How I solved my "PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null" error.
- Try clearing your entity cache first, before clearing the cache via:
drush -y cc entity
- Try rebuilding entities via:
drush eval "entity_defaults_rebuild();"
- If you're using Conditional Fields module, check #1951538: Cannot administer Field Dependencies after re-enabling module
- Check How to remove entity type from drush?
Comments
Different solution
Had the same error. I use Aurora and finally had to rename the vendor folder to .vendor to prevent breaking Drupal/Drush. Read more here https://github.com/Snugug/generator-aurora/issues/4