Allow aggregator feed items to never be discarded, by adding an additional option in 'Discard news items older than:'

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LAsan’s picture

Version: x.y.z » 7.x-dev

Applies to current version?

lolandese’s picture

Is there already a patch to accomplish this (D6)?

alex_b’s picture

Issue tags: +Novice

Novice task.

sethcohn’s picture

The fix via form_alter

D5:

function custommodule_form_alter($form_id, &$form) {
  if ($form_id == "aggregator_admin_settings"){
    $form['aggregator_clear']['#options'][157784630]  = "Nearly Never aka 5 years";                   
  }
}

D6 (and D7?):

function custommodule_form_aggregator_admin_settings_alter(&$form, &$form_state) {
    $form['aggregator_clear']['#options'][157784630]  = "Nearly Never aka 5 years";                   
}
JamesAn’s picture

Status: Active » Needs review
FileSize
1.51 KB

I've added a 'never' option to the 'Discard news items older than' field.

When aggregator_expire is called, it returns without discarding if the 'never' option is selected.

mr.baileys’s picture

Thanks for working on this JamesAn!

Strict technical review (haven't tested the functionality):

  1. Strings should be run through t() so they can be translated:
    +    $period[0] = 'Never';
    
  2. As per Coding Standards, comments should end with a period:
    +  // Check if items should be retained indefinitely
    
  3. 2 calls to variable_get to retrieve the same value: we can reuse the result from the first variable get instead of calling it a second time (second call below):
       // Remove all items that are older than flush item timer.
       $age = REQUEST_TIME - variable_get('aggregator_clear', 9676800);
    
  4. Not sure that $aggregator_clear is the best name for the variable, as it doesn't indicate that we are talking about a timespan/period.

Setting back to CNW for #1 and #2. #3 and #4 are just my preference, so feel free to ignore ;)

mr.baileys’s picture

Status: Needs review » Needs work

Forgot to actually set it to CNW...

JamesAn’s picture

Status: Needs work » Needs review
FileSize
1.59 KB

Thanks for the review. For #4, I used $aggregator_clear simply because the variable name in Drupal is 'aggregator_clear'. I've tweaked the patch by hand.. let's hope I didn't mess it up! *fingers-crossed*

Status: Needs review » Needs work

The last submitted patch failed testing.

JamesAn’s picture

Status: Needs work » Needs review
FileSize
1.62 KB

Ok, ok.. I re-rolled the patch.. -.-" This should work now.

Status: Needs review » Needs work

The last submitted patch failed testing.

JamesAn’s picture

Status: Needs work » Needs review

That's strange. The patch passed last time I checked. Let's re-test!

catch’s picture

I'm wondering if we should define a constant for NEVER rather than using 0. Otherwise this looks good to me. Test bot could use a nudge.

alex_b’s picture

Agreed. 0 should be a constant for clarity's sake: Introduced AGGREGATOR_CLEAR_NEVER and rerolled.

alex_b’s picture

Status: Needs review » Needs work
alex_b’s picture

Status: Needs work » Needs review

Nudging the bot.

Dries’s picture

We use 0 as never (or unlimited) in other places, so we could consider making it one (or two) generic constants. I'm happy to do that in a follow-up patch though.

Berdir’s picture

Status: Needs review » Needs work
+    $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(':fid' => $feed->fid, ':timestamp' => $age))->fetchCol();
-  $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(':fid' => $feed->fid, ':timestamp' => $age))->fetchCol();

If you have multiple arguments, they should be splitted up to multiple lines, see #394586-10: DBTNG: Trigger module ( A)

akahn’s picture

Status: Needs work » Needs review
FileSize
2.74 KB

Correcting db_query() indenting.

akahn’s picture

Status: Needs review » Reviewed & tested by the community

Giving this a spin and a more careful look, I think it's good to go.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

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

inspirited’s picture

Version: 7.x-dev » 6.14
Status: Closed (fixed) » Active

I read your post about how to add a "never" option to the aggregator in the discard setting. I was wondering if you could explail a little more or point me in the right direction. You posted a Patch but I wasn't sure how to implement or install it. I'm interested in having my aggregator keep all of my posts. I would greatly appreciated your help. Thank you for your time. I'm a newb to Drupal but follow directions really well :)

Sincerely,
John

mr.baileys’s picture

Version: 6.14 » 7.x-dev
Status: Active » Closed (fixed)

@inspirited: Information about applying patches. However, the patches in this thread are specific to Drupal 7, and it's unlikely that you'll be able to make these work on D6 without some tweaking.

Since this feature was implemented in D7, and new features are not backported to earlier versions, this issue was closed, and it is generally not done to re-open closed issues so I've changed the status back to closed.

If you would still like this feature in D6 you might find help through one of the support channels, especially the forums or irc.

djschoone’s picture

Strange this didn't make it to any official release yet. I'm happy with this workaround sethcohn made (#60468-11: Allow aggregator feed items to never be discarded. Rewrote it to D6:

function custommodule_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == "aggregator_admin_settings"){
    $form['aggregator_clear']['#options'][157784630]  = "Nearly Never aka 5 years";                  
  }
}
wavesailor’s picture

Issue summary: View changes

Any idea how I can get the "Never 5 years" into Drupal 7?

I created a custom module but it does not work - copied it from Drupal 6 code here https://www.drupal.org/node/21959#comment-2873140

Created a aggregator_settings.module and aggregator_settings.info file

<?php
/**
 * add the additional clear options
 */

function aggregator_settings_form_aggregator_admin_settings_alter(&$form, &$form_state) {
$form['aggregator_clear']['#options'][31556926]  = "1 year";
$form['aggregator_clear']['#options'][63113851]  = "2 years"; 
$form['aggregator_clear']['#options'][157784630]  = "5 years";                  
}