From 0014e6e94d2851bcc03ed6231805efee6c7ac1b5 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Fri, 18 Jan 2008 10:59:25 +0000 Subject: [PATCH] =?UTF-8?q?Elimination=20de=20la=20table=20principale=20de?= =?UTF-8?q?=20la=20boucle=20de=20[11091]:=20traitement=20particulier=20de?= =?UTF-8?q?=20la=20boucle=20Document=20dont=20la=20"table=20principale"=20?= =?UTF-8?q?a=20une=20jointure=20d'office.=20Toujours=20le=20m=C3=AAme=20fi?= =?UTF-8?q?chier=20=C3=A0=20contr=C3=B4ler=20pour=20SQLite.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scorie de [11089] qui empêchait contenu_document de fonctionner dans un cas. --- ecrire/inc/distant.php | 3 ++- ecrire/public/boucles.php | 7 +++---- ecrire/public/composer.php | 2 +- ecrire/req/mysql.php | 10 ++++++++-- ecrire/req/pg.php | 9 ++++++++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index 05f989fdb5..5c82c070af 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -312,10 +312,11 @@ function fichier_copie_locale($source) { } // Ping pour voir si son extension est connue et autorisee $path_parts = recuperer_infos_distantes($source,0,false) ; - $ext = $path_part ? $path_parts['extension'] : ''; + $ext = $path_parts ? $path_parts['extension'] : ''; if ($ext AND sql_getfetsel("extension", "spip_types_documents", "extension=".sql_quote($ext))) { return nom_fichier_copie_locale($source, $ext); } + spip_log("pas de copie locale pour $source"); } diff --git a/ecrire/public/boucles.php b/ecrire/public/boucles.php index a07c766582..e8bb2cbb11 100644 --- a/ecrire/public/boucles.php +++ b/ecrire/public/boucles.php @@ -178,10 +178,9 @@ function boucle_DOCUMENTS_dist($id_boucle, &$boucles) { AND !$boucle->modificateur['criteres']['id_rubrique'] AND !$boucle->modificateur['criteres']['id_document'] ) { - # pallier un defaut du compilo sur le AS qui se met a la fin - unset($boucle->from[$id_table]); - $boucle->from[] = "spip_documents AS `${id_table}` - LEFT JOIN spip_documents_articles AS a + # Espace avant LEFT JOIN indispensable pour insertion de AS + # a refaire plus proprement + $boucle->from[$id_table] = "spip_documents LEFT JOIN spip_documents_articles AS a ON `$id_table`.id_document=a.id_document LEFT JOIN spip_articles AS aa ON a.id_article=aa.id_article diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php index a18d5331eb..65a7a18ec2 100644 --- a/ecrire/public/composer.php +++ b/ecrire/public/composer.php @@ -518,6 +518,7 @@ function calculer_select ($select = array(), $from = array(), reset($from); $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/'; if (!( count($equiv) <> 1 OR // a faire sauter un jour + strpos($t, ' ') OR // jointure des le depart cf boucle_doc calculer_jointnul($t, $select, $e) OR calculer_jointnul($t, $join, $e) OR calculer_jointnul($t, $where, $e) OR @@ -533,7 +534,6 @@ function calculer_select ($select = array(), $from = array(), $where = remplacer_jointnul($t, $where, $e); $having = remplacer_jointnul($t, $having, $e); } - $from[-1] = $sfrom; } diff --git a/ecrire/req/mysql.php b/ecrire/req/mysql.php index 4cfaad3a2d..740f925251 100644 --- a/ecrire/req/mysql.php +++ b/ecrire/req/mysql.php @@ -239,8 +239,14 @@ function spip_mysql_select_as($args) } else $join =''; $res = ''; foreach($args as $k => $v) { - $res .= ', ' . $v . (is_numeric($k) ? '' : " AS `$k`") . $join; - $join = ''; + if (!is_numeric($k)) { + $p = strpos($v, " "); + if ($p) + $v = substr($v,0,$p) . " AS `$k`" . substr($v,$p); + else $v .= " AS `$k`"; + } + + $res .= ', ' . $v ; } return substr($res,2) . $join; } diff --git a/ecrire/req/pg.php b/ecrire/req/pg.php index 760877c431..2a7b2a73bc 100644 --- a/ecrire/req/pg.php +++ b/ecrire/req/pg.php @@ -488,11 +488,18 @@ function spip_pg_select_as($args) $argsas = ""; foreach($args as $k => $v) { $as = ''; + spip_log("$k : $v"); if (!is_numeric($k)) { if (preg_match('/\.(.*)$/', $k, $r)) $v = $k; - elseif ($v != $k) $as = " AS $k"; + elseif ($v != $k) { + $p = strpos($v, " "); + if ($p) + $v = substr($v,0,$p) . " AS $k" . substr($v,$p); + else $as = " AS $k"; + } } + spip_log("subs $k : $v avec $as"); if (strpos($v, 'JOIN') === false) $argsas .= ', '; $argsas .= $v . $as; } -- GitLab