When you create a custom content type and give it a field of type "text", you're asked to set a max length for this field (default 255). If you pick a length > 255 it will fail to save this field, and give an error. After this Drupal continues under the assumption that this field does in fact exist, and will give you an error on every page load.

This is the error:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/seatvandorp/includes/common.inc:2561) in drupal_send_headers() (regel 1040 van /var/www/seatvandorp/includes/bootstrap.inc).
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'seatvandorp.field_data_field_bijzonderheden' doesn't exist: SELECT field_data_field_bijzonderheden0.entity_type AS entity_type, field_data_field_bijzonderheden0.entity_id AS entity_id, field_data_field_bijzonderheden0.revision_id AS revision_id, field_data_field_bijzonderheden0.bundle AS bundle FROM {field_data_field_bijzonderheden} field_data_field_bijzonderheden0 WHERE (field_data_field_bijzonderheden0.deleted = :db_condition_placeholder_0) AND (field_data_field_bijzonderheden0.bundle = :db_condition_placeholder_1) LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => auto ) in field_sql_storage_field_storage_query() (regel 569 van /var/www/seatvandorp/modules/field/modules/field_sql_storage/field_sql_storage.module).

In my opinion Drupal should:
1) sanity check the length you input when creating a new field.
2) roll-back the actions preceding the failed save, so there is no lasting impact of a failed save.

Comments

jwlogemann’s picture

Some additional info:
I said length > 255, this is incorrect it is length > whatever is supported by your DB for text fields (e.g. 65535)
When you do the above you don't get a "field_data_field_FIELDNAME" table, but you do get an entry in the "field_config" table, which is what's causing the errors.

Proposed solution:
When creating the table fails, the "field_config" table should be rolled back to it's previous state

jwlogemann’s picture

Component: database system » field system
dcam’s picture