I constantly get the following error when trying to mass subscribe emails.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tid' cannot be null: INSERT INTO {simplenews_subscription} (tid, snid, status, timestamp, source) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 22 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => 1361542568 [:db_insert_placeholder_4] => ) in simplenews_subscription_save() (line 1501 of sites/all/modules/simplenews/simplenews.module).

Any help appreciated!

Comments

Ronni-1’s picture

im facing the same issue. Did u find any solution to this?

andreic’s picture

I manually removed the taxonomy instead removing the correlated category in the Simplenews settings first. Here how i did it step by step:

  • Install the Simplenews module
  • Deactivate it
  • Remove remaining vocabulary from taxonomy (that's where i messed it up)
  • Activate the module again
  • Go to Simplenews settings, and find an empty category. remove the category (title required in order to delete)
  • Created a new category
  • When i then try to mass-subscribe a user now i get the known error that we have on the live site!

One patch had to be added to the simplenews realname module:

Look for the line:*
$checked_newsletters = array_filter($form_state['values']['newsletters']);

Replace it with:
$checked_newsletters = array_keys(array_filter($form_state['values']['newsletters']));

And the following steps to clear all Simplenews data and create a clean new install:

You now have to reconnect the newsletter categories with the taxonomy TID.

The easiest way to do that is to uninstall the simplenews, simplenews_realname and the simplenews_rule modules by first disabling the module and the going to the uninstall tab, that will delete the tables on the DB. To make sure there was no extra info left on the site registry run this query in phpMyAdmin or your DB management software:

SELECT * FROM `variable` WHERE `name` LIKE '%simplenews%'

If there are values returned, make sure to remove them before continuing. The most important to delete is "simplenews_vid" as that is the simplenews vocabulary ID or machine name.

Then delete all newsletter taxonomies

And delete the category field from the newsletter content type. it will be automatically added again during the new install. If this step isn't done, the categories won't work with the content type, as they point to a non existing vocabulary.

The next step is re-enable the modules simplenews first then simplenews_realname, and last simplenews_rules. This last step will create a new taxonomy vocabulary called "Newsletter", please don't delete it, but if you want you can rename it, now keep in mind that the name of this vocabulary is inserted by default on the email subject when the newsletter is sent, so that it makes sense to keep it as "Newsletter".

To add or remove categories for the newsletter DO NOT do it from the taxonomy section instead go to the Configuration > Newsletter and add them and remove them from there.

Ronni-1’s picture

I get this error when i re-enable the simplenews-realname module.

DatabaseSchemaObjectExistsException: Table <em class="placeholder">simplenews_realname</em> already exists. in DatabaseSchema->createTable() (line 657 of /includes/database/schema.inc).

redhatusr’s picture

Issue summary: View changes

I get this error without the simplenews_realname module installed
anyone has a solution?