Better OPML import of feeds in multiple categories (#3286)

#fix https://github.com/FreshRSS/FreshRSS/issues/3284
Helps https://github.com/FreshRSS/FreshRSS/issues/1989

In OPMLs files in which feeds are listed several times, favour the
version in a category instead of in no category.
This commit is contained in:
Alexandre Alapetite
2020-12-26 17:23:23 +01:00
committed by GitHub
parent 4abb30228b
commit 4f74215199

View File

@@ -251,6 +251,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$nb_cats = count($this->catDAO->listCategories(false));
$limits = FreshRSS_Context::$system_conf->limits;
//Sort with categories first
usort($opml_elements, function ($a, $b) {
return strcmp(
(isset($a['xmlUrl']) ? 'Z' : 'A') . $a['text'],
(isset($b['xmlUrl']) ? 'Z' : 'A') . $b['text']);
});
foreach ($opml_elements as $elt) {
if (isset($elt['xmlUrl'])) {
// If xmlUrl exists, it means it is a feed