Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The aggregator supports OPML export for all feeds, but not import. This patch enables import of OPML lists, allowing people to import lists of RSS feeds they've already assembled in another RSS app.
Comment | File | Size | Author |
---|---|---|---|
#56 | opml_redirect.patch | 1.83 KB | mustafau |
#55 | opml_redirect.patch | 1.56 KB | mustafau |
#53 | aggregator-opml-import-16282-53.patch | 15.19 KB | mustafau |
#51 | aggregator-opml-import-16282-51.patch | 15.12 KB | mustafau |
#50 | aggregator-opml-import-16282-50.patch | 15.24 KB | mustafau |
Comments
Comment #1
Dries CreditAttribution: Dries commented1. This patch does not conform Drupal's coding style at all.
2. The error handling of aggregator_import() is bare bones (not helpful).
3. Use drupal_xml_parser_create() instead of xml_parser_create().
4. Drop the "sorry"'s.
5. form_set_error() is used incorrectly.
Please refine and resubmit.
Comment #2
Dries CreditAttribution: Dries commentedComment #3
Matt_T_hat CreditAttribution: Matt_T_hat commentedNo doubt I've just irritated some one but after spending the day finding out how to run diff/patch on win32 and getting that done - guess what!
That's right the form for OPML is tantalisingly there and yet it is beyond me to get it to anything (like submit). The browse button gets the page to hang for a few moments but that is all.
Comment #4
robertDouglass CreditAttribution: robertDouglass commentedWould be nice if someone could revive this code.
Comment #5
Matt_T_hat CreditAttribution: Matt_T_hat commentedA-Ha! I got it to work.
The OPML list must have been downloaded and can then be uploaded (via browse) and then it will work. Very well.
Comment #6
arnabdotorg CreditAttribution: arnabdotorg commentedToo lazy|busy to handle this, it would be nice to see this come through.
Comment #7
Robin Monks CreditAttribution: Robin Monks commentedI'm cleaning this up now, here is what I've got so far:
- Now Uses drupal_xml_phraser_create
- Applies Aganist HEAD
- Some Sorry's removed.
To be done:
- Conform to coding style
- Don't give error on existing entry
- Fix form error code
Robin
Comment #8
Robin Monks CreditAttribution: Robin Monks commentedI haven't given up, it's just taking a while.
Robin
Comment #9
Uwe Hermann CreditAttribution: Uwe Hermann commentedI have rerolled the patch, it applies more cleanly to HEAD now. Also, I fixed a bug (I think),
$feed['TITLE']
should have been$feed['TEXT']
, right? The patch as is works for me. Please lets try to get this into 4.7.Comment #10
Uwe Hermann CreditAttribution: Uwe Hermann commentedForgot the patch.
Comment #11
Robin Monks CreditAttribution: Robin Monks commentedPlease make sure this patch checks that the site is not already listed in the .
Also, please reassign this patch to yourself.
Robin
Comment #12
Uwe Hermann CreditAttribution: Uwe Hermann commented"not listed in the ......"? What is missing?
Comment #13
Prometheus6 CreditAttribution: Prometheus6 commentedI think he's talking about this:
Comment #14
drummNo longer applies.
Comment #15
dayre CreditAttribution: dayre commentedNot a lot of activity on this lately. I'm looking for OPML import functionality for a project i'm working on. The state was changed to "patch (code needs work)" with the last statement by drumm being "No longer applies.".
What no longer applies ? What work still needs to be done with this ? If Uwe doesn't have time, i might as well pick this up, a small TODO list would be helpful too.
Comment #16
Boris Mann CreditAttribution: Boris Mann commentedDavid -- this means the patch no longer applies to HEAD. Generally, we prepare patches for that, and then "backport" to the current release. This is a feature, so it may no longer get into 5.0, but shouldn't be too many variants.
The "To Do's" seem to be:
* Conform to coding style
* Don't give error on existing entry
* Fix form error code
Comment #17
Egon Bianchet CreditAttribution: Egon Bianchet commentedSubscribing ...
Comment #18
Egon Bianchet CreditAttribution: Egon Bianchet commentedMaybe in Drupal 6? ;-)
Comment #19
buddaThanks to the original patch XML processing code, I've just worked OPML import/export functionality in to FeedParser for 4.7.
Comment #20
PanchoMove this to the D7 queue.
Comment #21
cburschkaUgh. This is 4.6.x code - form_file(), form_submit(), etc. It will be fun to get it up to date.
Comment #22
cburschka... and by fun, I apparently mean easy. Seriously, that was all?
I'm pretty sure that the XML parsing is not up to Drupal standards, however.
The attached prototype patch allows both a local file upload and a remote URL (to be downloaded only once). It does not properly validate, however, and it also does not protect against duplicates.
It works like a charm, though - I imported ~400 feeds from a single OPML file to test. It uses drupal_execute to programmatically submit the feed addition form for each feed in the file.
TODO:
- Protect against those duplicate key inserts by checking for duplicate items.
- Validate the file, make sure that at least one of the two (upload or remote URL) are entered
- Make sure that the XML parsing does not go against ordinary Drupal style
Comment #23
cburschkaThe new patch checks for duplicates before adding.
Comment #24
Robin Monks CreditAttribution: Robin Monks commentedAside from the dupe checking, this worked great!
Robin
Comment #25
Robin Monks CreditAttribution: Robin Monks commentedPlease note, in the previous post I tested Patch #22.
Robin
Comment #26
cburschkaMh... could you also test #23, then? :)
Comment #27
cburschkaHere is a new patch.
Comment #28
cburschkaForgot to add: The patch renames some variables, validates that the user either enters a URL or uploads a file, and improves error handling. An OPML outline can be valid without containing anx XML feeds, which will be reflected in the messages.
I have been able to add 208 feeds in one go with this patch in HEAD.
Comment #29
Alex UA CreditAttribution: Alex UA commentedI tried this patch on my local machine (XP runnign XAMP) and I received the following error:
Comment #30
cburschkaIn Drupal 7, you need to rebuild the code registry if a new form is added. Disable and re-enable the aggregator module.
Comment #31
Alex UA CreditAttribution: Alex UA commentedThat worked, thanks! This is a really great feature- I hope it makes it into this release...
Comment #32
Dries CreditAttribution: Dries commentedI think this looks good. I've tested the patch and managed to import ~200 feeds in one swoop. Very nice.
A couple of requests though:
- There are a couple of coding style violations but nothing I can't fix when committing this patch. I'd recommend that we run it through the coder module.
- It would be useful if you could add a one paragraph context-sensitive help text on ?q=admin/content/aggregator/add/opml. I bet you that most people are not familiar with OPML so I think it is important to clue them in. The help text can be short and to the point.
- I'd really like to see us ship some tests with this. Do you think you can write a couple of SimpleTests? It would make this patch fly straight in. :-)
Thanks!
Comment #33
cburschkaI think I've managed to get all the code-style issues. The D6 coder is unfortunately a bit hit-and-miss there - it has the old concatenation policy.
Also, there's some help text:
There are some other changes:
- renamed _aggregator_parse_opml to _aggregator_parse_opml_feeds to clarify that the function specifically extracts newsfeeds (OPML can contain much more data than that)
- doxygen on _aggregator_parse_opml_feeds
- added an "or" between the upload and URL fields to mark them as alternative
- if no categories are created yet, note that all imported feeds could be added to the same category (it's annoying to find this out later, because afterward they have to be classified manually)
- got rid of the fallback method of prepending
<?xml version="1.0" ?>
. Seems like the parser works without this line now (perhaps PHP5 only? But D7 is PHP5+ anyway).The only thing remaining are the simpletests. I've never worked with unit tests before, so I'll need to learn a bit.
I assume these tests will be a single OPML test case. I'll open the form, submit it empty, with an uploaded file and with a URL, check that all feeds get added, and make sure that duplicates are removed. Would that be all?
Here's the patch with everything but the tests.
Comment #34
keith.smith CreditAttribution: keith.smith commentedEverywhere else (AFAIK) we just refer to feeds (rather than newsfeeds).
If its a URL it kinda' implies that it exists on the web. Is the second part true or is is downloaded every time this form is submitted?
Thanks for following the D6 precedent on the cron maintenance task stuff!
This is the other example of "news items" in one place and "feed items" in another.
I'm uncertain on the tense of this one but it seems like it would be "If you have created any..." or just "Imported feeds can be assigned to categories."
Needs a period at the end.
url -> URL
I'm not sure we use acronym anywhere else but I like it. There is a "to to" in here. Again, it talks about news feeds rather than just feeds.
Regardless of these minor style issues, I like OPML a lot!
Comment #35
cburschkaI've fixed "newsfeeds" in 1) and the redundancy/ambiguity in 2).
4) merely repeats text from the normal feed addition form, so I suggest either fixing that now, or both after this is added, but in a separate patch either way. That would be a pretty large-scale issue, incidentally:
Clarified the description for 5) (it's specifically advising the user to create categories before importing the feeds, because this is the one time that >200 feeds can be mass-categorized) and also added some more detail to the doxygen description besides a period in 6).
7) I'm not sure about 'URL' vs 'url' in the doxygen. Note that we're talking about a literal key in an array, ie
$item['url']
, not$item['URL']
. I've emphasized these literals to make that more clear.8) "to to" and "newsfeeds" fixed.
Comment #36
Dries CreditAttribution: Dries commentedThe only thing remaining are the simpletests. I've never worked with unit tests before, so I'll need to learn a bit. I assume these tests will be a single OPML test case. I'll open the form, submit it empty, with an uploaded file and with a URL, check that all feeds get added, and make sure that duplicates are removed. Would that be all?
That's correct. The goal of the test cases is to make sure that all of the functionality works, and that all of the functionality keeps working going forward. You've written enough tests for it, when they give you that level of confidence. Writing tests is fun -- I really encourage you to give it a try.
Comment #37
keith.smith CreditAttribution: keith.smith commentedGood note, which led me to do the same grep (the last one) without the wc -l
'news items' occurs
I'm happy to roll a patch for 2, 3, 4, 5, and 6, but there really aren't that many instances of this in user-facing text now, once the instances are fixed in this patch. There is also the permission which is now arguably misnamed but that certainly is another issue.
Regarding the current patch, exit should be exist. Other than that, everything else looks good on a quick read-through.
Comment #38
cburschkaI'm not quite up to the kind of empirical coding required to make a new test case, I'm afraid. I've made the tests and managed to get some of them to work. But for some reason, the tests started consistently crashing, and all HTTP requests started returning 0-length responses after the first few succeeded. Here's my test class; perhaps a few errors can be pointed out.
[test class edited out as it is now in the patch below]
Comment #39
cburschkaAfter hours of work, I'm beginning to get convinced that the fatal error is a fault of simpletest. Here's the patch, and I'm done debugging that test case. :(
Comment #40
catchI don't get the fatal error when runing simpletest.
Looks to me like the example OPML files should be created by the patch in /modules/aggregator somewhere instead of in the patch itself (save those /tmp errors).
Comment #41
cburschkaThe content of the sample OPML files are generated dynamically, including random names. Besides, the only reason the file_save_data fails is that I forgot the TRUE in the file_check_directory above, which means the folder is not created.
I still can't get the tests to run, but the file saving errors are gone.
Comment #42
catchThis takes me down to 8 fails and 1 exception - tests run fine for me still (and no file_save_data errors this time).
First error is
POST to admin/content/aggregator/add/opml, response is 0 bytes.
Likely that's the cause of the others. No immediate ideas why it's failing though.
Comment #43
cburschkaInterestingly, that is the same part that is failing for me - only it's more than one request. I can only speculate whether the curl timeout is set too low.
Comment #44
Dries CreditAttribution: Dries commentedFor me, the tests come to halt when running them. Is that the behavior you are seeing?
Comment #45
catchTests run all the way though for me (with above failures) - this on ubuntu.
Comment #46
cburschkaYes, the batch operation fails after about five minutes with a HTTP 500 error. The test does not run through.
If this is a timeout issue, perhaps I can fix it by dividing the test case up into two classes. After all, every class runs through in one batch step.
Comment #47
Dries CreditAttribution: Dries commentedArancayter, I don't think a single test should run for 5 minutes. I means something is broken. Time-permitting, I'll try to install xdebug (on MAMP) to see where the time is spent or where we are being blocked. If someone beats me to it, great. I'd really like to see this patch land.
Thanks for your persistence and your willingness to learn SimpleTest.
Comment #48
cburschkaWell, I started splitting he test case up anyway to narrow down the problem, and found the request that causes the test to crash:
Commenting out the POST will let this function finish normally. There are a lot of failures, but the test runs.
I'm wondering if an empty post array may be the culprit. I could submit another non-required field to make sure something is being sent...
Edit: Even after removing this, I'm still getting 0-length curl responses. However, I tend to get those on other tests in core, so it's possible that that's an issue on my server only.
I would really love it if drupal_http_request could take over the request handling in SimpleTest. Perhaps it's because I use PHP as CGI, but curl is pretty unusable on my site.
Comment #49
catchI'm sure there's plenty of tests with empty post arrays already, so it shouldn't be that. I get weird issues with drupalPost sometimes, but they're hard to pin down, and I don't seem to get this specific one.
Comment #50
mustafau CreditAttribution: mustafau commentedUpdated the patch.
Simplified some of the code in aggregator.admin.inc.
Refactored tests. There are two test cases and both are successful now.
Comment #51
mustafau CreditAttribution: mustafau commentedSmall improvements over the last patch.
Test cases merged.
XML parser now calls xml_parser_free().
Comment #52
Dries CreditAttribution: Dries commentedWith the latest patch, the tests no longer come to halt. However, there is a notice: "Undefined variable: cat_title".
Note that we don't abbreviate words in Drupal code -- 'cat' should probably be 'category' unless you mean a 'cat'? ;-) Same with '$res'.
Some messages are too cryptic (i.e. ''Category field if categories exist.'). It would be great if we could make these a bit more human-friendly.
Is 'NATURAL JOIN' ANSI SQL? Will it work on PostgreSQL?
url='%s'
should beurl = '%s'
(spaces).We don't capitalize each word in a sentence (i.e. ""Test Category" should be "Test category").
Comment #53
mustafau CreditAttribution: mustafau commentedUpdated.
"Category field if categories exist." is now "Looking for category field."
I am using PostgreSQL and NATURAL JOIN did work. Anyway I have changed it to "LEFT JOIN".
Comment #54
Dries CreditAttribution: Dries commentedLooks good and the tests pass. Committed to CVS HEAD. Thanks.
Comment #55
mustafau CreditAttribution: mustafau commentedI have added a redirect destination to the OPML import form and made small improvements to the code.
Comment #56
mustafau CreditAttribution: mustafau commentedWe should validate URLs too.
Comment #57
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
Comment #58
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.