From e34e41ddead284d62dc59ebec58fd0b6325e0b86 Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Sun, 25 Jul 2004 08:49:23 +0000 Subject: [PATCH] *EXPOSER moins gourmand * bug '' sur la clause GROUP BY (Yves Grenier, ced.) --- inc-arg-squel.php3 | 6 +++--- inc-calcul_mysql3.php | 31 ++++++++++++++----------------- inc-reqsql-squel.php3 | 4 ++-- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/inc-arg-squel.php3 b/inc-arg-squel.php3 index 2629e7166e..1c760274a6 100644 --- a/inc-arg-squel.php3 +++ b/inc-arg-squel.php3 @@ -57,7 +57,7 @@ function calculer_params($type, $params, $idb, &$boucles) { calcul_branche($hash_recherche_strict),"") . ")) AS points'; $boucle->where[] = "rec.". $table_primary[$type] . "=$id_field"; - $boucle->group = "'$id_field'"; + $boucle->group = $id_field; $boucle->where[] = '" .' . 'calcul_mysql_in("rec.hash", calcul_branche($hash_recherche),"") . "'; $boucles[$idb]->hash = true; @@ -142,7 +142,7 @@ function calculer_params($type, $params, $idb, &$boucles) { $col_table = $s; $boucle->from[] = "$col_table AS $col_table"; $boucle->where[] = "$id_field=$col_table." . $table_primary[$type]; - $boucle->group = "'$id_field'"; + $boucle->group = $id_field; $boucle->lien = true; } // Cas particulier pour les raccourcis 'type_mot' et 'titre_mot' @@ -159,7 +159,7 @@ function calculer_params($type, $params, $idb, &$boucles) { $boucle->from[] = 'mots AS mots'; $boucle->where[] = "$id_field=lien_mot." . $table_primary[$type]; $boucle->where[] = 'lien_mot.id_mot=mots.id_mot'; - $boucle->group = "'$id_field'"; + $boucle->group = $id_field; $col_table = 'mots'; $boucle->lien = true; diff --git a/inc-calcul_mysql3.php b/inc-calcul_mysql3.php index 98ef815720..766f4ef71e 100644 --- a/inc-calcul_mysql3.php +++ b/inc-calcul_mysql3.php @@ -133,10 +133,10 @@ function calcul_mysql_in($val, $valeurs, $tobeornotobe) function calcul_exposer ($pile, $reference) { static $hierarchie; + static $ref_precedente; - $md5 = md5(serialize($reference)); - - if (!$hierarchie[$md5]) { + if ($reference<>$ref_precedente) { + $ref_precedente = $reference; if ($id = $reference['id_article']) $base = 'articles'; else if ($id = $reference['id_breve']) @@ -148,42 +148,39 @@ function calcul_exposer ($pile, $reference) { else if ($id = $reference['id_secteur']) $base = 'rubriques'; - if (!$base) - $hierarchie[$md5] = '-'; - else { + unset ($hierarchie); + if ($base) { if ($base != 'rubriques') { - $hierarchie[$md5][$base][$id] = true; + $hierarchie[$base][$id] = true; $id_element = 'id_'.ereg_replace('s$', '', $base); $s = spip_fetch_array(spip_query( "SELECT id_rubrique FROM spip_$base WHERE $id_element=$id")); $id = $s['id_rubrique']; } - $hierarchie[$md5]['rubriques'][$id] = true; + $hierarchie['rubriques'][$id] = true; while (true) { $s = spip_fetch_array(spip_query( "SELECT id_parent FROM spip_rubriques WHERE id_rubrique=$id")); if ($id = $s['id_parent']) - $hierarchie[$md5]['rubriques'][$id] = true; + $hierarchie['rubriques'][$id] = true; else break; } } } - if ($hierarchie[$md5] == '-') - return false; - else if ($id = $pile['id_article']) - return $hierarchie[$md5]['articles'][$id]; + if ($id = $pile['id_article']) + return $hierarchie['articles'][$id]; else if ($id = $pile['id_breve']) - return $hierarchie[$md5]['breves'][$id]; + return $hierarchie['breves'][$id]; else if ($id = $pile['id_syndic']) - return $hierarchie[$md5]['syndic'][$id]; + return $hierarchie['syndic'][$id]; else if ($id = $pile['id_rubrique']) - return $hierarchie[$md5]['rubriques'][$id]; + return $hierarchie['rubriques'][$id]; else if ($id = $pile['id_secteur']) - return $hierarchie[$md5]['rubriques'][$id]; + return $hierarchie['rubriques'][$id]; } diff --git a/inc-reqsql-squel.php3 b/inc-reqsql-squel.php3 index badcc11cee..0c49932857 100644 --- a/inc-reqsql-squel.php3 +++ b/inc-reqsql-squel.php3 @@ -32,7 +32,7 @@ function calculer_requete(&$boucle) { $boucle->where[] = "lien.id_auteur=$id_table.id_auteur"; $boucle->where[] = 'lien.id_article=articles.id_article'; $boucle->where[] = "articles.statut='publie'"; - $boucle->group = "'$id_field'"; + $boucle->group = "$id_field"; } // pas d'auteurs poubellises $boucle->where[] = "NOT($id_table.statut='5poubelle')"; @@ -60,7 +60,7 @@ function calculer_requete(&$boucle) { $boucle->where[] = "petitions.id_article=articles.id_article"; $boucle->where[] = "petitions.id_article=$id_table.id_article"; $boucle->where[] = "$id_table.statut='publie'"; - $boucle->group = "'$id_field'"; + $boucle->group = "$id_field"; break; case 'documents': -- GitLab