/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
- * Copyright (c) 2001-2012 *
+ * Copyright (c) 2001-2014 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
if (!$desc = $trouver_table($ancienne_table))
return;
+ // securite pour ne pas perdre de donnees
+ if (!$trouver_table($liens))
+ return;
+
$champs = $desc['field'];
if (isset($champs['maj'])) unset($champs['maj']);
if (isset($champs[$primary])) unset($champs[$primary]);
$champs = array_keys($champs);
+ // ne garder que les champs qui existent sur la table destination
+ if ($desc_cible = $trouver_table($liens)){
+ $champs = array_intersect($champs,array_keys($desc_cible['field']));
+ }
+
$champs[] = "$primary as id_objet";
$champs[] = "'$objet' as objet";
$champs = implode(', ',$champs);