When using features to add the field_base and field_instances for domain access on files a SQL exception is thrown.
This occurs when cache clearing before feature reverting.
The error that is given when calling the feature revert after cache clear, using drush:
WD php: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1:[error]
SELECT fci.field_name AS field_name, fci.data AS data FROM {field_config_instance} fci WHERE (fci.entity_type = :entity_type) AND (fci.field_name IN ()); Array
(
[:entity_type] => file
)
in domain_entity_entity_field_instance() (line 359 of /modules/contrib/domain_entity/domain_entity.module).
Drush command terminated abnormally due to an unrecoverable error. [error]
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1: SELECT fci.field_name AS field_name, fci.data AS data FROM {field_config_instance} fci WHERE (fci.entity_type = :entity_type) AND (fci.field_name IN ()); Array
(
[:entity_type] => file
)
in domain_entity_entity_field_instance() (regel 359 van /modules/contrib/domain_entity/domain_entity.module).
This issue seems related to #1878042: Error when creating an entity .
However if I interpret the answers in that issue correctly, the fix there was "just use the web interface". Which I'm sure works fine, however that does not work well when using Continuous Deployment, as such a step can't be easily automated. So I'm opening this new issue to hopefully finally resolve this bug.
Comments
Comment #2
paulvandenburg commentedThis patch fixes the problem.
The problem seems to be that for field instances not in the static cache, it performs a database lookup.
However for these yet to be created field instances, it produces a malformed SQL query due to a variable not being filled as expected.
I've ensured that the SQL query always gets properly formed by providing a default value for the possibly empty variable. This should only make the WHERE clause stricter as to not getting more results than intended.
Comment #3
bskibinskiDid a functional test, the error doesn't occur anymore.
I can't say anything about the code itself, but it fixes the problem.
Comment #4
joshahubbers commentedReviewed this issue and it is ready to be committed.
Comment #5
joshahubbers commentedComment #6
bohartD7 reached its EOL back in January 2025, and there is no active release for D7 for this module.
Neither development nor support is planned for D7.
All D7-related issues (especially those with ~10 years of inactivity) are marked as outdated in a bunch.
If/once the issue still arises in D11+ versions, please create a follow-up issue.
Still, everyone can apply the patch above (not tested by the maintainers) to their projects.
Thanks!