diff --git a/ecrire/inc/syndic.php b/ecrire/inc/syndic.php index 37672fb9b704419ba816a32334195db5e008ad6b..5126166382084288f0c55bf37c40185e69a67bb5 100644 --- a/ecrire/inc/syndic.php +++ b/ecrire/inc/syndic.php @@ -378,13 +378,29 @@ function analyser_backend($rss, $url_syndic='') { // // http://doc.spip.org/@inserer_article_syndique function inserer_article_syndique ($data, $now_id_syndic, $statut, $url_site, $url_syndic, $resume, $documents) { - // Creer le lien s'il est nouveau - cle=(id_syndic,url) + // On coupe a 255 caracteres pour eviter tout doublon sur une URL de plus de 255 qui + // exloserait la base de donnees $le_lien = substr($data['url'], 0,255); - $n = spip_num_rows(spip_query("SELECT * FROM spip_syndic_articles WHERE url=" . _q($le_lien) . " AND id_syndic=$now_id_syndic")); - if ($n == 0 and !spip_sql_error()) { - spip_query("INSERT INTO spip_syndic_articles (id_syndic, url, date, statut) VALUES ('$now_id_syndic', " . _q($le_lien) . ", FROM_UNIXTIME(".$data['date']."), '$statut')"); - $ajout = true; + + // Si le site a des liens vides, il faut ruser : essayer de mettre a jour les liens + // vides existants, puis supprimer ceux qui restent + if (!strlen($le_lien)) { + $nettoyage_vides[$now_id_syndic]++; + $le_lien = '#'.$compteur[$now_id_syndic]; + } + + $s = spip_query("SELECT * FROM spip_syndic_articles WHERE url=" . _q($le_lien) . " AND id_syndic=$now_id_syndic ORDER BY maj LIMIT 0,1"); + if ($a = spip_fetch_array($s)) { + $id_syndic_article = $a['id_syndic_article']; + } else { + if (spip_sql_error()) { + return; + } else { + include_spip('base/abstract_sql'); + $id_syndic_article = spip_abstract_insert('spip_syndic_articles', '(id_syndic, url, date, statut)', '('._q($now_id_syndic).', '._q($le_lien). ', FROM_UNIXTIME('.$data['date'].'), '._q($statut).')'); + $ajout = true; + } } // Descriptif, en mode resume ou mode 'full text' @@ -421,7 +437,7 @@ function inserer_article_syndique ($data, $now_id_syndic, $statut, $url_site, $u } // Mise a jour du contenu (titre,auteurs,description,date?,source...) - spip_query("UPDATE spip_syndic_articles SET titre=" . _q($data['titre']) . ", ".$update_date." lesauteurs=" . _q($data['lesauteurs']) . ", descriptif=" . _q($desc) . ", lang="._q(substr($data['lang'],0,10)).", source="._q(substr($data['source'],0,255)).", url_source="._q(substr($data['url_source'],0,255)).", tags=" . _q($tags) . " WHERE id_syndic='$now_id_syndic' AND url=" . _q($le_lien)); + spip_query("UPDATE spip_syndic_articles SET titre=" . _q($data['titre']) . ", ".$update_date." lesauteurs=" . _q($data['lesauteurs']) . ", descriptif=" . _q($desc) . ", lang="._q(substr($data['lang'],0,10)).", source="._q(substr($data['source'],0,255)).", url_source="._q(substr($data['url_source'],0,255)).", tags=" . _q($tags) . " WHERE id_syndic_article=$id_syndic_article"); // Point d'entree post_syndication pipeline('post_syndication', diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php index 68a2fe77ada7a10ac9b1e1c2325cbe559ddbfece..231e978fee7fad4b9fba87c2c2bcbb436af2d14f 100644 --- a/ecrire/public/compiler.php +++ b/ecrire/public/compiler.php @@ -288,10 +288,6 @@ function calculer_boucle_nonrec($id_boucle, &$boucles) { // http://doc.spip.org/@calculer_requete_sql function calculer_requete_sql(&$boucle) { - if (!$order = $boucle->order - AND !$order = $boucle->default_order) - $order = array(); - return ($boucle->hierarchie ? "\n\t$boucle->hierarchie" : '') . $boucle->in . $boucle->hash . @@ -360,7 +356,10 @@ function calculer_from(&$boucle) // http://doc.spip.org/@calculer_order function calculer_order(&$boucle) { - $order = $boucle->order; + if (!$order = $boucle->order + AND !$order = $boucle->default_order) + $order = array(); + /*if (isset($boucle->modificateur['collate'])){ $col = "." . $boucle->modificateur['collate']; foreach($order as $k=>$o)