During install of a profile that bundles Entityforms, we're running into this error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'entityform_type' doesn't exist: SELECT e.* FROM {entityform_type} e; Array ( ) in entityform_entity_info().

This looks like another case of the well-known, though dreaded, #1311820: Don't do a registry_update() before installing a module.

Core has so far not fixed this critical issue; so far, modules have had to work around the issue by adding checks around their implementations of hook_entity_info().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GuyPaddock’s picture

GuyPaddock’s picture

Status: Active » Closed (won't fix)

The patch on comment #13 in #1311820: Don't do a registry_update() before installing a module seems to fix the issue in core. Yay!

GuyPaddock’s picture

Assigned: Unassigned » GuyPaddock
Status: Closed (won't fix) » Active

So... the other patch has some really bad side effects. I'll prepare a patch for this.

GuyPaddock’s picture

Status: Active » Needs review
FileSize
1011 bytes

Attached is a patch for the issue.

Status: Needs review » Needs work

Status: Needs work » Needs review
GuyPaddock’s picture

Patch did not fail testing. Automated testing is not set-up properly for Entityform.

Status: Needs review » Needs work
GuyPaddock’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev
FileSize
1009 bytes

Okay, the last failure was legit. Attached is a re-roll for the 2.x branch.

GuyPaddock’s picture

Status: Needs work » Needs review

Set to NR.

bmcmurray’s picture

Status: Needs review » Needs work

The patch from #9 does not appear to resolve the issue when Entityforms is included as a dependency of a module that is installed during initial install of an install profile.

It dies with the original error (From drush si output):

[error]  WD entityform: Failed to retrieve entityform types: exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'entercom_dev.entityform_type' doesn't exist'
michee.lengronne’s picture

What about a simple check if the table exists ?

michee.lengronne’s picture

FileSize
1.46 KB

Sorry, that's a better one.

joelpittet’s picture

Status: Needs work » Needs review
joelpittet’s picture

Assigned: GuyPaddock » Unassigned
Priority: Critical » Normal
Status: Needs review » Needs work

Why is the table missing in the first place? The patches all just mask the problem.

michee.lengronne’s picture

I think it is due to the order of functions in the drupal bootstrap. Drupal relies on the cache to make entity_info wait until table is created.

It breaks when the cache is volatile and clears in the middle of the bootstrap.

GuyPaddock’s picture

@joelpittet: Per #1311820: Don't do a registry_update() before installing a module, Drupal core rebuilds the registry before it's installed all of the schema. Any module that implements hook_registry_files_alter() can end up in this state where the table is missing.

@michee.lengronne: The reason why my original patch did not do a table check is because it adds an extra table check query every time the registry is rebuilt, as opposed to the perf hit of a rare exception. In a given site, it is unlikely for the table to be missing more than once ever because the error condition will go away once the schema is fully installed. Therefore, it's an exceptional case rather than a normal runtime case to be handled. Hence, it's better to handle this as an exception and not incur the perf hit during cache clears.

GuyPaddock’s picture

@bmcmurray: Can you post the stack trace for your error? It would seem to me to be the case that the other module (i.e. the module that depends on Entityform) is also implementing hook_entity_info() and runs into the same issue, but it's hard to tell without the trace.

Until this issue actually gets fixed in core, every module that could attempt to query the not-yet-installed entity table has to add code like I included in my patch.