Here's the problem: (from node_expire.rules.inc)

function node_expire_set_expired($nids, $set = FALSE) {
  static $nid_no = array();
  if (empty($close)) {
    $nid_no[] = $node->nid;
  }
  else {
    if ($nids = array_diff($nids, $nid_no)) {
      db_query('UPDATE {node_expire} SET expired = 1
        WHERE nid IN ('. implode(',', $nids) .')');
    }
  }
}

What the heck is $close?
This code will always fail because $close will always be empty.

I would submit a patch, but I'm not sure what this is supposed to do...
I'm unfamiliar with Rules hooks, but is this a half-finished Rules action callback?

CommentFileSizeAuthor
#19 rule.txt4.29 KBletzel
#2 node_expire-435560-2.patch1.09 KBsmsearcy

Comments

smsearcy’s picture

I'm not familiar with Rules either, but I'm guessing that instead of $close is should be $set (since that is being passed to the function but isn't being used). So it looks like this:

function node_expire_set_expired($nids, $set = FALSE) {
  static $nid_no = array();
  if (empty($set)) {
    $nid_no[] = $node->nid;
  }

That raised an error about the the first argument to array_diff() not being an array, so I made the following addition at line 19 in node_expire.module:

function node_expire_cron() {
  if ($query = db_query('SELECT n.nid FROM {node} n
      JOIN {node_expire} ne ON n.nid = ne.nid
      WHERE ne.expired = 0 AND ne.expire <= %d', time())) {
    $nids = array();  /** ADDED THIS LINE **/
    while ($node = db_fetch_object($query)) {
      $nids[] = $node->nid;

This worked for my site, but it's a little bit of guess-work.

smsearcy’s picture

Status: Active » Needs work
StatusFileSize
new1.09 KB

Here's a patch for the previous comment, soliciting feedback.

liliplanet’s picture

Is there perhaps an update on the errors or a new version please?

Same here, nodes do not expire and errors on cron jobs.

summit’s picture

Subscribing, greetings, Martijn

zapscribbles’s picture

Have applied this patch, testing on a node set to expire tomorrow

klonos’s picture

I am willing to help troubleshoot/test this one, but I am not sure how to reproduce it. Does it still apply in latest 2.x dev?

klonos’s picture

...Stephen how did this test of yours go mate?

vikramy’s picture

Version: 6.x-2.03 » 6.x-2.x-dev
Assigned: Unassigned » vikramy

Thanks for helping this.

I will try to explain the issue.

There is a field named "expired" in node_expire table. This field should set to "1" when node expires. But this is not happening now as of version 6.x-2.05. Because of this, people have issues like this http://drupal.org/node/433178.

Most users of this module are unpublishing their content after it expires using rules. But if someone needs a way just to send an email, then they get emails every cron run (after node expired) which is annoying. The way to fix this is as explained above by smsearcy.

Look for if (empty($close)) { in node_expire.rules.inc and replace $close by $set.
Add this $nids = array(); above while ($node = db_fetch_object($query)) { in node_expire.module
Will roll this into dev soon.
But there is also an option in rules under action "Unset the expired flag". I am trying to figure out the use case of that.

If no body needs that then its an easy fix, I guess..

vikramy’s picture

Can any one check latest dev? Make sure you run update.php

letzel’s picture

My use of the node_expire module is the following.

If a node expires, leave it published and
- send out an email to users that are responsible for the content of the node using CCK user reference fields
- move the node into another workflow state (I also use this as a condition for rules in order to avoid emails being sent out at every cron run)

Two views list up-to-date/outdated content a) on a per user base and b) as an overview for editors.

vikramy, I have just tested the latest dev as requested and I can happily confirm that the node does now properly expire on cron run.

klonos’s picture

How about the other people that used to have this issue? Do you still get it? (unfortunately I never managed to reproduce it, so I couldn't test)

vikramy’s picture

Status: Needs work » Needs review

Thanks letzel, klonos for testing this out..

I am trying to add a new feature and it is in the latest dev.

New feature will give us an option to send remainders to users every 2 weeks. Can some body test this out..

This is a sample rule.

array (
  'rules' => 
  array (
    'rules_11' => 
    array (
      '#type' => 'rule',
      '#set' => 'event_node_expired',
      '#label' => 'Node expire',
      '#active' => 1,
      '#weight' => '0',
      '#categories' => 
      array (
      ),
      '#status' => 'custom',
      '#conditions' => 
      array (
        0 => 
        array (
          '#type' => 'condition',
          '#settings' => 
          array (
            '#argument map' => 
            array (
              'node' => 'node',
            ),
          ),
          '#name' => 'node_expire_rules_expired_check_lastnotify',
          '#info' => 
          array (
            'arguments' => 
            array (
              'node' => 
              array (
                'type' => 'node',
                'label' => 'Content',
              ),
            ),
            'label' => 'Content is expired: Check lastnotify',
            'module' => 'Node',
          ),
          '#weight' => 0,
        ),
      ),
      '#actions' => 
      array (
        0 => 
        array (
          '#weight' => 0,
          '#info' => 
          array (
            'label' => 'Send a mail to a user',
            'arguments' => 
            array (
              'user' => 
              array (
                'type' => 'user',
                'label' => 'Recipient',
              ),
            ),
            'module' => 'System',
            'eval input' => 
            array (
              0 => 'subject',
              1 => 'message',
              2 => 'from',
            ),
          ),
          '#name' => 'rules_action_mail_to_user',
          '#settings' => 
          array (
            'from' => '',
            'subject' => 'Remainder email',
            'message' => 'Email message',
            '#argument map' => 
            array (
              'user' => 'author',
            ),
          ),
          '#type' => 'action',
        ),
        1 => 
        array (
          '#type' => 'action',
          '#settings' => 
          array (
            '#argument map' => 
            array (
              'node' => 'node',
            ),
          ),
          '#name' => 'node_expire_update_lastnotify',
          '#info' => 
          array (
            'arguments' => 
            array (
              'node' => 
              array (
                'type' => 'node',
                'label' => 'content expired',
              ),
            ),
            'label' => 'Update lastnotify',
            'module' => 'Node',
          ),
          '#weight' => 0,
        ),
      ),
      '#version' => 6003,
    ),
  ),
)
letzel’s picture

I'll test it and report. Generally I'd suggust to make the 2 weeks configurable rather than fixed.

vikramy’s picture

Did any one had a chance to test the new feature?

letzel’s picture

In my test case, no reminder was sent two weeks after expiration of the content. The content is still marked as expired. I found no error message in the log.

vikramy’s picture

Can you paste your rule? Also send me value of field in "lastnotify"?

letzel’s picture

I am most happy to respond, but being just a user, not a developer, I'd like to ask you to advise me how to get & compile the information.

Concerning the rule, do you want a screenshot of admin/rules/rules/rules_?/edit where ? is replaced by the rule id?

Concerning the value of field in "lastnotify", I searched the MySQL database and found entries in several tables. Which table's entry do you need?

vikramy’s picture

Field lastnotify will be in "node_expire" table.

Regarding rules, admin/rules/ie, Select the Triggered rules to export: "select the one you added for node expire", click export..
Even your mentioned screenshot would do..

letzel’s picture

StatusFileSize
new4.29 KB

Thank you for the explanation. All entries of field lastnotify in "node_expire" table have the value 0. Only one content node is expired for over two weeks, so one entry should be different.

The rule is attached to this post. (The correct domain name has been replaced by a fake "http://domain.name".)

vikramy’s picture

K.. that explains.. If possible can you do this..

Create a new test node.. Fill expiration date as "+1 sec". Click save.. After a sec or two run cron. Now check the value of lastnotify field.

or, do you think any node will expire soon? If, then after it expires let me know value of lastnotify field..

letzel’s picture

Two problems:

1) On opening the node creation form (node/add/page), I get the following warning:
warning: strtotime() expects parameter 1 to be string, array given in ....../sites/all/modules/node_expire/node_expire.nodeapi.inc on line 29.

2) At the bottom of the node creation form, under "Publishing options", the field "Expiration date: " accepts only numerical input, hence I cannot enter "+1 sec".
The field is pre-filled as follows: 1970-01-01
The explanation text line below the field reads:
Time date to consider the node expired. Format: 2010-12-02 (YYYY-MM-DD).

I am using the latest dev version of the module together with jQuery UI 6.x-1.4.

vikramy’s picture

Regarding 2, you are correct.. If you use jquery_ui, its hard to enter +1 sec. Give me a day or two.. I will try to fix or give a brief instruction.

Regarding 1, are you getting that for every node/add/page?

letzel’s picture

Regarding 2, I would like to add a request.

Consider the situation when the node is already expired, the content not yet updated and the admin wants to change something other than the content, i.e. even after the edit the node should remain expired.
Problem is that one can't leave the node expired because the system won't let you enter an expiry date that lies in the past. I would like to suggest to accept past expiry dates.

Regarding 1, the error appears for some but not all nodes. All nodes which give the warning when opening the edit tab have the expiry date 1970-01-01 in common. But there are other nodes with the same expiry date 1970-01-01 which do not give the warning when opening the edit tab. So it is a bit strange to me when & why this happens.

arrays’s picture

Hi,

I am using the 6.x-2.05 version. I set up the expire time to now() . But when i run cron, it does not expire the node.

I saw the $close and other points in the code and that all is already done in this version, but still its not working for me.

any idea??

Regards,
Aradhana

vikramy’s picture

Did you write a rule?

vikramy’s picture

Hi letzel,
Can you test latest dev..

arrays’s picture

Hi Vikramy,

No i did not write rule. but it should expire the node on cron run.. no?? I mean expired should be set to 1 when cron runs.

letzel’s picture

I tested the latest dev (Dec-03).

Regarding 1), I still reproduced the warning message on the node creation form (node/add/page):
warning: strtotime() expects parameter 1 to be string, array given in ....../sites/all/modules/node_expire/node_expire.nodeapi.inc on line 29.

Regarding 2) "+1 sec" is now accepted as input in the field "Expiration date: " under "Publishing options" at the bottom of the node creation form. (Past expiry dates are not accepted.)

vikramy’s picture

Hi arrays,
Latest dev should work that way..

@letzel, I haven't updated anything for your requests of 1 and 2.. I want to first fix this new feature, then I will take a look at those.. Can you run cron and check "lastnotify" field in "node_expire" table..

letzel’s picture

Hi vikramy,
ok, that's fine to me.

The value of "lastnotify" field in "node_expire" table has changed from 0 to 1291892845.

vikramy’s picture

@letzel, Did that work.. After cron run your rule must work.. Let me know if it worked..

letzel’s picture

Meanwhile I moved to another host where I experience difficulties to send out Drupal emails. Only emails sent via the contact form work, but no update notifications. Sorry, it is no good time to test node_expire remainder emails... Please bear with me.

PB1’s picture

Hello.

I wanted to share my experience with the first problem that @letzel noted in #21 above (the strtotime() error from line 29 of node_expire.nodeapi.inc).

I upgraded to the 2010-Dec-11 release of Node Expire version 6.x-2.x-dev over this past weekend. Yesterday (2010-12-20) I started getting the strtotime() error whenever I tried to edit or create a node of most (but not all) content types.

When I attempted to edit any of the definitions of the content types that were experiencing the above error (.../admin/content/node-type/page, for example), I received the following warning:

warning: htmlspecialchars() expects parameter 1 to be string, array given in /srv/www/vhosts/rc2beta/includes/bootstrap.inc on line 857.

When I edited my "newsflash" content type, for example, I received the "htmlspecialchars()" error, and I noticed that the default expiration date field was empty. I set default expiration date to "+4 weeks" and saved the content type definition. I was then able to edit and create "newsflash" nodes without the "strtotime()" error occurring.

I later had the idea to check the "node_expire_ntypes" variable in the MySQL database, and found the following value (re-formatted to make it easier to read):

a:8:{s:9:"newsflash";a:3:{s:7:"default";s:8:"+4 weeks";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:4:"page";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:18:"cctst_announcement";a:2:{s:7:"default";a:3:{s:7:"default";s:8:"+2 weeks";s:3:"max";s:0:"";s:8:"required";i:1;}s:3:"max";s:0:"";}
     s:4:"blog";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:5:"story";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:5:"event";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:5:"panel";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:7:"ce_page";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
    }

I then edited the "cctst_announcement" content type definition, received the "htmlspecialchars()" warning, and noticed that the default expiration date field was again empty. I set the default expiration date value and saved the content type definition. I was then able to create and edit "cctst_announcement" nodes without any errors.

After these changes, the node_expire_ntypes variable in the DB then looked like this:

a:8:{s:9:"newsflash";a:3:{s:7:"default";s:8:"+4 weeks";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:4:"page";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:18:"cctst_announcement";a:3:{s:7:"default";s:8:"+2 weeks";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:4:"blog";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:5:"story";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:5:"event";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:5:"panel";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
     s:7:"ce_page";a:2:{s:7:"default";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}s:3:"max";s:0:"";}
    }

I then edited all of my other content types and just re-saved them again. The node_expire_ntypes variable then looked like this:

a:8:{s:9:"newsflash";a:3:{s:7:"default";s:8:"+4 weeks";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:4:"page";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:18:"cctst_announcement";a:3:{s:7:"default";s:8:"+2 weeks";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:4:"blog";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:5:"story";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:5:"event";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:5:"panel";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
     s:7:"ce_page";a:3:{s:7:"default";s:0:"";s:3:"max";s:0:"";s:8:"required";i:0;}
    }

After this, I was able to edit/create nodes of all content types, without any errors. Later re-editing of the content type definitions did not generate any errors, and the default expiration date values were stored correctly.

I think the process of updating/re-saving the content type definitions "fixed" a formatting problem in the node_expire_ntypes variable.

I hope this information is helpful in tracking down the strtotime() and htmlspecialchars() problems.

One last question I have: I noticed that, in addition to the "node_expire_ntypes" variable, I have "node_expire_" and "node_expire_required_" variables for every content type listed in the node_type table. Should I have those variables, or are they now obsolete with the use of the "node_expire_ntypes" variable?

Thanks to all for this module and your helpful comments.

Pete

vikramy’s picture

Thank you for your detailed post.. Bit busy this week but will get back to you soon..

Regarding your "htmlspecialchars()", this should be from views? http://drupal.org/node/1000760

I am not 100% sure but worth a try..

Can you give me more info about "strtotime() error/warning"?

PB1’s picture

Hi, vikramy. I understand about being busy, since we are approaching the Christmas holiday here in the US. :)

Yes, I did also upgrade to the latest 6.x version of Views (6.x-2.12, released on 2010-12-15) over this past weekend, since that was a security update. The Views issue thread that you referenced, though, appears to be for the 6.x-3.x-dev branch, which I do not have installed.

I don't think the Views 6.x-2.12 release was causing the "htmlspecialchars()" error when I edited Content Type definitions. There should not be any Views in use on that Admin page, in my websites.

My theory is that the value in the "node_expire_ntypes" variable got corrupted when I upgraded to the 2010-Dec-11 release of Node Expire version 6.x-2.x-dev, and that the corrupted value was causing the "htmlspecialchars()" warning when I edited my Content Types. I am guessing that Drupal encountered the error when it was trying to determine what the Default Expiration Date value should be for the Content Type.

As I mentioned, the "strtotime()" error was occurring whenever I tried to edit or add a node with a Content Type referenced in the value for the "node_expire_ntypes" variable. My guess is that the corrupted value in "node_expire_ntypes" again caused a parsing error when Drupal was trying to determine what to use for the Expiration Date value on the node edit page.

Just to be clear, my sites are not encountering these errors anymore, after I re-saved all of my Content Type definitions.

Thanks again for your thoughts on this. Please let me know if you need more information about the "strtotime()" error. Have a good holiday.

Pete

letzel’s picture

Ok, emails are working again, and the reminder email is being sent successfully now. However, it keeps being sent at every cron run, not just once, so I had to disable the reminder rule for the time being.

I can confirm that I am getting the same warnings as @PB1, strtotime() error, ...expects parameter 1 to be a string... using the latest dev and Views 6.x-2.12. These warnings appeared shortly after making changes to node_expire, first time several weeks ago.

Merry Christmas to everybody!

vikramy’s picture

@letzel, You must also add an action "Update lastnotify" to your rule to send email once in 2 weeks..

Also as suggested by @PB1, please try re-saving all your Content Type definitions -- admin/content/node-type/* ..

@PB1, I am still not able to reproduce that strtotime() error on my test installation.. Based on your comments, it looks like that variable is corrupted. If you can still go back and can reproduce this error, try this code inside node_expire_update_6201() @node_expire.install on dev version.

if ($ntypes = variable_get('node_expire_ntypes', array())) {
  variable_set('node_expire_ntypes', $ntypes);
}

Just re save that variable on update.. Don't know why this would help..

Also take a look at this.. http://info4admins.com/warning-htmlspecialchars-expects-parameter-1-be-s....

If @letzel confirms re saving all Content Type definitions fixes that issue, then my priority would be to make a new release and start working on d7 version. Suggestions?

letzel’s picture

Happy New Year to everybody!

Re-saving all content type definitions seems to have fixed that issue - thanks for the suggestions, @vikramy and @PB1.

Also, adding the action "Update lastnotify" to my rule to send email once in 2 weeks helped to avoid reminders being sent out with every cron run.

PB1’s picture

Hi, again, @vikramy, Happy New Year!

I'm sorry, I am unable to reproduce the strtotime() error, now that I have re-saved all of my Content Type definitions.

I think you are good to go with making a new release and working on the D7 version.

I'm glad to hear that @letzel's site is working now, too. :)

Thanks.

Pete

vikramy’s picture

Happy new year... Thanks every one.

I am closing this issue, please re open if any issues..

vikramy’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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