After create a new newsletter content, I get this error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tid' cannot be null: INSERT INTO {simplenews_newsletter} (nid, vid, tid, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 30 [:db_insert_placeholder_1] => 29 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => 0 ) in simplenews_newsletter_save() (line 2406 of /www/htdocs/v100333/cms/sites/all/modules/simplenews/simplenews.module).

I'm using a fresh installation with ctools, devel, simplenews & views.

Comments

simon georges’s picture

Did you choose a newsletter term during content creation ?

picsofle’s picture

Thats another problem. I have created 2 terms for newsletter, but I can't select anyone. No terms are displayed.

simon georges’s picture

Did you add the Newsletter field to your content type ?

picsofle’s picture

Newsletter field is added to content type. Vocabulary and terms are created.

miro_dietiker’s picture

Did you assign the vocabulary with the newsletter configuration to be used as newsletter definition?

simon georges’s picture

Status: Active » Postponed (maintainer needs more info)
berdir’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing old bug reports with no feedback. If you still experience this, please test with the most recent dev snapshot first.

shaneonabike’s picture

For the record I had the same issue but by resaving the Field and setting a default it seems have resolved the issue. I think for my case it might have been caused when this was migrated from D6, and something was out of synch.

ggeczy’s picture

Thank you so much ShaneOnABike - I've been through a half dozen issue pages here before I found your comment at the end of this one, this is the only solution that resolved the problem for me. I never migrated from D6 but clearly something was mixed up. As a summary I had to delete the "Newsletter category" field and recreate it, and then the Newsletter types started showing up properly.

marko b’s picture

I had the same problem, opening field setting, choosing default taxonomy term and saving seems to solved this.

ram4nd’s picture

Version: 7.x-1.x-dev » 7.x-1.1
Issue summary: View changes
Status: Closed (cannot reproduce) » Needs review
Issue tags: -error, -PDOException
StatusFileSize
new780 bytes

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tid' cannot be null: INSERT INTO {simplenews_newsletter} (nid, tid, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 9945 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 ) funktsioonis simplenews_newsletter_save() (rida 2001 / /drupal/sites/all/modules/simplenews/simplenews.module).

Pass the following option to git commit to attribute authorship to this user:
--author="ram4nd "

miro_dietiker’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Postponed (maintainer needs more info)

Fixing code happens in -dev.

ram4nd, there's no need to spam issue queues for attribution requests. Maintainers know how to do this and do this in case attribution appropriate.

Finally, please write a test or at least provide exact setup (mysql?postgres?) about how to trigger this bug.

ram4nd’s picture

Fixing code happens in dev, but maybe version can be helpful.

Well in my experience a lot of maintainers don't know that.

It's a huge site, that has many modules and has been upgraded since drupal 7.8. It would be hard to pinpoint the problem. But I can say that it happened while I was running migrate script. Also it happens on feeds import. It seems like the simplenews term is put to entity no matter what. It might has to do something with it being required. I will respond if I will have to dig in it more. I don't have time to look at it that closely.

miro_dietiker’s picture

Yes, you will need to provide a exact description to fix this bug.
Also, attribution only happens if ALL the patch work was done by you. If a maintainer needs to fix certain aspects, is a combined work and common to not attribute.
Here in concrete, if someone else provides tests in the same issue, you won't get the attribution. As with core, mentions (in commit messages) are the main instrument.

So if you want an attribution, you better perfectly describe the problem, provide a failing test outlining the issue, provide a fix, thus providing code on the quality level of a real maintainer. I'm looking forward to your inputs!

parraccourci’s picture

I had the same issue. I wanted to be able to send newsletter only for some nodes. So I checked the "simplenews" checkbox in the "publishing options" but I unchecked the "required field" in the newsletter category field. So the simplenews field can be empty. The patch solved my problem.

pol’s picture

The patch fix the problem with 7.x-1.x, if you upgrade to 7.x-2.x, the problem is gone.

francewhoa’s picture

This is to confirm this error

Steps to reproduce

  1. Fresh install:
    1. Drupal core 7.44
    2. Simplenews 7.x-1.x-dev (2015-May-1) or 7.x-1.1
  2. Upgrade from Drupal core 7.44 to 7.52
    • Notes
      • Related comment #11481869
      • Related comment #11808356
      • According to Brad Duell, the source of the challenge/bug might be related to updating a version of Drupal core, and or updating a version of the contributed module(s) entity (Entity API), and or entity_email, and or entityreference
  3. Upgrade from Drupal core 7.52 to 7.56
  4. Using:
    1. Drupal core 7.56
    2. Simplenews 7.x-1.x-dev (2015-May-1) or 7.x-1.1
    3. Firefox 52.4.0 (64-bit)
      or
      Chromium 57.0.2987.98
  5. Go to /node/add/simplenews
  6. Fill the form
    1. Under "Body" set "Text format" to "Filtered HTML"
    2. Select any "Newsletter category"
    3. Check "Create new revision"
    4. Check "Publish"
    5. Leave all other settings to their default
  7. Click on "Save" button
  8. The challenge is that this error is return on a blank page
    1. Error
      1. Error
        The website encountered an unexpected error. Please try again later.
    2. Screenshot
      Screenshot error
  9. Expected result is the user should see the next page. With this:
    1. A confirmation message "Simplenews newsletter <TITLE> has been created."
    2. Those horizontal tabs: "View", "Edit", "Manage display", "Newsletter"

We'll post another comment here later about the suggested resolution

bduell’s picture

The patch for #11 has not been applied yet for 7.x-1.x and 7.x-1.x-dev but fixes the issue.

Thank you, ram4nd!

francewhoa’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Hi miro_dietiker :) Thanks for all your maintainer contributions

The requested steps to reproduce this bug/challenge are into this comment #17 above

The requested suggested steps to resolve this challenge are into this comment #18 above.

Thanks to ram4nd for the patch in comment #11 :) And thanks to Brad, parraccourci, and Pol for testing it :) I also tested this patch with the most recent simplenews dev version, I can confirm that patch resolved the challenge.

As module maintainer, if you agree with this suggested resolution above, do you have everything you need to commit the patch in #11?

francewhoa’s picture

@Francewhoa :) This is a note to myself. I added this related ticket. For easier navigation about comment #17 above step to "Upgrade from Drupal core 7.44 to 7.52".