To reproduce this issue ...

  • have no Twitter accounts set up (I don't know if this is essential)
  • add a Post to Twitter field to a Drupal content type
  • in the default settings for the field, untick the Post to Twitter status
  • edit a node of that type
  • there is an error when saving the field

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_post_to_twitter_status' at row 1:
INSERT INTO {field_data_field_post_to_twitter}
(entity_type, entity_id, revision_id, bundle, delta, language, field_post_to_twitter_status, field_post_to_twitter_message, field_post_to_twitter_account)
VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8);
Array (
[:db_insert_placeholder_0] => node
[:db_insert_placeholder_1] => 1263
[:db_insert_placeholder_2] => 1263
[:db_insert_placeholder_3] => activity
[:db_insert_placeholder_4] => 0
[:db_insert_placeholder_5] => und
[:db_insert_placeholder_6] =>
[:db_insert_placeholder_7] => New activity: [node:title] [node:url:absolute]
[:db_insert_placeholder_8] => 0 )
in field_sql_storage_field_storage_write()
(line 514 of /var/www/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).

The function twitter_post_field_widget_form() currently sets the 'status' value to FALSE. The function field_sql_storage_field_storage_write() expects this value to be an integer, but the FALSE is converted to an empty string.

Setting the default for 'status' to zero fixes this issue.

I will attach a patch.

Comments

kenwest created an issue. See original summary.

kenwest’s picture

Title: Twitter post fails to save field with default Status value » Post to Twitter field fails to save with Status set to default
kenwest’s picture

StatusFileSize
new856 bytes

Here's the patch

kenwest’s picture

Status: Active » Needs review
oadaeh’s picture

I can confirm that I was able to reproduce this error, and it is necessary that there are no accounts set up to get the error to happen.

The patch applies cleanly and works as stated, so it can go in as is.

However, one of the function parameters that is not the last parameter has a default value set, so I created a subsequent patch to address that. I also corrected the function comment.

oadaeh’s picture

Title: Post to Twitter field fails to save with Status set to default » Post to Twitter field fails to save with Status set to FALSE
StatusFileSize
new727 bytes

Including an interdiff between the two patches.

andrtroe’s picture

Assigned: Unassigned » andrtroe

  • oadaeh authored 77d697f on 7.x-6.x
    Issue #2598044 by oadaeh, kenwest, andrey.troeglazov: Post to Twitter...
andrtroe’s picture

Assigned: andrtroe » Unassigned
Status: Needs review » Fixed

Thank you guys, commited the patch, if smn can double check it will be great.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.