[SPIP Zone] [SPIP 3.1 + Accès Restreint] Erreur SQL pour l'ajout d'une Zone depuis la page d'un auteur

Bonjour,

En version SVN de partout :wink:
Page ecrire/?exec=auteur&id_auteur=1
Je clique sur Ajouter une Zone et j'ai ceci :
Erreur SQL 1052
Column 'titre' in field list is ambiguous
SELECT zones.id_zone, 0 as points, (TRIM(IF(INSTR(titre, '<multi>') = 0 , TRIM(titre), CONCAT( LEFT(titre, INSTR(titre, '<multi>')-1), IF( IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4) = 0, TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))), IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1,INSTR(titre, '</multi>') -(INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1) )), '[')>0,LEFT(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1,INSTR(titre, '</multi>') -(INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1) )),INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1,INSTR(titre, '</multi>') -(INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1) )), '[')-1),TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1,INSTR(titre, '</multi>') -(INSTR(titre, '<multi>')+7+IF(INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')=0,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),']')+1,INSTR(TRIM(SUBSTRING(titre, INSTR(titre, '<multi>')+7, INSTR(titre, '</multi>') -(7+INSTR(titre, '<multi>')))),'[fr]')+4)-1) ))) ), RIGHT(titre, CHAR_LENGTH(titre) -(7+INSTR(titre, '</multi>'))) ) ))) AS multi, zones.titre AS titre_rang, zones.titre, zones.publique, zones.privee, L1.objet, L1.id_objet FROM spip_zones AS `zones` INNER JOIN spip_forum AS L1 ON ( L1.id_objet = zones.id_zone AND L1.objet='zone') WHERE NOT(((zones.id_zone IN (1)))) GROUP BY zones.id_zone ORDER BY multi

/ecrire/public/composer.php calculer_select(){ sql_select(); } 914

--
RealET

Le 21/07/2015 18:05, RealET a écrit :

Bonjour,

En version SVN de partout :wink:
Page ecrire/?exec=auteur&id_auteur=1
Je clique sur Ajouter une Zone et j'ai ceci :

Après analyse, c'est la boucle qui plante en faisant une jointure sur spip_forum au lieu de spip_zones_liens pour choper objet et id_objet (dans prive/objets/liste/zones_associer).

<BOUCLE_liste_aut(ZONES){!id_zone IN #GET{exclus}}{tout}{where?}{recherche?}{statut?}{tri #ENV{par,multi titre},#GET{defaut_tri}}{pagination #ENV{nb,10} zonea}>
  ... #OBJET #ID_OBJET ...

Sous sqlite, ça provoque la même erreur (mais la requête est plus simple)
SELECT
  zones.id_zone,
  0 as points,
  EXTRAIRE_MULTI(titre, 'fr') AS multi,
  zones.titre AS titre_rang,
  zones.titre,
  zones.publique,
  zones.privee,
  L1.objet,
  L1.id_objet
FROM
  spip_zones AS 'zones'
INNER JOIN
  spip_forum AS L1
  ON ( L1.id_objet = zones.id_zone AND L1.objet='zone')
WHERE NOT(((zones.id_zone IN (1))))
GROUP BY zones.id_zone ORDER BY multi

Ce que je ne pige pas c'est que la boucle suivante (dans prive/objets/liste/zones_lier) ne fait pas de jointure du tout et prend #OBJET et #ID_OBJET dans l'environnement du squelette.

<BOUCLE_liste_zone(ZONES){id_zone IN #GET{selection}}{where?}{tri #ENV{par,titre},#GET{defaut_tri}}{par multi titre}{pagination #ENV{nb,10} zonel}>
... #OBJET #ID_OBJET ...

Mes 2 sous.

Je me demande si c'est pas un problème dans SPIP directement, suite à des modification des calculs de jointures.

MM.

Le 22/07/2015 15:34, Matthieu Marcillaud a écrit :

Je me demande si c'est pas un problème dans SPIP directement, suite à
des modification des calculs de jointures.

Effectivement, il y a plusieurs choses.

Le dépot champ_sql cherchait le champ dans les jointures explicites, mais ne... (803f3c35) · Validations · spip / spip · GitLab permet dans la boucle de trouver une jointure (avec spip_forum) pour afficher #OBJET et #ID_OBJET alors qu'avant cela n'était pas le cas.

Et c'est la présence du critère {statut?} qui provoque l'accueil de cette jointure possible, car ce champ n'est pas présent dans spip_zones.

J'ai corrigé du coup.

Il y avait un autre bug qui empêchait de lier et délier.

MM.