Errors on cron run

hammiesink - April 7, 2009 - 18:14
Project:Node Expire
Version:6.x-2.03
Component:Miscellaneous
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

When I run a cron manually from the Status Report screen, I get the following error:

* user warning: Duplicate entry '8' for key 'PRIMARY' query: INSERT INTO node_expire (nid, expire, expired) VALUES (8, 0, 0) in /mydomainname/includes/common.inc on line 3422.
* user warning: Duplicate entry '9' for key 'PRIMARY' query: INSERT INTO node_expire (nid, expire, expired) VALUES (9, 0, 0) in /mydomainname/includes/common.inc on line 3422.
* user warning: Duplicate entry '10' for key 'PRIMARY' query: INSERT INTO node_expire (nid, expire, expired) VALUES (10, 0, 0) in /mydomainname/includes/common.inc on line 3422.
* user warning: Duplicate entry '11' for key 'PRIMARY' query: INSERT INTO node_expire (nid, expire, expired) VALUES (11, 0, 0) in /mydomainname/includes/common.inc on line 3422.

#1

marioe2000 - April 23, 2009 - 18:09

Same problem here... only difference is that I get it for only two records.

#2

aluminium - May 11, 2009 - 04:25

Same problem

Duplicate entry '506' for key 1 query: drupal_write_record /* Administrator : drupal_write_record */ INSERT INTO node_expire (nid, expire, expired) VALUES (506, 0, 0) in /home/folder/data/www/domain/includes/common.inc on line 3422.

#3

smsearcy - May 13, 2009 - 01:31

Try changing the code at line 53 in node_expire.nodeapi.inc from:

    case 'insert':
      $update = array();
      if (isset($node->node_expire)) {
        $update[] = 'nid';
      }

to
    case 'insert':
      $update = array();
      if (isset($node->expire)) {
        $update[] = 'nid';
      }

It wasn't properly detecting if it was editing an existing record.

#4

aluminium - May 13, 2009 - 19:48

Hi, smsearcy!
Thanks for your reply.
You code work fine, my problem is completely solved.

#5

smsearcy - May 14, 2009 - 23:46
Status:active» needs review

Here's a patch for code change in comment #3. I think I created it correctly, please let me know if there is a problem.

AttachmentSize
node_expire-426636-5.patch 435 bytes

#6

smsearcy - May 29, 2009 - 16:37

I ran into an issue with my previous patch of not being able to add an expiration date to an existing node without an expiration date (I think because it was attempting to update a non-existent record in {node_expire}), so I rewrote the insert/update section. This hopefully will also address #466680: Nodes saved in node_expire table with value of 0 then unpublished by not saving an empty expiration date in the table (and will clean up the table).

    case 'update':
    case 'insert':
      db_query('DELETE FROM {node_expire} WHERE nid = %d', $node->nid);
      if (empty($node->expire)) {
          // don't save an empty expiration date in the database
          break;
      }
      $node->expire   = strtotime($node->expire);
      $node->expired  = FALSE;
      db_query('INSERT {node_expire} (nid, expire, expired) VALUES(%d, %d, %d)', $node->nid, $node->expire, $node->expired);
      break;

I've attached a patch, which hopefully is correctly formatted (I'm stuck running Windows).

AttachmentSize
node_expire-426636-6.patch 737 bytes

#7

smsearcy - May 29, 2009 - 17:11

Minor formatting change to previous post, and removed the second point from the case statement.

    case 'update':
    case 'insert':
      db_query('DELETE FROM {node_expire} WHERE nid = %d', $node->nid);
      if (!empty($node->expire)) {
        $node->expire   = strtotime($node->expire);
        $node->expired  = FALSE;
        db_query('INSERT {node_expire} (nid, expire, expired) VALUES(%d, %d, %d)', $node->nid, $node->expire, $node->expired);
      }
      break;

AttachmentSize
node_expire-426636-7.patch 765 bytes

#8

arthurf - June 1, 2009 - 14:42

Here's a slight variation on the above patch- removes the the $update array and uses the drupal_write_record fuction instead of the db_query. It also prevents makes the delete query conditional. I'm not sure if there is ever a condition where this would be the case, but seems like it might be a good idea to check for it.

AttachmentSize
node_expire_diff.patch 1.13 KB

#9

barckhoff - June 2, 2009 - 07:47

Excellent! Thank you so much for posting this -- I installed the arthurf patch (#8 above) and it seems to be working for me.

Any idea how to stop node expire from subtracting a day from the expiration date every time a node is edited? (See http://drupal.org/node/435658)

#10

smsearcy - June 3, 2009 - 00:53

I tested arthurf's patch (#8) when adding/modifying/deleting expiration dates on new and existing nodes and didn't find any issues. Thank you.

#11

p4trizio - June 12, 2009 - 23:53

Hi guys! Isn't it time to make a new release of this module? With all this patches... I'm lost! ;-)
Can someone post the MUST patches of this module? Just a simple list to make it work in a good way.
Thank you!

#12

Summit - June 16, 2009 - 20:52

Hi, I think committing the working patches in a .dev would be the best way, because maybe there is also a working order for the patches to commit properly, right? Then after testing making a 2.04 or 2.1 please.
Thanks a lot in advance for considering this!
Greetings, Martijn

#13

the.alphy - June 20, 2009 - 00:46

I'm having this same error. How test/stable is the patch? Does anyone know when it will make it's way into 2.04/the next version?

#14

JamesAn - June 20, 2009 - 04:44
Status:needs review» reviewed & tested by the community

The patch in #8 works for me too. I took a quick peek at the PHP code and it makes sense to me.

Maybe if we RTBC this, one of the committers will take notice.

#15

the.alphy - June 20, 2009 - 05:38

Yeah, I tested the patch as well and it seems to fix the problem so far.

#16

squiggle86 - June 25, 2009 - 02:01

Subscribe, I've been having the same issue

 
 

Drupal is a registered trademark of Dries Buytaert.