Symptoms

When saving or creating a newsletter issue, the newsletter (taxonomy term) is not saved with the issue (node). Thus, the newsletter issue does not belong to any newsletter.

Affects

Drupal 6.24 core codebases and greater.

Issue details

To fix a bug in the taxonomy system, Drupal core altered the way that taxonomy is presented in the node object during the "Update" and "Insert" operations in the nodeapi.

See #1427848: Node taxonomy array key change on node_save

The Fix

I'm attaching a patch for all 6.x-2.x branches of simplenews to account for any drupal core version when assigning the simplenews term id on the update and insert operations.

Comments

KeyboardCowboy’s picture

This patch affects simplenews.module on the 6.x-2.x branch only and fixes the issue surrounding the change to the taxonomy structure in Drupal 6.24.

berdir’s picture

Status: Needs review » Needs work
+++ b/simplenews.module
@@ -659,7 +659,24 @@ function simplenews_nodeapi(&$node, $op, $teaser, $page) {
+      // Drupal changed its taxonomy format on the insert and update operations
+      // in version 6.24.
+      $terms = array_values($node->taxonomy);
+
+      // Drupal <= 6.23: $node->taxonomy[vid] = tid
+      if (is_int($terms[0])) {

Using $first_term = reset($node->taxonomy) and then checking that would probably be easier than this.

KeyboardCowboy’s picture

Status: Needs work » Needs review
StatusFileSize
new3.36 KB

Patch has been updated with the code recommended by @Berdir. I love picking up new tools. I can't believe I was never familiarized with those basic PHP array commands.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

I guess I'd also be fine with just supporting the newest core version, everyone should keep their core versions up to date anyway, but if we already have to code, then let's keep it.

husztisanyi’s picture

This patch works for me, thanks!

simon georges’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

berdir’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

This probably need to be ported to 6.x-1.x as well?

That branch is pretty much dead but this completely breaks the module and we have 17k reported users who are using 6.x-1.3...

simon georges’s picture

@Berdir, do you mean we should release a 6.x-1.4 ?

berdir’s picture

First, we actually need to commit yet, but yes, then it will require a release I guess.

berdir’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Patch (to be ported) » Fixed

Can't reproduce this issue in 6.x-1.x. Back to fixed then.

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