As I posted my original feature request 2362333 in the wrong group at first, I guess that nobody over here noticed it when I moved it over. So – let's try to give this a little poke so perhaps someone will see it.
The long version can still be found over there. (UPDATE: I don't seem to be able to attach that issue as a related one. *headscratch*) The patch file also works on the latest 7.x-2.0-alpha8, I've re-attached it to this ticket.
What it does is: It sorts the list of feed importers by their readable names – which, compared to the machine name, can be changed to provoke a different feed list sort order. I am working on a huge database migration with about 30 feeds that need to be performed one by on in the correct order. This helps a lot.
It's really just one line of code in feeds.module, and it greatly increases clarity.
UPDATE:
Just for clarification, as twistor mentioned it: This is only about the sort order on the feeds overview page ./admin/structure/feeds and the manual import page ./import. It does not define a weight or a processing order – it's really just about having the feeds sorted alphanumerically by their visual names instead of by their internal machine name (which can't be changed later).
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | interdiff-2385601-17-18.txt | 1.33 KB | megachriz |
| #18 | feeds-sort-importers-by-name-2385601-18.patch | 832 bytes | megachriz |
| #17 | feeds-sorting_feed_importers_by_readable_names-2385601-16.patch | 1009 bytes | jerenus |
| #14 | feeds.module_sorted-list_7.x-2.x-dev_2014-Dec-23.patch | 820 bytes | GerZah |
| feeds.module_sorted-list.patch | 613 bytes | GerZah |
Comments
Comment #1
GerZah commentedComment #3
megachrizMarked #2362333: Sorting feed importers by readable names, not by machine names as a duplicate.
Comment #4
GerZah commentedThanks, MegaChriz.
I'm apparently too stupid to create a patch file – at least one that suffices the requirements for automatic patching. I'm sorry, I'm not so versed with git, I simply modified my original version of feeds.module and created a diff between the original version and mine. Rest assured, the patch applies nicely to the 7.x-2.0-alpha8 version of feeds.module.
Comment #5
megachriz@GerZah
I don't think you are stupid. Patches just sometimes fail tests. Even patches from the Drupal core maintainers sometimes fail tests.
I 'm changing the version to 7.x-2.x-dev, because patches for feature requests should always be tested against dev. I will trigger a re-test after that as at first glance the failing tests ("Undefined index: content-type") seem unrelated.
Comment #7
GerZah commentedNo – I said that I was too stupid to submit a working patch. ;-) I see that the patch now went through just fine. Thank you very much!
Comment #8
twistor commentedWe can't use anonymous functions since we depend on PHP >= 5.2.
Also, the strval() call is unnecessary.
Sorting the list by name is fine, I'm not sure how multi-byte characters will work.
That said, I'm not sure if this is the best idea. Feeds doesn't offer any guarantees about the order that importers execute. If you update an importer, it's possible that it will reschedule the feeds, and that would put things out of sync.
I've worked on this before, but I don't think I ever released any code. The idea is to mark importers as dependent on another importer, and have the parent importer be the one that is scheduled. That would ensure that they run in the correct order, but then that would only work for the standalone importer.
Comment #9
megachriz@GerZah
If you know your way in object orientated code, you could also take a look at the Migrate module, which is designed especially for migrations and has good dependency handling (in the sense of one migration depends on an other). It takes some effort to grasp though and it usually takes longer to setup as you need to define the migrations and mapping in code (there are also some UI modules available to simplify the process, but I haven't tried these yet).
Comment #10
GerZah commented@twistor:
@MegaChriz: Thanks for the suggestion. I'm far too far down the road to switch from feeds to migrate at this point. :)
Comment #11
GerZah commentedComment #12
GerZah commentedOK – there we go:
Better? ... This works for me with 7.x-2.x-dev / 2014-Dec-23.
Comment #13
GerZah commentedComment #14
GerZah commentedErrm.
Sorry, don't mind #12. Breaks due to (possible) re-definition. Bummer!
Try this one here in #14, please.
Comment #15
GerZah commentedComment #16
jerenus commentedPass the testing. Reroll the patch and add some comments. Look forward to this function to be committed.
Comment #17
jerenus commentedComment #18
megachrizThanks for the patch, GerZah and Jerenus.
I've expanded the function documentation a bit and also moved the
uasort()call to the place were all feeds importers are loaded. This ensures that we can expect FeedsImporter objects infeeds_importer_name_sort().Comment #20
megachrizCommitted #18. Thanks all!