Comments

alex_b’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Component: User interface » Code

Good feature request. Applies to HEAD.

alex_b’s picture

Issue tags: +Novice

This is a novice task.

budda’s picture

Is this simply a case of removing the form #required or are there other implications of having "feed" nodes with no feed URL set?

budda’s picture

Status: Active » Needs review
StatusFileSize
new417 bytes

Patch attached to remove required setting just to get the issue cleared.

alex_b’s picture

Status: Needs review » Needs work

This should be optionally required.

budda’s picture

An option to make another field optional. Is that going to far with the options a site builder has?

budda’s picture

Status: Needs work » Needs review
StatusFileSize
new1.45 KB

Here's a more flexible configuration option patch.

patcon’s picture

Same feature could be useful for file uploads too (not just feed URLs).

alex_b’s picture

Status: Needs review » Needs work

Sorry for coming around late:

'feed_required' should be 'url_required'.

#8: you are right, we should cover both fetchers.

patcon’s picture

Sorry alex, so given that both fetchers should be covered, isn't "feed_required" the best config name? (If I extend this?)

patcon’s picture

Right now, it's looking like I need to set a "feed_required" setting for each fetcher, but I'm wondering whether I can set set this on the Basic settings page in such a way that any fetcher (even if a new one is introduced) will inherit this "required" property?

Still new to this though. Bad idea? Not how it works?

alex_b’s picture

#10

Good point, let's use "source_required" then.

patcon’s picture

Assigned: Unassigned » patcon
Bevan’s picture

Title: Option to choose if the feed url is required or not » Add option to make source URL/file not required for importers attached to nodes
Assigned: patcon » Unassigned
Issue tags: -Novice
StatusFileSize
new5.47 KB

This patch implements a configuration option for both the File and HTTP fetchers to make the field optional. It also hides the "Import" tab on nodes if there is not a valid source. There are some minor issues;

  • The source for a stand-alone importer can be made not-required. This does not make any sense and results in errors. How can it be determined if an importer is a standalone importer or not?
  • A file can not be deleted from a Feeds-parent node without turning on the "Supply path to file directly" option and deleting the file referenced in the text field. A node-editor should be able to delete the source file if it is not required.
  • A required File source field does not have an asterisk indicating that it is required. I think this can be fixed in theme_feeds_upload().
  • This is the only way I could find to determine if a FeedsSource actually has a valid source or not in feeds_access() and feeds_nodeapi(). It seems clunky, and there is probably a better way?;
        $source_config = $source->getConfigFor($source->importer->fetcher);
        if (!empty($source_config['source']) {
          // ...
        }
    

The patch needs more work, but it also needs some review to maintain good direction.

This does not really seem like a novice issue any more.

Holoduke’s picture

I need this feature.

I checked patch from budda, looks nice, var name will be changed easy to source_required.
But i didn't saw applied to form exposed:

  public function sourceForm($source_config) {
    $form = array();
    $form['source'] = array(
      '#type' => 'textfield',
      '#title' => t('URL'),
      '#description' => t('Enter a feed URL.'),
      '#default_value' => isset($source_config['source']) ? $source_config['source'] : '',
      '#maxlength' => NULL,
  +    '#required' => <strong>$this->config['source_required'],</strong>
    );
    return $form;
  }

I just tested at my site and it works fine. Ofcourse, the patch is old and i doesn't fit current beta version, but the concept works fine. I changed by hand. I don't know how to post a complete patch, but if anybody has a CSV configured, the patch will be done within minutes.

Bevan’s picture

EmanueleQuinto’s picture

The attached patch simply reproduce settings from FeedAPI options (#590064: Optional feeds) and works only for file fetcher.

Should be straightforward to extend to HTTP as well but I can't test that fetcher.

sbydrupal’s picture

Will there be any update on this issue moving forward ?

Patches in #7 and #15 works in the sense that the page can be submitted without requiring feed url (I use a single content type to
capture the feed in). However, during node submission, it still runs the import process and provide warning that feed coulnd't be retrieved...

Will the upcoming update include the changes ?

Thx much

Arts and Ideas’s picture

Sure could use this update, too!
Need to import AND locally create nodes.
Thanks.

Bevan’s picture

Status: Needs work » Needs review

Lets try to get some attention from the maintainers.

dfgcvb’s picture

Subscribe.

farhadhf’s picture

Subscribe!

mareks’s picture

Using latest D7 dev and I too think that the URL field should be optional.

For example, I connected the feeds with my existing content type called Student - in order to pull in their personal blog info. But not all students have a blog :)

I feel like a fool. This is so obvious case. I must be doing something wrong? Maybe the mappers are somehow behind this?

kscheirer’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Priority: Normal » Major
Issue summary: View changes
Status: Needs review » Needs work

Ran into the same problem, this patch would still be useful in 2014...

I'm using Feeds 7.x-2.0-alpha8 and https://drupal.org/project/feeds_selfnode_processor, and not all my nodes have a feed from which to update. Not sure which patch to port to D7.

kscheirer’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha8
Status: Needs work » Needs review
StatusFileSize
new6.15 KB

This worked for me, patch written for version 7.x-2.0-alpha8.

It's a reroll of Bevan's patch in #14, which looked most complete to me. Luckily most of the code is still the same. Sorry for the p5 format, I'm sure that will make the tests fail :(

Status: Needs review » Needs work

The last submitted patch, 25: 856316-optional-source-url-25.patch, failed testing.

kscheirer’s picture

Status: Needs work » Needs review
StatusFileSize
new5.77 KB

Sorry, here's a properly formatted patch.

Status: Needs review » Needs work

The last submitted patch, 27: 856316-optional-source-url-27.patch, failed testing.

kscheirer’s picture

All these errors look like problems in the tests themselves, can someone confirm? Patch is working great for me.

subu.purohit’s picture

#4 did a quick fix for me and required tag was removed from node form. But when I submit node then it returned me error "The url is invalid".

So I added a condition in sourceFormValidate() function as:

if ($values['source'] != null) {

and now it is skipping validation for url field.

xiahy’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 27: 856316-optional-source-url-27.patch, failed testing.

kscheirer’s picture

Re #27, still looks like unrelated test cases are failing. I'm happy to fix up the patch if there's really something wrong of course.

Patch has been in my production for almost 2 months and is still working great for me.

ufku’s picture

Version: 7.x-2.0-alpha8 » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new6.51 KB

Updated the patch. It now also removes/skips scheduling when there is no source. This saves lots of execution time during cron.

Rob_Feature’s picture

On the latest dev we get

Hunk #1 succeeded at 90 (offset 19 lines).
Hunk #2 FAILED at 145.
Hunk #3 succeeded at 221 (offset 27 lines).
Hunk #4 succeeded at 231 (offset 27 lines).
1 out of 4 hunks FAILED -- saving rejects to file plugins/FeedsHTTPFetcher.inc.rej
twistor’s picture

Status: Needs review » Needs work
+++ b/feeds.module
+++ b/feeds.module
@@ -635,11 +635,9 @@ function feeds_node_insert($node) {

@@ -635,11 +635,9 @@ function feeds_node_insert($node) {
   if (isset($node->feeds) && $importer_id = feeds_get_importer_id($node->type)) {
     $source = feeds_source($importer_id, $node->nid);
     // Start import if requested.
-    if (feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) {
+    if ($source->hasFetcherSource() && feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) {
       $source->startImport();
     }
-    // Schedule the source.
-    $source->schedule();

Why are we not scheduling the feed on insert?

ufku’s picture

feeds_node_insert() calls feeds_node_update() which schedules the import if a source is provided.

senzaesclusiva’s picture

Sorry to reopen this.
I wish to ask if this option is already included in dev version
Thanks

kscheirer’s picture

@senzaesclusiva - no worries, the issue was never closed, so you're not re-opening. This code is not yet in the dev version, you'll need to apply one of the patches in this issue.

senzaesclusiva’s picture

Many thanks Kscheirer
i'll try to apply one of them.

senzaesclusiva’s picture

Hello Kscheirer
I tried to apply a patch (feeds 7.x-2.0-alpha8 ) but it seems something goes wrong.
Here is a terminal report:

patching file feeds.module
Hunk #1 FAILED at 635.
Hunk #2 FAILED at 648.
2 out of 2 hunks FAILED -- saving rejects to file feeds.module.rej
patching file includes/FeedsSource.inc
Hunk #1 FAILED at 296.
Hunk #2 FAILED at 792.
2 out of 2 hunks FAILED -- saving rejects to file includes/FeedsSource.inc.rej
patching file plugins/FeedsFetcher.inc
patching file plugins/FeedsFileFetcher.inc
patching file plugins/FeedsHTTPFetcher.inc
Hunk #1 succeeded at 57 (offset -14 lines).
Hunk #2 FAILED at 112.
Hunk #3 succeeded at 166 (offset -28 lines).
Hunk #4 succeeded at 176 with fuzz 2 (offset -28 lines).
1 out of 4 hunks FAILED -- saving rejects to file plugins/FeedsHTTPFetcher.inc.rej

Wich could be the issue?
Thanks a lot

kscheirer’s picture

Which patch did you apply? If it's the one from #35, it should be applied to 7.x-2.x-dev, not the alpha.

senzaesclusiva’s picture

damn.....I used the wrong version :-))
Sorry

senzaesclusiva’s picture

StatusFileSize
new464 bytes

Well
i patched now the dev version and it seems to works fine; importers attached to the node has
URL/file field not required. Good!

But there is an issue referred to FeedsHTTPFetcher.inc. (look rej file attached).

It remain to be seen why Feeds Image Grabber doesn't work, as i posted few days ago.
https://www.drupal.org/node/2380661

The last submitted patch, 35: feeds-optional_source-856316-35.patch, failed testing.

reszli’s picture

StatusFileSize
new6.55 KB

here is the modified patch, that applies to latest dev
and the field can now be set to optional :)
thanks!

megachriz’s picture

Status: Needs work » Needs review

Setting to "Needs review" so the testbot will test the patch in #48.

Status: Needs review » Needs work

The last submitted patch, 48: feeds-optional_source-856316-48.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 48: feeds-optional_source-856316-48.patch, failed testing.

paulsheldrake’s picture

Updating the patch from #48 to apply cleanly.

paulsheldrake’s picture

paulsheldrake’s picture

Status: Needs work » Needs review

Updating status to trigger testing

The last submitted patch, 53: feeds-optional-source-num48-rerolled-856316.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 54: feeds-optional_source_num48_rerolled-856316.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 54: feeds-optional_source_num48_rerolled-856316.patch, failed testing.

megachriz’s picture

mr.york’s picture

Status: Needs work » Needs review
StatusFileSize
new7.4 KB

Reroll.

Status: Needs review » Needs work

The last submitted patch, 61: feeds-optional_source_num48_rerolled-856316-61.patch, failed testing.

mr.york’s picture

StatusFileSize
new1.2 KB
new7.24 KB

Fixed scheduler problem.

mr.york’s picture

Status: Needs work » Needs review

megachriz’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

I tested the patch from #63 in action with the HTTP Fetcher. Codewise it looks good so far, though I have less knowlegde about the scheduling stuff.

With the importer attached to a content type and "Require feed" option turned off for the HTTP Fetcher, I noticed the following:

  1. When adding a feed node the fields "Title" and "URL" are both optional. If I leave both empty and then try to save the node the following two error messages appear:
    • Source URL is empty.
    • Could not retrieve title from feed.

    Shouldn't that say something like "The title or the URL is required"? This issue is perhaps related to #1621602: Could not retrieve title from feed - Make title field only optional if the parser can deliver a title.

  2. The import tab is visible on the feed node, even when no source is supplied. When you go to the import page, you can try to perform an import which results into the error "Source URL is empty.". Shouldn't the import tab be hidden when there is nothing to import? Or maybe a warning should be displayed on the import page when there is no source?
  3. I noticed that an entry is created in the feeds_source table even when no source is supplied. I'm not sure if that entry should be created in this case. When looking in the code it seems that it doesn't lead to any problems, because in FeedsSource::scheduleImport() no import job is scheduled if there is no source. So maybe this is fine.

Other:

  • The source can be made optional for importers using a standalone form as well. I think the option should not be available in this case and the source should be required in all cases. I see that this issue is noted as a @todo in the code.
  • This needs automated tests. I think the tests should cover at least the following:
    • When no source is supplied, no errors should occur during cron.
    • When a source is supplied later, all content gets imported after running cron.
    • When a source is removed later, no errors should occur during cron.

    Perhaps there are more useful cases to test.

Good work so far!

dshields’s picture

The patch in #63 only helps with existing nodes.
It fails when creating a new node.

dshields’s picture

StatusFileSize
new7.73 KB

This extends #63 to allow for the file source to be optional while creating new nodes as well as editing existing nodes.

dshields’s picture

Status: Needs work » Needs review
megachriz’s picture

Status: Needs review » Needs work

Tests are passing. Back to "Needs work" as per #66.

geoffreyr’s picture

Status: Needs work » Needs review
StatusFileSize
new8.2 KB

Reroll of patch against most recent 7.x-2.x-dev.

Status: Needs review » Needs work

The last submitted patch, 71: feeds-optional_source-856316-71.patch, failed testing. View results

dhigby’s picture

I want the ability to optionally specify a newsfeed for a node, so that I can aggregate feeds from all nodes into a large newsfeed. Since this capability is not yet available, it seems to me that I am using the wrong tool for the job. What solutions have others ended up with?

bluegeek9’s picture

Status: Needs work » Closed (outdated)
//www.flaticon.com/free-icons/thank-you Thank you for your contribution!

Unfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.