General question. In D6 FeedAPI I recall that the cron would import feed items for the parent feed even if it was unpublished. Is this the case with Feeds? Are there settings that need to be set?

If it does, is this the code to adjust to check if importer is published? Please advise on how to adjust it (sorry for my lack of programming skills in advance).

<?php
function feeds_cron() {
  if (
$importers = feeds_reschedule()) {
    foreach (
$importers as $id) {
     
feeds_importer($id)->schedule();
     
$rows = db_query("SELECT feed_nid FROM {feeds_source} WHERE id = :id", array(':id' => $id));
      foreach (
$rows as $row) {
       
feeds_source($id, $row->feed_nid)->schedule();
      }
    }
   
feeds_reschedule(FALSE);
?>
Files: 

Comments

hellomobe’s picture

I don't have my cron set up yet to test this, but here is my change - feedback welcome.

<?php
 
function feeds_cron() {
  if (
$importers = feeds_reschedule()) {
    foreach (
$importers as $id) {
     
feeds_importer($id)->schedule();
     
//comment out original code
      //$rows = db_query("SELECT feed_nid FROM {feeds_source} WHERE id = :id", array(':id' => $id));
    //check to see if node is published
 
$rows = db_query("SELECT feed_nid FROM {feeds_source} as fs LEFT JOIN {node} as n on fs.feed_nid = n.nid WHERE fs.id = :id AND n.status='1'", array(':id' => $id));
      foreach (
$rows as $row) {
       
feeds_source($id, $row->feed_nid)->schedule();
      }
    }
?>
hellomobe’s picture

This isn't working. When I clear the cache it still runs the unpublished feeds. (I really don't understand why it's running when the cache is cleared).

twistor’s picture

Title:Don't import items if parent feed is unpublished» Don't import items if parent feed is unpublished.
Component:Miscellaneous» Code
Category:support» feature

This is doable, but it would have to be done in a backwards-compatible, and configurable way.

steven.wichers’s picture

StatusFileSize
new672 bytes

Here's a patch for #1. I haven't tested if it actually works beyond comparing the result of a count() with and without restricting by node status (there was a difference).

liquidcms’s picture

Status:Active» Needs work

first test seems to show that patch in #4 does NOT work. will test more tomorrow.

tyler-durden’s picture

I'm not a programmer so I can't help, but as a user I'd think there should be a way to control the feed of each individual importer. Right now your only option is to delete it to stop it feeding, unless I am missing something. I need this individual control, and unpublishing it to turn it off would make logical sense.

Did this get anywhere? Last post mentions looking into why it didn't work tomorrow, but "tomorrow" was over 19 weeks ago.