@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * @return void |
| 31 | 31 | **/ |
| 32 | 32 | function array_set_merge(&$table,$index,$valeur){ |
| 33 | - if (!isset($table[$index])) |
|
| 34 | - $table[$index] = $valeur; |
|
| 35 | - else |
|
| 36 | - $table[$index] = array_merge($table[$index],$valeur); |
|
| 33 | + if (!isset($table[$index])) |
|
| 34 | + $table[$index] = $valeur; |
|
| 35 | + else |
|
| 36 | + $table[$index] = array_merge($table[$index],$valeur); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -50,376 +50,376 @@ discard block |
||
| 50 | 50 | * @return array|bool |
| 51 | 51 | */ |
| 52 | 52 | function lister_tables_objets_sql($table_sql=null, $desc=array()){ |
| 53 | - static $deja_la = false; |
|
| 54 | - static $infos_tables = null; |
|
| 55 | - static $md5 = null; |
|
| 56 | - static $plugin_hash = null; |
|
| 57 | - // prealablement recuperer les tables_principales |
|
| 58 | - if (is_null($infos_tables) |
|
| 59 | - OR $plugin_hash!==_PLUGINS_HASH){ |
|
| 60 | - // pas de reentrance (cas base/serial) |
|
| 61 | - if ($deja_la) { |
|
| 62 | - spip_log ("Re-entrance anormale sur lister_tables_objets_sql :" |
|
| 63 | - . var_export(debug_backtrace(),true),_LOG_CRITIQUE); |
|
| 64 | - return ($table_sql==="::md5"?$md5:array()); |
|
| 65 | - } |
|
| 66 | - $deja_la = true; |
|
| 67 | - $plugin_hash = _PLUGINS_HASH; // avant de lancer les pipelines |
|
| 68 | - |
|
| 69 | - // recuperer les declarations explicites ancienne mode |
|
| 70 | - // qui servent a completer declarer_tables_objets_sql |
|
| 71 | - base_serial($GLOBALS['tables_principales']); |
|
| 72 | - base_auxiliaires($GLOBALS['tables_auxiliaires']); |
|
| 73 | - $infos_tables = array( |
|
| 74 | - 'spip_articles'=> array( |
|
| 75 | - 'page'=>'article', |
|
| 76 | - 'texte_retour' => 'icone_retour_article', |
|
| 77 | - 'texte_modifier' => 'icone_modifier_article', |
|
| 78 | - 'texte_creer' => 'icone_ecrire_article', |
|
| 79 | - 'texte_objets' => 'public:articles', |
|
| 80 | - 'texte_objet' => 'public:article', |
|
| 81 | - 'texte_signale_edition' => 'texte_travail_article', |
|
| 82 | - 'info_aucun_objet'=> 'info_aucun_article', |
|
| 83 | - 'info_1_objet' => 'info_1_article', |
|
| 84 | - 'info_nb_objets' => 'info_nb_articles', |
|
| 85 | - 'texte_logo_objet' => 'logo_article', |
|
| 86 | - 'texte_langue_objet' => 'titre_langue_article', |
|
| 87 | - 'texte_definir_comme_traduction_objet' => 'trad_lier', |
|
| 88 | - 'titre' => 'titre, lang', |
|
| 89 | - 'date' => 'date', |
|
| 90 | - 'principale' => 'oui', |
|
| 91 | - 'champs_editables' => array('surtitre', 'titre', 'soustitre', 'descriptif','nom_site', 'url_site', 'chapo', 'texte', 'ps','virtuel'), |
|
| 92 | - 'champs_versionnes' => array('id_rubrique', 'surtitre', 'titre', 'soustitre', 'jointure_auteurs', 'descriptif', 'nom_site', 'url_site', 'chapo', 'texte', 'ps'), |
|
| 93 | - 'field' => array( |
|
| 94 | - "id_article" => "bigint(21) NOT NULL", |
|
| 95 | - "surtitre" => "text DEFAULT '' NOT NULL", |
|
| 96 | - "titre" => "text DEFAULT '' NOT NULL", |
|
| 97 | - "soustitre" => "text DEFAULT '' NOT NULL", |
|
| 98 | - "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 99 | - "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 100 | - "chapo" => "mediumtext DEFAULT '' NOT NULL", |
|
| 101 | - "texte" => "longtext DEFAULT '' NOT NULL", |
|
| 102 | - "ps" => "mediumtext DEFAULT '' NOT NULL", |
|
| 103 | - "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 104 | - "statut" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 105 | - "id_secteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 106 | - "maj" => "TIMESTAMP", |
|
| 107 | - "export" => "VARCHAR(10) DEFAULT 'oui'", |
|
| 108 | - "date_redac" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 109 | - "visites" => "integer DEFAULT '0' NOT NULL", |
|
| 110 | - "referers" => "integer DEFAULT '0' NOT NULL", |
|
| 111 | - "popularite" => "DOUBLE DEFAULT '0' NOT NULL", |
|
| 112 | - "accepter_forum" => "CHAR(3) DEFAULT '' NOT NULL", |
|
| 113 | - "date_modif" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 114 | - "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 115 | - "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", |
|
| 116 | - "id_trad" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 117 | - "nom_site" => "tinytext DEFAULT '' NOT NULL", |
|
| 118 | - "url_site" => "VARCHAR(255) DEFAULT '' NOT NULL", |
|
| 119 | - "virtuel" => "VARCHAR(255) DEFAULT '' NOT NULL", |
|
| 120 | - ), |
|
| 121 | - 'key' => array( |
|
| 122 | - "PRIMARY KEY" => "id_article", |
|
| 123 | - "KEY id_rubrique" => "id_rubrique", |
|
| 124 | - "KEY id_secteur" => "id_secteur", |
|
| 125 | - "KEY id_trad" => "id_trad", |
|
| 126 | - "KEY lang" => "lang", |
|
| 127 | - "KEY statut" => "statut, date", |
|
| 128 | - ), |
|
| 129 | - 'join' => array( |
|
| 130 | - "id_article"=>"id_article", |
|
| 131 | - "id_rubrique"=>"id_rubrique" |
|
| 132 | - ), |
|
| 133 | - 'rechercher_champs' => array( |
|
| 134 | - 'surtitre' => 5, 'titre' => 8, 'soustitre' => 5, 'chapo' => 3, |
|
| 135 | - 'texte' => 1, 'ps' => 1, 'nom_site' => 1, 'url_site' => 1, |
|
| 136 | - 'descriptif' => 4 |
|
| 137 | - ), |
|
| 138 | - 'rechercher_jointures' => array( |
|
| 139 | - 'auteur' => array('nom' => 10), |
|
| 140 | - ), |
|
| 141 | - 'statut'=> array( |
|
| 142 | - array( |
|
| 143 | - 'champ' => 'statut', |
|
| 144 | - 'publie' => 'publie', |
|
| 145 | - 'previsu' => 'publie,prop,prepa/auteur', |
|
| 146 | - 'post_date' => 'date', |
|
| 147 | - 'exception' => 'statut' |
|
| 148 | - ) |
|
| 149 | - ), |
|
| 150 | - 'statut_titres' => array( |
|
| 151 | - 'prepa'=>'info_article_redaction', |
|
| 152 | - 'prop'=>'info_article_propose', |
|
| 153 | - 'publie'=>'info_article_publie', |
|
| 154 | - 'refuse'=>'info_article_refuse', |
|
| 155 | - 'poubelle'=>'info_article_supprime' |
|
| 156 | - ), |
|
| 157 | - 'statut_textes_instituer' => array( |
|
| 158 | - 'prepa' => 'texte_statut_en_cours_redaction', |
|
| 159 | - 'prop' => 'texte_statut_propose_evaluation', |
|
| 160 | - 'publie' => 'texte_statut_publie', |
|
| 161 | - 'refuse' => 'texte_statut_refuse', |
|
| 162 | - 'poubelle' => 'texte_statut_poubelle', |
|
| 163 | - ), |
|
| 164 | - 'texte_changer_statut' => 'texte_article_statut', |
|
| 165 | - 'aide_changer_statut' => 'artstatut', |
|
| 166 | - 'tables_jointures' => array( |
|
| 167 | - 'profondeur' => 'rubriques', |
|
| 168 | - #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 169 | - ), |
|
| 170 | - ), |
|
| 171 | - 'spip_auteurs' => array( |
|
| 172 | - 'page'=>'auteur', |
|
| 173 | - 'texte_retour' => 'icone_retour', |
|
| 174 | - 'texte_ajouter' => 'titre_ajouter_un_auteur', |
|
| 175 | - 'texte_modifier' => 'admin_modifier_auteur', |
|
| 176 | - 'texte_objets' => 'icone_auteurs', |
|
| 177 | - 'texte_objet' => 'public:auteur', |
|
| 178 | - 'info_aucun_objet'=> 'info_aucun_auteur', |
|
| 179 | - 'info_1_objet' => 'info_1_auteur', |
|
| 180 | - 'info_nb_objets' => 'info_nb_auteurs', |
|
| 181 | - 'texte_logo_objet' => 'logo_auteur', |
|
| 182 | - 'texte_creer_associer' => 'creer_et_associer_un_auteur', |
|
| 183 | - 'titre' => "nom AS titre, '' AS lang", |
|
| 184 | - 'date' => 'date', |
|
| 185 | - 'principale' => 'oui', |
|
| 186 | - 'champs_editables' => array('nom','email','bio','nom_site','url_site','imessage','pgp'), |
|
| 187 | - 'champs_versionnes' => array('nom', 'bio', 'email', 'nom_site', 'url_site', 'login'), |
|
| 188 | - 'field' => array( |
|
| 189 | - "id_auteur" => "bigint(21) NOT NULL", |
|
| 190 | - "nom" => "text DEFAULT '' NOT NULL", |
|
| 191 | - "bio" => "text DEFAULT '' NOT NULL", |
|
| 192 | - "email" => "tinytext DEFAULT '' NOT NULL", |
|
| 193 | - "nom_site" => "tinytext DEFAULT '' NOT NULL", |
|
| 194 | - "url_site" => "text DEFAULT '' NOT NULL", |
|
| 195 | - "login" => "VARCHAR(255) BINARY", |
|
| 196 | - "pass" => "tinytext DEFAULT '' NOT NULL", |
|
| 197 | - "low_sec" => "tinytext DEFAULT '' NOT NULL", |
|
| 198 | - "statut" => "varchar(255) DEFAULT '0' NOT NULL", |
|
| 199 | - "webmestre" => "varchar(3) DEFAULT 'non' NOT NULL", |
|
| 200 | - "maj" => "TIMESTAMP", |
|
| 201 | - "pgp" => "TEXT DEFAULT '' NOT NULL", |
|
| 202 | - "htpass" => "tinytext DEFAULT '' NOT NULL", |
|
| 203 | - "en_ligne" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 204 | - "alea_actuel" => "tinytext", |
|
| 205 | - "alea_futur" => "tinytext", |
|
| 206 | - "prefs" => "tinytext", |
|
| 207 | - "cookie_oubli" => "tinytext", |
|
| 208 | - "source" => "VARCHAR(10) DEFAULT 'spip' NOT NULL", |
|
| 209 | - "lang" => "VARCHAR(10) DEFAULT '' NOT NULL" |
|
| 210 | - ), |
|
| 211 | - 'key' => array( |
|
| 212 | - "PRIMARY KEY" => "id_auteur", |
|
| 213 | - "KEY login" => "login", |
|
| 214 | - "KEY statut" => "statut", |
|
| 215 | - "KEY en_ligne" => "en_ligne", |
|
| 216 | - ), |
|
| 217 | - 'join' => array( |
|
| 218 | - "id_auteur"=>"id_auteur", |
|
| 219 | - "login"=>"login" |
|
| 220 | - ), |
|
| 221 | - 'rechercher_champs' => array( |
|
| 222 | - 'nom' => 5, 'bio' => 1, 'email' => 1, 'nom_site' => 1, 'url_site' => 1, 'login' => 1 |
|
| 223 | - ), |
|
| 224 | - // 2 conditions pour les auteurs : statut!=poubelle, |
|
| 225 | - // et avoir des articles publies |
|
| 226 | - 'statut'=> array( |
|
| 227 | - array( |
|
| 228 | - 'champ' => 'statut', |
|
| 229 | - 'publie' => '!5poubelle', |
|
| 230 | - 'previsu' => '!5poubelle', |
|
| 231 | - 'exception' => 'statut' |
|
| 232 | - ), |
|
| 233 | - array( |
|
| 234 | - 'champ' => array( |
|
| 235 | - array('spip_auteurs_liens', 'id_auteur'), |
|
| 236 | - array( |
|
| 237 | - 'spip_articles', |
|
| 238 | - array('id_objet','id_article','objet','article') |
|
| 239 | - ), |
|
| 240 | - 'statut' |
|
| 241 | - ), |
|
| 242 | - 'publie' => 'publie', |
|
| 243 | - 'previsu' => '!', |
|
| 244 | - 'post_date' => 'date', |
|
| 245 | - 'exception' => array('statut','lien','tout') |
|
| 246 | - ), |
|
| 247 | - ), |
|
| 248 | - 'statut_images' => array( |
|
| 249 | - 'auteur-6forum-16.png', |
|
| 250 | - '0minirezo'=>'auteur-0minirezo-16.png', |
|
| 251 | - '1comite'=>'auteur-1comite-16.png', |
|
| 252 | - '6forum'=>'auteur-6forum-16.png', |
|
| 253 | - '5poubelle'=>'auteur-5poubelle-16.png', |
|
| 254 | - 'nouveau'=>'' |
|
| 255 | - ), |
|
| 256 | - 'statut_titres' => array( |
|
| 257 | - 'titre_image_visiteur', |
|
| 258 | - '0minirezo'=>'titre_image_administrateur', |
|
| 259 | - '1comite'=>'titre_image_redacteur_02', |
|
| 260 | - '6forum'=>'titre_image_visiteur', |
|
| 261 | - '5poubelle'=>'titre_image_auteur_supprime', |
|
| 262 | - ), |
|
| 263 | - 'tables_jointures' => array( |
|
| 264 | - #'auteurs_liens' // declaration generique plus bas |
|
| 265 | - ), |
|
| 266 | - ), |
|
| 267 | - 'spip_rubriques' => array( |
|
| 268 | - 'page'=>'rubrique', |
|
| 269 | - 'url_voir' => 'rubrique', |
|
| 270 | - 'url_edit' => 'rubrique_edit', |
|
| 271 | - 'texte_retour' => 'icone_retour', |
|
| 272 | - 'texte_objets' => 'public:rubriques', |
|
| 273 | - 'texte_objet' => 'public:rubrique', |
|
| 274 | - 'texte_modifier' => 'icone_modifier_rubrique', |
|
| 275 | - 'texte_creer' => 'icone_creer_rubrique', |
|
| 276 | - 'texte_ajouter' => 'titre_ajouter_une_rubrique', |
|
| 277 | - 'texte_creer_associer' => 'creer_et_associer_une_rubrique', |
|
| 278 | - 'info_aucun_objet'=> 'info_aucun_rubrique', |
|
| 279 | - 'info_1_objet' => 'info_1_rubrique', |
|
| 280 | - 'info_nb_objets' => 'info_nb_rubriques', |
|
| 281 | - 'texte_logo_objet' => 'logo_rubrique', |
|
| 282 | - 'texte_langue_objet' => 'titre_langue_rubrique', |
|
| 283 | - 'titre'=>'titre, lang', |
|
| 284 | - 'date' => 'date', |
|
| 285 | - 'principale' => 'oui', |
|
| 286 | - 'champs_editables' => array('titre', 'texte', 'descriptif', 'extra'), |
|
| 287 | - 'champs_versionnes' => array('titre', 'descriptif', 'texte'), |
|
| 288 | - 'field' => array( |
|
| 289 | - "id_rubrique" => "bigint(21) NOT NULL", |
|
| 290 | - "id_parent" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 291 | - "titre" => "text DEFAULT '' NOT NULL", |
|
| 292 | - "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 293 | - "texte" => "longtext DEFAULT '' NOT NULL", |
|
| 294 | - "id_secteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 295 | - "maj" => "TIMESTAMP", |
|
| 296 | - "statut" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 297 | - "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 298 | - "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 299 | - "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", |
|
| 300 | - "statut_tmp" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 301 | - "date_tmp" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 302 | - "profondeur" => "smallint(5) DEFAULT '0' NOT NULL" |
|
| 303 | - ), |
|
| 304 | - 'key' => array( |
|
| 305 | - "PRIMARY KEY" => "id_rubrique", |
|
| 306 | - "KEY lang" => "lang", |
|
| 307 | - "KEY id_parent" => "id_parent", |
|
| 308 | - ), |
|
| 309 | - 'rechercher_champs' => array( |
|
| 310 | - 'titre' => 8, 'descriptif' => 5, 'texte' => 1 |
|
| 311 | - ), |
|
| 312 | - 'statut' => array( |
|
| 313 | - array( |
|
| 314 | - 'champ' => 'statut', |
|
| 315 | - 'publie' => 'publie', |
|
| 316 | - 'previsu' => '!', |
|
| 317 | - 'exception' => array('statut','tout') |
|
| 318 | - ), |
|
| 319 | - ), |
|
| 320 | - 'tables_jointures' => array( |
|
| 321 | - #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 322 | - ), |
|
| 323 | - ), |
|
| 324 | - // toutes les tables ont le droit a une jointure sur les auteurs |
|
| 325 | - array('tables_jointures'=>array('id_auteur'=>'auteurs_liens')) |
|
| 326 | - ); |
|
| 327 | - |
|
| 328 | - // avant d'appeller les pipeline qui peuvent generer une reentrance a l'install |
|
| 329 | - // initialiser la signature |
|
| 330 | - $md5 = md5(serialize($infos_tables)); |
|
| 331 | - |
|
| 332 | - $GLOBALS['tables_principales'] = pipeline('declarer_tables_principales',$GLOBALS['tables_principales']); |
|
| 333 | - $GLOBALS['tables_auxiliaires'] = pipeline('declarer_tables_auxiliaires',$GLOBALS['tables_auxiliaires']); |
|
| 334 | - $infos_tables = pipeline('declarer_tables_objets_sql',$infos_tables); |
|
| 335 | - |
|
| 336 | - // completer les informations manquantes ou implicites |
|
| 337 | - $all = array(); |
|
| 338 | - foreach(array_keys($infos_tables) as $t) { |
|
| 339 | - // les cles numeriques servent a declarer |
|
| 340 | - // les proprietes applicables a tous les objets |
|
| 341 | - // on les mets de cote |
|
| 342 | - if (is_numeric($t)) { |
|
| 343 | - $all = array_merge_recursive($all,$infos_tables[$t]); |
|
| 344 | - unset($infos_tables[$t]); |
|
| 345 | - } |
|
| 346 | - else |
|
| 347 | - $infos_tables[$t] = renseigner_table_objet_sql($t,$infos_tables[$t]); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - // repercuter les proprietes generales communes a tous les objets |
|
| 351 | - foreach(array_keys($infos_tables) as $t) { |
|
| 352 | - foreach($all as $i=>$v) |
|
| 353 | - if (in_array($i,array('tables_jointures','champs_versionnes'))){ |
|
| 354 | - $add = $all[$i]; |
|
| 355 | - // eviter les doublons de declaration de table jointure (ex des mots sur auteurs) |
|
| 356 | - // pour les declarations generiques avec cles numeriques |
|
| 357 | - if ($i=='tables_jointures' AND isset($infos_tables[$t][$i]) AND count($infos_tables[$t][$i])) { |
|
| 358 | - $doublons = array_intersect($infos_tables[$t][$i],$add); |
|
| 359 | - foreach($doublons as $d){ |
|
| 360 | - if (is_numeric(array_search($d,$infos_tables[$t][$i])) |
|
| 361 | - AND is_numeric($k=array_search($d,$add))) |
|
| 362 | - unset($add[$k]); |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - $infos_tables[$t][$i] = array_merge(isset($infos_tables[$t][$i])?$infos_tables[$t][$i]:array(),$add); |
|
| 366 | - } |
|
| 367 | - else |
|
| 368 | - $infos_tables[$t][$i] = array_merge_recursive(isset($infos_tables[$t][$i])?$infos_tables[$t][$i]:array(),$all[$i]); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // completer les tables principales et auxiliaires |
|
| 372 | - // avec celles declarees uniquement dans declarer_table_objets_sql |
|
| 373 | - // pour assurer la compat en transition |
|
| 374 | - foreach($infos_tables as $table=>$infos) { |
|
| 375 | - $principale_ou_auxiliaire = ($infos['principale']?'tables_principales':'tables_auxiliaires'); |
|
| 376 | - // memoriser des champs eventuels declares par des plugins dans le pipeline tables_xxx |
|
| 377 | - // qui a ete appelle avant |
|
| 378 | - $mem = (isset($GLOBALS[$principale_ou_auxiliaire][$table])?$GLOBALS[$principale_ou_auxiliaire][$table]:array()); |
|
| 379 | - // l'ajouter au tableau |
|
| 380 | - $GLOBALS[$principale_ou_auxiliaire][$table] = array(); |
|
| 381 | - if (isset($infos['field']) AND isset($infos['key'])){ |
|
| 382 | - foreach(array('field','key','join') as $k) |
|
| 383 | - if (isset($infos_tables[$table][$k])) |
|
| 384 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = &$infos_tables[$table][$k]; |
|
| 385 | - } |
|
| 386 | - else { |
|
| 387 | - // ici on ne renvoie que les declarations, donc RIEN |
|
| 388 | - // pour avoir la vrai description en base, il faut passer par trouver_table |
|
| 389 | - $GLOBALS[$principale_ou_auxiliaire][$table] = array(); |
|
| 390 | - } |
|
| 391 | - if (count($mem)){ |
|
| 392 | - foreach(array_keys($mem) as $k) |
|
| 393 | - if (isset($GLOBALS[$principale_ou_auxiliaire][$table][$k])) |
|
| 394 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = array_merge($GLOBALS[$principale_ou_auxiliaire][$table][$k],$mem[$k]); |
|
| 395 | - else |
|
| 396 | - $GLOBALS[$principale_ou_auxiliaire][$table][$k] = $mem[$k]; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - // recuperer les interfaces (table_titre, table_date) |
|
| 401 | - // on ne le fait que dans un second temps pour que table_objet soit fonctionnel |
|
| 402 | - // dans le pipeline de declarer_tables_interfaces |
|
| 403 | - include_spip('public/interfaces'); |
|
| 404 | - foreach(array_keys($infos_tables) as $t) { |
|
| 405 | - $infos_tables[$t] = renseigner_table_objet_interfaces($t,$infos_tables[$t]); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - $deja_la = false; |
|
| 409 | - // signature |
|
| 410 | - $md5 = md5(serialize($infos_tables)); |
|
| 411 | - } |
|
| 412 | - if ($table_sql==="::md5") |
|
| 413 | - return $md5; |
|
| 414 | - if ($table_sql AND !isset($infos_tables[$table_sql])){ |
|
| 415 | - #$desc = renseigner_table_objet_sql($table_sql,$desc); |
|
| 416 | - $desc = renseigner_table_objet_interfaces($table_sql,$desc); |
|
| 417 | - return $desc; |
|
| 418 | - } |
|
| 419 | - if ($table_sql) |
|
| 420 | - return isset($infos_tables[$table_sql])?$infos_tables[$table_sql]:array(); |
|
| 421 | - |
|
| 422 | - return $infos_tables; |
|
| 53 | + static $deja_la = false; |
|
| 54 | + static $infos_tables = null; |
|
| 55 | + static $md5 = null; |
|
| 56 | + static $plugin_hash = null; |
|
| 57 | + // prealablement recuperer les tables_principales |
|
| 58 | + if (is_null($infos_tables) |
|
| 59 | + OR $plugin_hash!==_PLUGINS_HASH){ |
|
| 60 | + // pas de reentrance (cas base/serial) |
|
| 61 | + if ($deja_la) { |
|
| 62 | + spip_log ("Re-entrance anormale sur lister_tables_objets_sql :" |
|
| 63 | + . var_export(debug_backtrace(),true),_LOG_CRITIQUE); |
|
| 64 | + return ($table_sql==="::md5"?$md5:array()); |
|
| 65 | + } |
|
| 66 | + $deja_la = true; |
|
| 67 | + $plugin_hash = _PLUGINS_HASH; // avant de lancer les pipelines |
|
| 68 | + |
|
| 69 | + // recuperer les declarations explicites ancienne mode |
|
| 70 | + // qui servent a completer declarer_tables_objets_sql |
|
| 71 | + base_serial($GLOBALS['tables_principales']); |
|
| 72 | + base_auxiliaires($GLOBALS['tables_auxiliaires']); |
|
| 73 | + $infos_tables = array( |
|
| 74 | + 'spip_articles'=> array( |
|
| 75 | + 'page'=>'article', |
|
| 76 | + 'texte_retour' => 'icone_retour_article', |
|
| 77 | + 'texte_modifier' => 'icone_modifier_article', |
|
| 78 | + 'texte_creer' => 'icone_ecrire_article', |
|
| 79 | + 'texte_objets' => 'public:articles', |
|
| 80 | + 'texte_objet' => 'public:article', |
|
| 81 | + 'texte_signale_edition' => 'texte_travail_article', |
|
| 82 | + 'info_aucun_objet'=> 'info_aucun_article', |
|
| 83 | + 'info_1_objet' => 'info_1_article', |
|
| 84 | + 'info_nb_objets' => 'info_nb_articles', |
|
| 85 | + 'texte_logo_objet' => 'logo_article', |
|
| 86 | + 'texte_langue_objet' => 'titre_langue_article', |
|
| 87 | + 'texte_definir_comme_traduction_objet' => 'trad_lier', |
|
| 88 | + 'titre' => 'titre, lang', |
|
| 89 | + 'date' => 'date', |
|
| 90 | + 'principale' => 'oui', |
|
| 91 | + 'champs_editables' => array('surtitre', 'titre', 'soustitre', 'descriptif','nom_site', 'url_site', 'chapo', 'texte', 'ps','virtuel'), |
|
| 92 | + 'champs_versionnes' => array('id_rubrique', 'surtitre', 'titre', 'soustitre', 'jointure_auteurs', 'descriptif', 'nom_site', 'url_site', 'chapo', 'texte', 'ps'), |
|
| 93 | + 'field' => array( |
|
| 94 | + "id_article" => "bigint(21) NOT NULL", |
|
| 95 | + "surtitre" => "text DEFAULT '' NOT NULL", |
|
| 96 | + "titre" => "text DEFAULT '' NOT NULL", |
|
| 97 | + "soustitre" => "text DEFAULT '' NOT NULL", |
|
| 98 | + "id_rubrique" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 99 | + "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 100 | + "chapo" => "mediumtext DEFAULT '' NOT NULL", |
|
| 101 | + "texte" => "longtext DEFAULT '' NOT NULL", |
|
| 102 | + "ps" => "mediumtext DEFAULT '' NOT NULL", |
|
| 103 | + "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 104 | + "statut" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 105 | + "id_secteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 106 | + "maj" => "TIMESTAMP", |
|
| 107 | + "export" => "VARCHAR(10) DEFAULT 'oui'", |
|
| 108 | + "date_redac" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 109 | + "visites" => "integer DEFAULT '0' NOT NULL", |
|
| 110 | + "referers" => "integer DEFAULT '0' NOT NULL", |
|
| 111 | + "popularite" => "DOUBLE DEFAULT '0' NOT NULL", |
|
| 112 | + "accepter_forum" => "CHAR(3) DEFAULT '' NOT NULL", |
|
| 113 | + "date_modif" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 114 | + "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 115 | + "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", |
|
| 116 | + "id_trad" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 117 | + "nom_site" => "tinytext DEFAULT '' NOT NULL", |
|
| 118 | + "url_site" => "VARCHAR(255) DEFAULT '' NOT NULL", |
|
| 119 | + "virtuel" => "VARCHAR(255) DEFAULT '' NOT NULL", |
|
| 120 | + ), |
|
| 121 | + 'key' => array( |
|
| 122 | + "PRIMARY KEY" => "id_article", |
|
| 123 | + "KEY id_rubrique" => "id_rubrique", |
|
| 124 | + "KEY id_secteur" => "id_secteur", |
|
| 125 | + "KEY id_trad" => "id_trad", |
|
| 126 | + "KEY lang" => "lang", |
|
| 127 | + "KEY statut" => "statut, date", |
|
| 128 | + ), |
|
| 129 | + 'join' => array( |
|
| 130 | + "id_article"=>"id_article", |
|
| 131 | + "id_rubrique"=>"id_rubrique" |
|
| 132 | + ), |
|
| 133 | + 'rechercher_champs' => array( |
|
| 134 | + 'surtitre' => 5, 'titre' => 8, 'soustitre' => 5, 'chapo' => 3, |
|
| 135 | + 'texte' => 1, 'ps' => 1, 'nom_site' => 1, 'url_site' => 1, |
|
| 136 | + 'descriptif' => 4 |
|
| 137 | + ), |
|
| 138 | + 'rechercher_jointures' => array( |
|
| 139 | + 'auteur' => array('nom' => 10), |
|
| 140 | + ), |
|
| 141 | + 'statut'=> array( |
|
| 142 | + array( |
|
| 143 | + 'champ' => 'statut', |
|
| 144 | + 'publie' => 'publie', |
|
| 145 | + 'previsu' => 'publie,prop,prepa/auteur', |
|
| 146 | + 'post_date' => 'date', |
|
| 147 | + 'exception' => 'statut' |
|
| 148 | + ) |
|
| 149 | + ), |
|
| 150 | + 'statut_titres' => array( |
|
| 151 | + 'prepa'=>'info_article_redaction', |
|
| 152 | + 'prop'=>'info_article_propose', |
|
| 153 | + 'publie'=>'info_article_publie', |
|
| 154 | + 'refuse'=>'info_article_refuse', |
|
| 155 | + 'poubelle'=>'info_article_supprime' |
|
| 156 | + ), |
|
| 157 | + 'statut_textes_instituer' => array( |
|
| 158 | + 'prepa' => 'texte_statut_en_cours_redaction', |
|
| 159 | + 'prop' => 'texte_statut_propose_evaluation', |
|
| 160 | + 'publie' => 'texte_statut_publie', |
|
| 161 | + 'refuse' => 'texte_statut_refuse', |
|
| 162 | + 'poubelle' => 'texte_statut_poubelle', |
|
| 163 | + ), |
|
| 164 | + 'texte_changer_statut' => 'texte_article_statut', |
|
| 165 | + 'aide_changer_statut' => 'artstatut', |
|
| 166 | + 'tables_jointures' => array( |
|
| 167 | + 'profondeur' => 'rubriques', |
|
| 168 | + #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 169 | + ), |
|
| 170 | + ), |
|
| 171 | + 'spip_auteurs' => array( |
|
| 172 | + 'page'=>'auteur', |
|
| 173 | + 'texte_retour' => 'icone_retour', |
|
| 174 | + 'texte_ajouter' => 'titre_ajouter_un_auteur', |
|
| 175 | + 'texte_modifier' => 'admin_modifier_auteur', |
|
| 176 | + 'texte_objets' => 'icone_auteurs', |
|
| 177 | + 'texte_objet' => 'public:auteur', |
|
| 178 | + 'info_aucun_objet'=> 'info_aucun_auteur', |
|
| 179 | + 'info_1_objet' => 'info_1_auteur', |
|
| 180 | + 'info_nb_objets' => 'info_nb_auteurs', |
|
| 181 | + 'texte_logo_objet' => 'logo_auteur', |
|
| 182 | + 'texte_creer_associer' => 'creer_et_associer_un_auteur', |
|
| 183 | + 'titre' => "nom AS titre, '' AS lang", |
|
| 184 | + 'date' => 'date', |
|
| 185 | + 'principale' => 'oui', |
|
| 186 | + 'champs_editables' => array('nom','email','bio','nom_site','url_site','imessage','pgp'), |
|
| 187 | + 'champs_versionnes' => array('nom', 'bio', 'email', 'nom_site', 'url_site', 'login'), |
|
| 188 | + 'field' => array( |
|
| 189 | + "id_auteur" => "bigint(21) NOT NULL", |
|
| 190 | + "nom" => "text DEFAULT '' NOT NULL", |
|
| 191 | + "bio" => "text DEFAULT '' NOT NULL", |
|
| 192 | + "email" => "tinytext DEFAULT '' NOT NULL", |
|
| 193 | + "nom_site" => "tinytext DEFAULT '' NOT NULL", |
|
| 194 | + "url_site" => "text DEFAULT '' NOT NULL", |
|
| 195 | + "login" => "VARCHAR(255) BINARY", |
|
| 196 | + "pass" => "tinytext DEFAULT '' NOT NULL", |
|
| 197 | + "low_sec" => "tinytext DEFAULT '' NOT NULL", |
|
| 198 | + "statut" => "varchar(255) DEFAULT '0' NOT NULL", |
|
| 199 | + "webmestre" => "varchar(3) DEFAULT 'non' NOT NULL", |
|
| 200 | + "maj" => "TIMESTAMP", |
|
| 201 | + "pgp" => "TEXT DEFAULT '' NOT NULL", |
|
| 202 | + "htpass" => "tinytext DEFAULT '' NOT NULL", |
|
| 203 | + "en_ligne" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 204 | + "alea_actuel" => "tinytext", |
|
| 205 | + "alea_futur" => "tinytext", |
|
| 206 | + "prefs" => "tinytext", |
|
| 207 | + "cookie_oubli" => "tinytext", |
|
| 208 | + "source" => "VARCHAR(10) DEFAULT 'spip' NOT NULL", |
|
| 209 | + "lang" => "VARCHAR(10) DEFAULT '' NOT NULL" |
|
| 210 | + ), |
|
| 211 | + 'key' => array( |
|
| 212 | + "PRIMARY KEY" => "id_auteur", |
|
| 213 | + "KEY login" => "login", |
|
| 214 | + "KEY statut" => "statut", |
|
| 215 | + "KEY en_ligne" => "en_ligne", |
|
| 216 | + ), |
|
| 217 | + 'join' => array( |
|
| 218 | + "id_auteur"=>"id_auteur", |
|
| 219 | + "login"=>"login" |
|
| 220 | + ), |
|
| 221 | + 'rechercher_champs' => array( |
|
| 222 | + 'nom' => 5, 'bio' => 1, 'email' => 1, 'nom_site' => 1, 'url_site' => 1, 'login' => 1 |
|
| 223 | + ), |
|
| 224 | + // 2 conditions pour les auteurs : statut!=poubelle, |
|
| 225 | + // et avoir des articles publies |
|
| 226 | + 'statut'=> array( |
|
| 227 | + array( |
|
| 228 | + 'champ' => 'statut', |
|
| 229 | + 'publie' => '!5poubelle', |
|
| 230 | + 'previsu' => '!5poubelle', |
|
| 231 | + 'exception' => 'statut' |
|
| 232 | + ), |
|
| 233 | + array( |
|
| 234 | + 'champ' => array( |
|
| 235 | + array('spip_auteurs_liens', 'id_auteur'), |
|
| 236 | + array( |
|
| 237 | + 'spip_articles', |
|
| 238 | + array('id_objet','id_article','objet','article') |
|
| 239 | + ), |
|
| 240 | + 'statut' |
|
| 241 | + ), |
|
| 242 | + 'publie' => 'publie', |
|
| 243 | + 'previsu' => '!', |
|
| 244 | + 'post_date' => 'date', |
|
| 245 | + 'exception' => array('statut','lien','tout') |
|
| 246 | + ), |
|
| 247 | + ), |
|
| 248 | + 'statut_images' => array( |
|
| 249 | + 'auteur-6forum-16.png', |
|
| 250 | + '0minirezo'=>'auteur-0minirezo-16.png', |
|
| 251 | + '1comite'=>'auteur-1comite-16.png', |
|
| 252 | + '6forum'=>'auteur-6forum-16.png', |
|
| 253 | + '5poubelle'=>'auteur-5poubelle-16.png', |
|
| 254 | + 'nouveau'=>'' |
|
| 255 | + ), |
|
| 256 | + 'statut_titres' => array( |
|
| 257 | + 'titre_image_visiteur', |
|
| 258 | + '0minirezo'=>'titre_image_administrateur', |
|
| 259 | + '1comite'=>'titre_image_redacteur_02', |
|
| 260 | + '6forum'=>'titre_image_visiteur', |
|
| 261 | + '5poubelle'=>'titre_image_auteur_supprime', |
|
| 262 | + ), |
|
| 263 | + 'tables_jointures' => array( |
|
| 264 | + #'auteurs_liens' // declaration generique plus bas |
|
| 265 | + ), |
|
| 266 | + ), |
|
| 267 | + 'spip_rubriques' => array( |
|
| 268 | + 'page'=>'rubrique', |
|
| 269 | + 'url_voir' => 'rubrique', |
|
| 270 | + 'url_edit' => 'rubrique_edit', |
|
| 271 | + 'texte_retour' => 'icone_retour', |
|
| 272 | + 'texte_objets' => 'public:rubriques', |
|
| 273 | + 'texte_objet' => 'public:rubrique', |
|
| 274 | + 'texte_modifier' => 'icone_modifier_rubrique', |
|
| 275 | + 'texte_creer' => 'icone_creer_rubrique', |
|
| 276 | + 'texte_ajouter' => 'titre_ajouter_une_rubrique', |
|
| 277 | + 'texte_creer_associer' => 'creer_et_associer_une_rubrique', |
|
| 278 | + 'info_aucun_objet'=> 'info_aucun_rubrique', |
|
| 279 | + 'info_1_objet' => 'info_1_rubrique', |
|
| 280 | + 'info_nb_objets' => 'info_nb_rubriques', |
|
| 281 | + 'texte_logo_objet' => 'logo_rubrique', |
|
| 282 | + 'texte_langue_objet' => 'titre_langue_rubrique', |
|
| 283 | + 'titre'=>'titre, lang', |
|
| 284 | + 'date' => 'date', |
|
| 285 | + 'principale' => 'oui', |
|
| 286 | + 'champs_editables' => array('titre', 'texte', 'descriptif', 'extra'), |
|
| 287 | + 'champs_versionnes' => array('titre', 'descriptif', 'texte'), |
|
| 288 | + 'field' => array( |
|
| 289 | + "id_rubrique" => "bigint(21) NOT NULL", |
|
| 290 | + "id_parent" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 291 | + "titre" => "text DEFAULT '' NOT NULL", |
|
| 292 | + "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 293 | + "texte" => "longtext DEFAULT '' NOT NULL", |
|
| 294 | + "id_secteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 295 | + "maj" => "TIMESTAMP", |
|
| 296 | + "statut" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 297 | + "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 298 | + "lang" => "VARCHAR(10) DEFAULT '' NOT NULL", |
|
| 299 | + "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", |
|
| 300 | + "statut_tmp" => "varchar(10) DEFAULT '0' NOT NULL", |
|
| 301 | + "date_tmp" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
|
| 302 | + "profondeur" => "smallint(5) DEFAULT '0' NOT NULL" |
|
| 303 | + ), |
|
| 304 | + 'key' => array( |
|
| 305 | + "PRIMARY KEY" => "id_rubrique", |
|
| 306 | + "KEY lang" => "lang", |
|
| 307 | + "KEY id_parent" => "id_parent", |
|
| 308 | + ), |
|
| 309 | + 'rechercher_champs' => array( |
|
| 310 | + 'titre' => 8, 'descriptif' => 5, 'texte' => 1 |
|
| 311 | + ), |
|
| 312 | + 'statut' => array( |
|
| 313 | + array( |
|
| 314 | + 'champ' => 'statut', |
|
| 315 | + 'publie' => 'publie', |
|
| 316 | + 'previsu' => '!', |
|
| 317 | + 'exception' => array('statut','tout') |
|
| 318 | + ), |
|
| 319 | + ), |
|
| 320 | + 'tables_jointures' => array( |
|
| 321 | + #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
|
| 322 | + ), |
|
| 323 | + ), |
|
| 324 | + // toutes les tables ont le droit a une jointure sur les auteurs |
|
| 325 | + array('tables_jointures'=>array('id_auteur'=>'auteurs_liens')) |
|
| 326 | + ); |
|
| 327 | + |
|
| 328 | + // avant d'appeller les pipeline qui peuvent generer une reentrance a l'install |
|
| 329 | + // initialiser la signature |
|
| 330 | + $md5 = md5(serialize($infos_tables)); |
|
| 331 | + |
|
| 332 | + $GLOBALS['tables_principales'] = pipeline('declarer_tables_principales',$GLOBALS['tables_principales']); |
|
| 333 | + $GLOBALS['tables_auxiliaires'] = pipeline('declarer_tables_auxiliaires',$GLOBALS['tables_auxiliaires']); |
|
| 334 | + $infos_tables = pipeline('declarer_tables_objets_sql',$infos_tables); |
|
| 335 | + |
|
| 336 | + // completer les informations manquantes ou implicites |
|
| 337 | + $all = array(); |
|
| 338 | + foreach(array_keys($infos_tables) as $t) { |
|
| 339 | + // les cles numeriques servent a declarer |
|
| 340 | + // les proprietes applicables a tous les objets |
|
| 341 | + // on les mets de cote |
|
| 342 | + if (is_numeric($t)) { |
|
| 343 | + $all = array_merge_recursive($all,$infos_tables[$t]); |
|
| 344 | + unset($infos_tables[$t]); |
|
| 345 | + } |
|
| 346 | + else |
|
| 347 | + $infos_tables[$t] = renseigner_table_objet_sql($t,$infos_tables[$t]); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + // repercuter les proprietes generales communes a tous les objets |
|
| 351 | + foreach(array_keys($infos_tables) as $t) { |
|
| 352 | + foreach($all as $i=>$v) |
|
| 353 | + if (in_array($i,array('tables_jointures','champs_versionnes'))){ |
|
| 354 | + $add = $all[$i]; |
|
| 355 | + // eviter les doublons de declaration de table jointure (ex des mots sur auteurs) |
|
| 356 | + // pour les declarations generiques avec cles numeriques |
|
| 357 | + if ($i=='tables_jointures' AND isset($infos_tables[$t][$i]) AND count($infos_tables[$t][$i])) { |
|
| 358 | + $doublons = array_intersect($infos_tables[$t][$i],$add); |
|
| 359 | + foreach($doublons as $d){ |
|
| 360 | + if (is_numeric(array_search($d,$infos_tables[$t][$i])) |
|
| 361 | + AND is_numeric($k=array_search($d,$add))) |
|
| 362 | + unset($add[$k]); |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + $infos_tables[$t][$i] = array_merge(isset($infos_tables[$t][$i])?$infos_tables[$t][$i]:array(),$add); |
|
| 366 | + } |
|
| 367 | + else |
|
| 368 | + $infos_tables[$t][$i] = array_merge_recursive(isset($infos_tables[$t][$i])?$infos_tables[$t][$i]:array(),$all[$i]); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // completer les tables principales et auxiliaires |
|
| 372 | + // avec celles declarees uniquement dans declarer_table_objets_sql |
|
| 373 | + // pour assurer la compat en transition |
|
| 374 | + foreach($infos_tables as $table=>$infos) { |
|
| 375 | + $principale_ou_auxiliaire = ($infos['principale']?'tables_principales':'tables_auxiliaires'); |
|
| 376 | + // memoriser des champs eventuels declares par des plugins dans le pipeline tables_xxx |
|
| 377 | + // qui a ete appelle avant |
|
| 378 | + $mem = (isset($GLOBALS[$principale_ou_auxiliaire][$table])?$GLOBALS[$principale_ou_auxiliaire][$table]:array()); |
|
| 379 | + // l'ajouter au tableau |
|
| 380 | + $GLOBALS[$principale_ou_auxiliaire][$table] = array(); |
|
| 381 | + if (isset($infos['field']) AND isset($infos['key'])){ |
|
| 382 | + foreach(array('field','key','join') as $k) |
|
| 383 | + if (isset($infos_tables[$table][$k])) |
|
| 384 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = &$infos_tables[$table][$k]; |
|
| 385 | + } |
|
| 386 | + else { |
|
| 387 | + // ici on ne renvoie que les declarations, donc RIEN |
|
| 388 | + // pour avoir la vrai description en base, il faut passer par trouver_table |
|
| 389 | + $GLOBALS[$principale_ou_auxiliaire][$table] = array(); |
|
| 390 | + } |
|
| 391 | + if (count($mem)){ |
|
| 392 | + foreach(array_keys($mem) as $k) |
|
| 393 | + if (isset($GLOBALS[$principale_ou_auxiliaire][$table][$k])) |
|
| 394 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = array_merge($GLOBALS[$principale_ou_auxiliaire][$table][$k],$mem[$k]); |
|
| 395 | + else |
|
| 396 | + $GLOBALS[$principale_ou_auxiliaire][$table][$k] = $mem[$k]; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + // recuperer les interfaces (table_titre, table_date) |
|
| 401 | + // on ne le fait que dans un second temps pour que table_objet soit fonctionnel |
|
| 402 | + // dans le pipeline de declarer_tables_interfaces |
|
| 403 | + include_spip('public/interfaces'); |
|
| 404 | + foreach(array_keys($infos_tables) as $t) { |
|
| 405 | + $infos_tables[$t] = renseigner_table_objet_interfaces($t,$infos_tables[$t]); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + $deja_la = false; |
|
| 409 | + // signature |
|
| 410 | + $md5 = md5(serialize($infos_tables)); |
|
| 411 | + } |
|
| 412 | + if ($table_sql==="::md5") |
|
| 413 | + return $md5; |
|
| 414 | + if ($table_sql AND !isset($infos_tables[$table_sql])){ |
|
| 415 | + #$desc = renseigner_table_objet_sql($table_sql,$desc); |
|
| 416 | + $desc = renseigner_table_objet_interfaces($table_sql,$desc); |
|
| 417 | + return $desc; |
|
| 418 | + } |
|
| 419 | + if ($table_sql) |
|
| 420 | + return isset($infos_tables[$table_sql])?$infos_tables[$table_sql]:array(); |
|
| 421 | + |
|
| 422 | + return $infos_tables; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -434,27 +434,27 @@ discard block |
||
| 434 | 434 | **/ |
| 435 | 435 | function base_serial(&$tables_principales){ |
| 436 | 436 | |
| 437 | - $spip_jobs = array( |
|
| 438 | - "id_job" => "bigint(21) NOT NULL", |
|
| 439 | - "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 440 | - "fonction" => "varchar(255) NOT NULL", //nom de la fonction |
|
| 441 | - "args"=> "longblob DEFAULT '' NOT NULL", // arguments |
|
| 442 | - "md5args"=> "char(32) NOT NULL default ''", // signature des arguments |
|
| 443 | - "inclure" => "varchar(255) NOT NULL", // fichier a inclure ou path/ pour charger_fonction |
|
| 444 | - "priorite" => "smallint(6) NOT NULL default 0", |
|
| 445 | - "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", // date au plus tot |
|
| 446 | - "status" => "tinyint NOT NULL default 1", |
|
| 447 | - ); |
|
| 448 | - |
|
| 449 | - $spip_jobs_key = array( |
|
| 450 | - "PRIMARY KEY" => "id_job", |
|
| 451 | - "KEY date" => "date", |
|
| 452 | - "KEY status" => "status", |
|
| 453 | - ); |
|
| 454 | - |
|
| 455 | - /// Attention: mes_fonctions peut avoir deja defini cette variable |
|
| 456 | - /// il faut donc rajouter, mais pas reinitialiser |
|
| 457 | - $tables_principales['spip_jobs'] = array('field' => &$spip_jobs, 'key' => &$spip_jobs_key); |
|
| 437 | + $spip_jobs = array( |
|
| 438 | + "id_job" => "bigint(21) NOT NULL", |
|
| 439 | + "descriptif" => "text DEFAULT '' NOT NULL", |
|
| 440 | + "fonction" => "varchar(255) NOT NULL", //nom de la fonction |
|
| 441 | + "args"=> "longblob DEFAULT '' NOT NULL", // arguments |
|
| 442 | + "md5args"=> "char(32) NOT NULL default ''", // signature des arguments |
|
| 443 | + "inclure" => "varchar(255) NOT NULL", // fichier a inclure ou path/ pour charger_fonction |
|
| 444 | + "priorite" => "smallint(6) NOT NULL default 0", |
|
| 445 | + "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", // date au plus tot |
|
| 446 | + "status" => "tinyint NOT NULL default 1", |
|
| 447 | + ); |
|
| 448 | + |
|
| 449 | + $spip_jobs_key = array( |
|
| 450 | + "PRIMARY KEY" => "id_job", |
|
| 451 | + "KEY date" => "date", |
|
| 452 | + "KEY status" => "status", |
|
| 453 | + ); |
|
| 454 | + |
|
| 455 | + /// Attention: mes_fonctions peut avoir deja defini cette variable |
|
| 456 | + /// il faut donc rajouter, mais pas reinitialiser |
|
| 457 | + $tables_principales['spip_jobs'] = array('field' => &$spip_jobs, 'key' => &$spip_jobs_key); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | |
@@ -467,62 +467,62 @@ discard block |
||
| 467 | 467 | **/ |
| 468 | 468 | function base_auxiliaires(&$tables_auxiliaires){ |
| 469 | 469 | $spip_resultats = array( |
| 470 | - "recherche" => "char(16) DEFAULT '' NOT NULL", |
|
| 471 | - "id" => "INT UNSIGNED NOT NULL", |
|
| 472 | - "points" => "INT UNSIGNED DEFAULT '0' NOT NULL", |
|
| 473 | - "table_objet" => "varchar(30) DEFAULT '' NOT NULL", |
|
| 474 | - "serveur" => "char(16) DEFAULT '' NOT NULL", // hash md5 partiel du serveur de base ('' pour le serveur principal) |
|
| 475 | - "maj" => "TIMESTAMP" ); |
|
| 470 | + "recherche" => "char(16) DEFAULT '' NOT NULL", |
|
| 471 | + "id" => "INT UNSIGNED NOT NULL", |
|
| 472 | + "points" => "INT UNSIGNED DEFAULT '0' NOT NULL", |
|
| 473 | + "table_objet" => "varchar(30) DEFAULT '' NOT NULL", |
|
| 474 | + "serveur" => "char(16) DEFAULT '' NOT NULL", // hash md5 partiel du serveur de base ('' pour le serveur principal) |
|
| 475 | + "maj" => "TIMESTAMP" ); |
|
| 476 | 476 | |
| 477 | 477 | $spip_resultats_key = array( |
| 478 | 478 | // pas de cle ni index, ca fait des insertions plus rapides et les requetes jointes utilisees en recheche ne sont pas plus lentes ... |
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | 481 | $spip_auteurs_liens = array( |
| 482 | - "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 483 | - "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 484 | - "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 485 | - "vu" => "VARCHAR(6) DEFAULT 'non' NOT NULL"); |
|
| 482 | + "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 483 | + "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 484 | + "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 485 | + "vu" => "VARCHAR(6) DEFAULT 'non' NOT NULL"); |
|
| 486 | 486 | |
| 487 | 487 | $spip_auteurs_liens_key = array( |
| 488 | - "PRIMARY KEY" => "id_auteur,id_objet,objet", |
|
| 489 | - "KEY id_auteur" => "id_auteur", |
|
| 490 | - "KEY id_objet" => "id_objet", |
|
| 491 | - "KEY objet" => "objet", |
|
| 488 | + "PRIMARY KEY" => "id_auteur,id_objet,objet", |
|
| 489 | + "KEY id_auteur" => "id_auteur", |
|
| 490 | + "KEY id_objet" => "id_objet", |
|
| 491 | + "KEY objet" => "objet", |
|
| 492 | 492 | ); |
| 493 | 493 | |
| 494 | 494 | $spip_meta = array( |
| 495 | - "nom" => "VARCHAR (255) NOT NULL", |
|
| 496 | - "valeur" => "text DEFAULT ''", |
|
| 497 | - "impt" => "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL", |
|
| 498 | - "maj" => "TIMESTAMP"); |
|
| 495 | + "nom" => "VARCHAR (255) NOT NULL", |
|
| 496 | + "valeur" => "text DEFAULT ''", |
|
| 497 | + "impt" => "ENUM('non', 'oui') DEFAULT 'oui' NOT NULL", |
|
| 498 | + "maj" => "TIMESTAMP"); |
|
| 499 | 499 | |
| 500 | 500 | $spip_meta_key = array( |
| 501 | - "PRIMARY KEY" => "nom"); |
|
| 501 | + "PRIMARY KEY" => "nom"); |
|
| 502 | 502 | |
| 503 | 503 | $spip_jobs_liens = array( |
| 504 | - "id_job" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 505 | - "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 506 | - "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 504 | + "id_job" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 505 | + "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", |
|
| 506 | + "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
|
| 507 | 507 | ); |
| 508 | 508 | |
| 509 | 509 | $spip_jobs_liens_key = array( |
| 510 | - "PRIMARY KEY" => "id_job,id_objet,objet", |
|
| 511 | - "KEY id_job" => "id_job"); |
|
| 510 | + "PRIMARY KEY" => "id_job,id_objet,objet", |
|
| 511 | + "KEY id_job" => "id_job"); |
|
| 512 | 512 | |
| 513 | 513 | $tables_auxiliaires['spip_auteurs_liens'] = array( |
| 514 | - 'field' => &$spip_auteurs_liens, |
|
| 515 | - 'key' => &$spip_auteurs_liens_key); |
|
| 514 | + 'field' => &$spip_auteurs_liens, |
|
| 515 | + 'key' => &$spip_auteurs_liens_key); |
|
| 516 | 516 | |
| 517 | 517 | $tables_auxiliaires['spip_meta'] = array( |
| 518 | - 'field' => &$spip_meta, |
|
| 519 | - 'key' => &$spip_meta_key); |
|
| 518 | + 'field' => &$spip_meta, |
|
| 519 | + 'key' => &$spip_meta_key); |
|
| 520 | 520 | $tables_auxiliaires['spip_resultats'] = array( |
| 521 | - 'field' => &$spip_resultats, |
|
| 522 | - 'key' => &$spip_resultats_key); |
|
| 521 | + 'field' => &$spip_resultats, |
|
| 522 | + 'key' => &$spip_resultats_key); |
|
| 523 | 523 | $tables_auxiliaires['spip_jobs_liens'] = array( |
| 524 | - 'field' => &$spip_jobs_liens, |
|
| 525 | - 'key' => &$spip_jobs_liens_key); |
|
| 524 | + 'field' => &$spip_jobs_liens, |
|
| 525 | + 'key' => &$spip_jobs_liens_key); |
|
| 526 | 526 | |
| 527 | 527 | } |
| 528 | 528 | |
@@ -579,98 +579,98 @@ discard block |
||
| 579 | 579 | * @return array |
| 580 | 580 | */ |
| 581 | 581 | function renseigner_table_objet_sql($table_sql,&$infos){ |
| 582 | - if (!isset($infos['type'])){ |
|
| 583 | - // si on arrive de base/trouver_table, on a la cle primaire : |
|
| 584 | - // s'en servir pour extrapoler le type |
|
| 585 | - if (isset($infos['key']["PRIMARY KEY"])){ |
|
| 586 | - $primary = $infos['key']["PRIMARY KEY"]; |
|
| 587 | - $primary = explode(',',$primary); |
|
| 588 | - $primary = reset($primary); |
|
| 589 | - $infos['type'] = preg_replace(',^spip_|^id_|s$,', '', $primary); |
|
| 590 | - } |
|
| 591 | - else |
|
| 592 | - $infos['type'] = preg_replace(',^spip_|s$,', '', $table_sql); |
|
| 593 | - } |
|
| 594 | - if (!isset($infos['type_surnoms'])) |
|
| 595 | - $infos['type_surnoms'] = array(); |
|
| 596 | - |
|
| 597 | - if (!isset($infos['table_objet'])) |
|
| 598 | - $infos['table_objet'] = preg_replace(',^spip_,', '', $table_sql); |
|
| 599 | - if (!isset($infos['table_objet_surnoms'])) |
|
| 600 | - $infos['table_objet_surnoms'] = array(); |
|
| 601 | - |
|
| 602 | - if (!isset($infos['principale'])) |
|
| 603 | - $infos['principale'] = (isset($GLOBALS['tables_principales'][$table_sql])?'oui':false); |
|
| 604 | - |
|
| 605 | - // normaliser pour pouvoir tester en php $infos['principale']? |
|
| 606 | - // et dans une boucle {principale=oui} |
|
| 607 | - $infos['principale'] = (($infos['principale'] AND $infos['principale']!='non')?'oui':false); |
|
| 608 | - |
|
| 609 | - // declarer et normaliser pour pouvoir tester en php $infos['editable']? |
|
| 610 | - // et dans une boucle {editable=oui} |
|
| 611 | - if (!isset($infos['editable'])) $infos['editable'] = 'oui'; |
|
| 612 | - $infos['editable'] = (($infos['editable'] AND $infos['editable']!='non')?'oui':false); |
|
| 613 | - |
|
| 614 | - // les urls publiques sont par defaut page=type pour les tables principales, et rien pour les autres |
|
| 615 | - // seules les exceptions sont donc a declarer |
|
| 616 | - if (!isset($infos['page'])) |
|
| 617 | - $infos['page'] = ($infos['principale']?$infos['type']:''); |
|
| 618 | - |
|
| 619 | - if (!isset($infos['url_voir'])) |
|
| 620 | - $infos['url_voir'] = $infos['type']; |
|
| 621 | - if (!isset($infos['url_edit'])) |
|
| 622 | - $infos['url_edit'] = $infos['url_voir'].($infos['editable']?"_edit":''); |
|
| 623 | - if (!isset($infos['icone_objet'])) |
|
| 624 | - $infos['icone_objet'] = $infos['type']; |
|
| 625 | - |
|
| 626 | - // chaines de langue |
|
| 627 | - // par defaut : objet:icone_xxx_objet |
|
| 628 | - if (!isset($infos['texte_retour'])) |
|
| 629 | - $infos['texte_retour'] = 'icone_retour'; |
|
| 630 | - if (!isset($infos['texte_modifier'])) |
|
| 631 | - $infos['texte_modifier'] = $infos['type'].':'.'icone_modifier_'.$infos['type']; |
|
| 632 | - if (!isset($infos['texte_creer'])) |
|
| 633 | - $infos['texte_creer'] = $infos['type'].':'.'icone_creer_'.$infos['type']; |
|
| 634 | - if (!isset($infos['texte_creer_associer'])) |
|
| 635 | - $infos['texte_creer_associer'] = $infos['type'].':'.'texte_creer_associer_'.$infos['type']; |
|
| 636 | - if (!isset($infos['texte_ajouter'])) // Ajouter un X |
|
| 637 | - $infos['texte_ajouter'] = $infos['type'].':'.'texte_ajouter_'.$infos['type']; |
|
| 638 | - if (!isset($infos['texte_objets'])) |
|
| 639 | - $infos['texte_objets'] = $infos['type'].':'.'titre_'.$infos['table_objet']; |
|
| 640 | - if (!isset($infos['texte_objet'])) |
|
| 641 | - $infos['texte_objet'] = $infos['type'].':'.'titre_'.$infos['type']; |
|
| 642 | - if (!isset($infos['texte_logo_objet'])) // objet:titre_logo_objet "Logo de ce X" |
|
| 643 | - $infos['texte_logo_objet'] = $infos['type'].':'.'titre_logo_'.$infos['type']; |
|
| 644 | - if (!isset($infos['texte_langue_objet'])) // objet:texte_langue_objet "Langue de ce X" |
|
| 645 | - $infos['texte_langue_objet'] = $infos['type'].':'.'titre_langue_'.$infos['type']; |
|
| 646 | - if (!isset($infos['texte_definir_comme_traduction_objet'])) // "Ce X est une traduction du X numéro :" |
|
| 647 | - $infos['texte_definir_comme_traduction_objet'] = $infos['type'].':'.'texte_definir_comme_traduction_'.$infos['type']; |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - // objet:info_aucun_objet |
|
| 651 | - if (!isset($infos['info_aucun_objet'])) |
|
| 652 | - $infos['info_aucun_objet'] = $infos['type'].':'.'info_aucun_'.$infos['type']; |
|
| 653 | - // objet:info_1_objet |
|
| 654 | - if (!isset($infos['info_1_objet'])) |
|
| 655 | - $infos['info_1_objet'] = $infos['type'].':'.'info_1_'.$infos['type']; |
|
| 656 | - // objet:info_nb_objets |
|
| 657 | - if (!isset($infos['info_nb_objets'])) |
|
| 658 | - $infos['info_nb_objets'] = $infos['type'].':'.'info_nb_'.$infos['table_objet']; |
|
| 659 | - |
|
| 660 | - |
|
| 661 | - if (!isset($infos['champs_editables'])) |
|
| 662 | - $infos['champs_editables'] = array(); |
|
| 663 | - if (!isset($infos['champs_versionnes'])) |
|
| 664 | - $infos['champs_versionnes'] = array(); |
|
| 665 | - if (!isset($infos['rechercher_champs'])) |
|
| 666 | - $infos['rechercher_champs'] = array(); |
|
| 667 | - if (!isset($infos['rechercher_jointures'])) |
|
| 668 | - $infos['rechercher_jointures'] = array(); |
|
| 669 | - |
|
| 670 | - if (!isset($infos['modeles'])) |
|
| 671 | - $infos['modeles'] = array($infos['type']); |
|
| 672 | - |
|
| 673 | - return $infos; |
|
| 582 | + if (!isset($infos['type'])){ |
|
| 583 | + // si on arrive de base/trouver_table, on a la cle primaire : |
|
| 584 | + // s'en servir pour extrapoler le type |
|
| 585 | + if (isset($infos['key']["PRIMARY KEY"])){ |
|
| 586 | + $primary = $infos['key']["PRIMARY KEY"]; |
|
| 587 | + $primary = explode(',',$primary); |
|
| 588 | + $primary = reset($primary); |
|
| 589 | + $infos['type'] = preg_replace(',^spip_|^id_|s$,', '', $primary); |
|
| 590 | + } |
|
| 591 | + else |
|
| 592 | + $infos['type'] = preg_replace(',^spip_|s$,', '', $table_sql); |
|
| 593 | + } |
|
| 594 | + if (!isset($infos['type_surnoms'])) |
|
| 595 | + $infos['type_surnoms'] = array(); |
|
| 596 | + |
|
| 597 | + if (!isset($infos['table_objet'])) |
|
| 598 | + $infos['table_objet'] = preg_replace(',^spip_,', '', $table_sql); |
|
| 599 | + if (!isset($infos['table_objet_surnoms'])) |
|
| 600 | + $infos['table_objet_surnoms'] = array(); |
|
| 601 | + |
|
| 602 | + if (!isset($infos['principale'])) |
|
| 603 | + $infos['principale'] = (isset($GLOBALS['tables_principales'][$table_sql])?'oui':false); |
|
| 604 | + |
|
| 605 | + // normaliser pour pouvoir tester en php $infos['principale']? |
|
| 606 | + // et dans une boucle {principale=oui} |
|
| 607 | + $infos['principale'] = (($infos['principale'] AND $infos['principale']!='non')?'oui':false); |
|
| 608 | + |
|
| 609 | + // declarer et normaliser pour pouvoir tester en php $infos['editable']? |
|
| 610 | + // et dans une boucle {editable=oui} |
|
| 611 | + if (!isset($infos['editable'])) $infos['editable'] = 'oui'; |
|
| 612 | + $infos['editable'] = (($infos['editable'] AND $infos['editable']!='non')?'oui':false); |
|
| 613 | + |
|
| 614 | + // les urls publiques sont par defaut page=type pour les tables principales, et rien pour les autres |
|
| 615 | + // seules les exceptions sont donc a declarer |
|
| 616 | + if (!isset($infos['page'])) |
|
| 617 | + $infos['page'] = ($infos['principale']?$infos['type']:''); |
|
| 618 | + |
|
| 619 | + if (!isset($infos['url_voir'])) |
|
| 620 | + $infos['url_voir'] = $infos['type']; |
|
| 621 | + if (!isset($infos['url_edit'])) |
|
| 622 | + $infos['url_edit'] = $infos['url_voir'].($infos['editable']?"_edit":''); |
|
| 623 | + if (!isset($infos['icone_objet'])) |
|
| 624 | + $infos['icone_objet'] = $infos['type']; |
|
| 625 | + |
|
| 626 | + // chaines de langue |
|
| 627 | + // par defaut : objet:icone_xxx_objet |
|
| 628 | + if (!isset($infos['texte_retour'])) |
|
| 629 | + $infos['texte_retour'] = 'icone_retour'; |
|
| 630 | + if (!isset($infos['texte_modifier'])) |
|
| 631 | + $infos['texte_modifier'] = $infos['type'].':'.'icone_modifier_'.$infos['type']; |
|
| 632 | + if (!isset($infos['texte_creer'])) |
|
| 633 | + $infos['texte_creer'] = $infos['type'].':'.'icone_creer_'.$infos['type']; |
|
| 634 | + if (!isset($infos['texte_creer_associer'])) |
|
| 635 | + $infos['texte_creer_associer'] = $infos['type'].':'.'texte_creer_associer_'.$infos['type']; |
|
| 636 | + if (!isset($infos['texte_ajouter'])) // Ajouter un X |
|
| 637 | + $infos['texte_ajouter'] = $infos['type'].':'.'texte_ajouter_'.$infos['type']; |
|
| 638 | + if (!isset($infos['texte_objets'])) |
|
| 639 | + $infos['texte_objets'] = $infos['type'].':'.'titre_'.$infos['table_objet']; |
|
| 640 | + if (!isset($infos['texte_objet'])) |
|
| 641 | + $infos['texte_objet'] = $infos['type'].':'.'titre_'.$infos['type']; |
|
| 642 | + if (!isset($infos['texte_logo_objet'])) // objet:titre_logo_objet "Logo de ce X" |
|
| 643 | + $infos['texte_logo_objet'] = $infos['type'].':'.'titre_logo_'.$infos['type']; |
|
| 644 | + if (!isset($infos['texte_langue_objet'])) // objet:texte_langue_objet "Langue de ce X" |
|
| 645 | + $infos['texte_langue_objet'] = $infos['type'].':'.'titre_langue_'.$infos['type']; |
|
| 646 | + if (!isset($infos['texte_definir_comme_traduction_objet'])) // "Ce X est une traduction du X numéro :" |
|
| 647 | + $infos['texte_definir_comme_traduction_objet'] = $infos['type'].':'.'texte_definir_comme_traduction_'.$infos['type']; |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + // objet:info_aucun_objet |
|
| 651 | + if (!isset($infos['info_aucun_objet'])) |
|
| 652 | + $infos['info_aucun_objet'] = $infos['type'].':'.'info_aucun_'.$infos['type']; |
|
| 653 | + // objet:info_1_objet |
|
| 654 | + if (!isset($infos['info_1_objet'])) |
|
| 655 | + $infos['info_1_objet'] = $infos['type'].':'.'info_1_'.$infos['type']; |
|
| 656 | + // objet:info_nb_objets |
|
| 657 | + if (!isset($infos['info_nb_objets'])) |
|
| 658 | + $infos['info_nb_objets'] = $infos['type'].':'.'info_nb_'.$infos['table_objet']; |
|
| 659 | + |
|
| 660 | + |
|
| 661 | + if (!isset($infos['champs_editables'])) |
|
| 662 | + $infos['champs_editables'] = array(); |
|
| 663 | + if (!isset($infos['champs_versionnes'])) |
|
| 664 | + $infos['champs_versionnes'] = array(); |
|
| 665 | + if (!isset($infos['rechercher_champs'])) |
|
| 666 | + $infos['rechercher_champs'] = array(); |
|
| 667 | + if (!isset($infos['rechercher_jointures'])) |
|
| 668 | + $infos['rechercher_jointures'] = array(); |
|
| 669 | + |
|
| 670 | + if (!isset($infos['modeles'])) |
|
| 671 | + $infos['modeles'] = array($infos['type']); |
|
| 672 | + |
|
| 673 | + return $infos; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -687,27 +687,27 @@ discard block |
||
| 687 | 687 | * @return array |
| 688 | 688 | */ |
| 689 | 689 | function renseigner_table_objet_interfaces($table_sql,&$infos){ |
| 690 | - if (!isset($infos['titre'])){ |
|
| 691 | - if (isset($infos['table_objet']) AND isset($GLOBALS['table_titre'][$infos['table_objet']])) |
|
| 692 | - $infos['titre'] = $GLOBALS['table_titre'][$infos['table_objet']]; |
|
| 693 | - else { |
|
| 694 | - $infos['titre'] = ((isset($infos['field']['titre']))?"titre,":"'' as titre,"); |
|
| 695 | - $infos['titre'] .= ((isset($infos['field']['lang']))?"lang":"'' as lang"); |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - if (!isset($infos['date'])){ |
|
| 699 | - if (isset($infos['table_objet']) and isset($GLOBALS['table_date'][$infos['table_objet']])) |
|
| 700 | - $infos['date'] = $GLOBALS['table_date'][$infos['table_objet']]; |
|
| 701 | - else |
|
| 702 | - $infos['date'] = ((isset($infos['field']['date']))?"date":''); |
|
| 703 | - } |
|
| 704 | - if (!isset($infos['statut'])) |
|
| 705 | - $infos['statut'] = isset($GLOBALS['table_statut'][$table_sql]) ? $GLOBALS['table_statut'][$table_sql] : ''; |
|
| 706 | - if (!isset($infos['tables_jointures'])) |
|
| 707 | - $infos['tables_jointures'] = array(); |
|
| 708 | - if (isset($GLOBALS['tables_jointures'][$table_sql])) |
|
| 709 | - $infos['tables_jointures'] = array_merge($infos['tables_jointures'],$GLOBALS['tables_jointures'][$table_sql]); |
|
| 710 | - return $infos; |
|
| 690 | + if (!isset($infos['titre'])){ |
|
| 691 | + if (isset($infos['table_objet']) AND isset($GLOBALS['table_titre'][$infos['table_objet']])) |
|
| 692 | + $infos['titre'] = $GLOBALS['table_titre'][$infos['table_objet']]; |
|
| 693 | + else { |
|
| 694 | + $infos['titre'] = ((isset($infos['field']['titre']))?"titre,":"'' as titre,"); |
|
| 695 | + $infos['titre'] .= ((isset($infos['field']['lang']))?"lang":"'' as lang"); |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + if (!isset($infos['date'])){ |
|
| 699 | + if (isset($infos['table_objet']) and isset($GLOBALS['table_date'][$infos['table_objet']])) |
|
| 700 | + $infos['date'] = $GLOBALS['table_date'][$infos['table_objet']]; |
|
| 701 | + else |
|
| 702 | + $infos['date'] = ((isset($infos['field']['date']))?"date":''); |
|
| 703 | + } |
|
| 704 | + if (!isset($infos['statut'])) |
|
| 705 | + $infos['statut'] = isset($GLOBALS['table_statut'][$table_sql]) ? $GLOBALS['table_statut'][$table_sql] : ''; |
|
| 706 | + if (!isset($infos['tables_jointures'])) |
|
| 707 | + $infos['tables_jointures'] = array(); |
|
| 708 | + if (isset($GLOBALS['tables_jointures'][$table_sql])) |
|
| 709 | + $infos['tables_jointures'] = array_merge($infos['tables_jointures'],$GLOBALS['tables_jointures'][$table_sql]); |
|
| 710 | + return $infos; |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
@@ -718,12 +718,12 @@ discard block |
||
| 718 | 718 | * Liste et descriptions des tables principales |
| 719 | 719 | **/ |
| 720 | 720 | function lister_tables_principales(){ |
| 721 | - static $done = false; |
|
| 722 | - if (!$done OR !count($GLOBALS['tables_principales'])){ |
|
| 723 | - lister_tables_objets_sql(); |
|
| 724 | - $done = true; |
|
| 725 | - } |
|
| 726 | - return $GLOBALS['tables_principales']; |
|
| 721 | + static $done = false; |
|
| 722 | + if (!$done OR !count($GLOBALS['tables_principales'])){ |
|
| 723 | + lister_tables_objets_sql(); |
|
| 724 | + $done = true; |
|
| 725 | + } |
|
| 726 | + return $GLOBALS['tables_principales']; |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
@@ -734,12 +734,12 @@ discard block |
||
| 734 | 734 | * Liste et descriptions des tables auxiliaires |
| 735 | 735 | **/ |
| 736 | 736 | function lister_tables_auxiliaires(){ |
| 737 | - static $done = false; |
|
| 738 | - if (!$done OR !count($GLOBALS['tables_auxiliaires'])){ |
|
| 739 | - lister_tables_objets_sql(); |
|
| 740 | - $done = true; |
|
| 741 | - } |
|
| 742 | - return $GLOBALS['tables_auxiliaires']; |
|
| 737 | + static $done = false; |
|
| 738 | + if (!$done OR !count($GLOBALS['tables_auxiliaires'])){ |
|
| 739 | + lister_tables_objets_sql(); |
|
| 740 | + $done = true; |
|
| 741 | + } |
|
| 742 | + return $GLOBALS['tables_auxiliaires']; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
@@ -747,38 +747,38 @@ discard block |
||
| 747 | 747 | * @return array |
| 748 | 748 | */ |
| 749 | 749 | function lister_tables_objets_surnoms(){ |
| 750 | - static $surnoms = null; |
|
| 751 | - static $md5 = null; |
|
| 752 | - if (!$surnoms |
|
| 753 | - OR $md5 != lister_tables_objets_sql('::md5')){ |
|
| 754 | - // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 755 | - // pour compatibilite, car il faut dorenavent utiliser |
|
| 756 | - // declarer_table_objets_sql |
|
| 757 | - $surnoms = pipeline('declarer_tables_objets_surnoms', |
|
| 758 | - array( |
|
| 759 | - # pour les modeles |
|
| 760 | - # a enlever ? |
|
| 761 | - 'doc' => 'documents', |
|
| 762 | - 'img' => 'documents', |
|
| 763 | - 'emb' => 'documents', |
|
| 764 | - )); |
|
| 765 | - $infos_tables = lister_tables_objets_sql(); |
|
| 766 | - foreach($infos_tables as $t=>$infos){ |
|
| 767 | - // cas de base type=>table |
|
| 768 | - // et preg_replace(',^spip_|^id_|s$,',table)=>table |
|
| 769 | - if ($infos['table_objet']){ // securite, si la fonction est appelee trop tot, c'est vide |
|
| 770 | - // optimisations pour table_objet |
|
| 771 | - //$surnoms[$infos['type']] = $infos['table_objet']; |
|
| 772 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['table_objet']; |
|
| 773 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['table_objet']; |
|
| 774 | - if (is_array($infos['table_objet_surnoms']) AND count($infos['table_objet_surnoms'])) |
|
| 775 | - foreach($infos['table_objet_surnoms'] as $surnom) |
|
| 776 | - $surnoms[$surnom] = $infos['table_objet']; |
|
| 777 | - } |
|
| 778 | - } |
|
| 779 | - $md5 = lister_tables_objets_sql('::md5'); |
|
| 780 | - } |
|
| 781 | - return $surnoms; |
|
| 750 | + static $surnoms = null; |
|
| 751 | + static $md5 = null; |
|
| 752 | + if (!$surnoms |
|
| 753 | + OR $md5 != lister_tables_objets_sql('::md5')){ |
|
| 754 | + // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 755 | + // pour compatibilite, car il faut dorenavent utiliser |
|
| 756 | + // declarer_table_objets_sql |
|
| 757 | + $surnoms = pipeline('declarer_tables_objets_surnoms', |
|
| 758 | + array( |
|
| 759 | + # pour les modeles |
|
| 760 | + # a enlever ? |
|
| 761 | + 'doc' => 'documents', |
|
| 762 | + 'img' => 'documents', |
|
| 763 | + 'emb' => 'documents', |
|
| 764 | + )); |
|
| 765 | + $infos_tables = lister_tables_objets_sql(); |
|
| 766 | + foreach($infos_tables as $t=>$infos){ |
|
| 767 | + // cas de base type=>table |
|
| 768 | + // et preg_replace(',^spip_|^id_|s$,',table)=>table |
|
| 769 | + if ($infos['table_objet']){ // securite, si la fonction est appelee trop tot, c'est vide |
|
| 770 | + // optimisations pour table_objet |
|
| 771 | + //$surnoms[$infos['type']] = $infos['table_objet']; |
|
| 772 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['table_objet']; |
|
| 773 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['table_objet']; |
|
| 774 | + if (is_array($infos['table_objet_surnoms']) AND count($infos['table_objet_surnoms'])) |
|
| 775 | + foreach($infos['table_objet_surnoms'] as $surnom) |
|
| 776 | + $surnoms[$surnom] = $infos['table_objet']; |
|
| 777 | + } |
|
| 778 | + } |
|
| 779 | + $md5 = lister_tables_objets_sql('::md5'); |
|
| 780 | + } |
|
| 781 | + return $surnoms; |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -786,61 +786,61 @@ discard block |
||
| 786 | 786 | * @return array |
| 787 | 787 | */ |
| 788 | 788 | function lister_types_surnoms(){ |
| 789 | - static $surnoms = null; |
|
| 790 | - static $md5 = null; |
|
| 791 | - if (!$surnoms |
|
| 792 | - OR $md5 != lister_tables_objets_sql('::md5')){ |
|
| 793 | - // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 794 | - // pour compatibilite, car il faut dorenavent utiliser |
|
| 795 | - // declarer_table_objets_sql |
|
| 796 | - $surnoms = pipeline('declarer_type_surnoms', array('racine-site'=>'site')); |
|
| 797 | - $infos_tables = lister_tables_objets_sql(); |
|
| 798 | - foreach($infos_tables as $t=>$infos){ |
|
| 799 | - if ($infos['type']){ // securite, si la fonction est appelee trop tot, c'est vide |
|
| 800 | - // optimisations pour objet_type |
|
| 801 | - //$surnoms[$infos['type']] = $infos['type']; |
|
| 802 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['type']; |
|
| 803 | - $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['type']; |
|
| 804 | - // surnoms declares |
|
| 805 | - if (is_array($infos['type_surnoms']) AND count($infos['type_surnoms'])) |
|
| 806 | - foreach($infos['type_surnoms'] as $surnom) |
|
| 807 | - $surnoms[$surnom] = $infos['type']; |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - $md5 = lister_tables_objets_sql('::md5'); |
|
| 811 | - } |
|
| 812 | - return $surnoms; |
|
| 789 | + static $surnoms = null; |
|
| 790 | + static $md5 = null; |
|
| 791 | + if (!$surnoms |
|
| 792 | + OR $md5 != lister_tables_objets_sql('::md5')){ |
|
| 793 | + // passer dans un pipeline qui permet aux plugins de declarer leurs exceptions |
|
| 794 | + // pour compatibilite, car il faut dorenavent utiliser |
|
| 795 | + // declarer_table_objets_sql |
|
| 796 | + $surnoms = pipeline('declarer_type_surnoms', array('racine-site'=>'site')); |
|
| 797 | + $infos_tables = lister_tables_objets_sql(); |
|
| 798 | + foreach($infos_tables as $t=>$infos){ |
|
| 799 | + if ($infos['type']){ // securite, si la fonction est appelee trop tot, c'est vide |
|
| 800 | + // optimisations pour objet_type |
|
| 801 | + //$surnoms[$infos['type']] = $infos['type']; |
|
| 802 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['table_objet'])] = $infos['type']; |
|
| 803 | + $surnoms[preg_replace(',^spip_|^id_|s$,', '', $infos['type'])] = $infos['type']; |
|
| 804 | + // surnoms declares |
|
| 805 | + if (is_array($infos['type_surnoms']) AND count($infos['type_surnoms'])) |
|
| 806 | + foreach($infos['type_surnoms'] as $surnom) |
|
| 807 | + $surnoms[$surnom] = $infos['type']; |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + $md5 = lister_tables_objets_sql('::md5'); |
|
| 811 | + } |
|
| 812 | + return $surnoms; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | function lister_tables_spip($serveur=''){ |
| 816 | - static $tables = array(); |
|
| 817 | - if (!isset($tables[$serveur])){ |
|
| 818 | - $tables[$serveur] = array(); |
|
| 819 | - if (!function_exists("sql_alltable")) |
|
| 820 | - include_spip("base/abstract_sql"); |
|
| 821 | - $ts = sql_alltable(null,$serveur); // toutes les tables "spip_" (ou prefixe perso) |
|
| 822 | - $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 823 | - $spip = $connexion['prefixe'] . '_'; |
|
| 824 | - foreach ($ts as $t){ |
|
| 825 | - $t = substr($t,strlen($spip)); |
|
| 826 | - $tables[$serveur]["spip_$t"] = $t; |
|
| 827 | - } |
|
| 828 | - } |
|
| 829 | - return $tables[$serveur]; |
|
| 816 | + static $tables = array(); |
|
| 817 | + if (!isset($tables[$serveur])){ |
|
| 818 | + $tables[$serveur] = array(); |
|
| 819 | + if (!function_exists("sql_alltable")) |
|
| 820 | + include_spip("base/abstract_sql"); |
|
| 821 | + $ts = sql_alltable(null,$serveur); // toutes les tables "spip_" (ou prefixe perso) |
|
| 822 | + $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 823 | + $spip = $connexion['prefixe'] . '_'; |
|
| 824 | + foreach ($ts as $t){ |
|
| 825 | + $t = substr($t,strlen($spip)); |
|
| 826 | + $tables[$serveur]["spip_$t"] = $t; |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | + return $tables[$serveur]; |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | function lister_toutes_tables($serveur){ |
| 833 | - static $tables = array(); |
|
| 834 | - if (!isset($tables[$serveur])){ |
|
| 835 | - $tables[$serveur] = array(); |
|
| 836 | - if (!function_exists("sql_alltable")) |
|
| 837 | - include_spip("base/abstract_sql"); |
|
| 838 | - $ts = sql_alltable('%',$serveur); // toutes les tables |
|
| 839 | - foreach ($ts as $t){ |
|
| 840 | - $tables[$serveur][$t] = $t; |
|
| 841 | - } |
|
| 842 | - } |
|
| 843 | - return $tables[$serveur]; |
|
| 833 | + static $tables = array(); |
|
| 834 | + if (!isset($tables[$serveur])){ |
|
| 835 | + $tables[$serveur] = array(); |
|
| 836 | + if (!function_exists("sql_alltable")) |
|
| 837 | + include_spip("base/abstract_sql"); |
|
| 838 | + $ts = sql_alltable('%',$serveur); // toutes les tables |
|
| 839 | + foreach ($ts as $t){ |
|
| 840 | + $tables[$serveur][$t] = $t; |
|
| 841 | + } |
|
| 842 | + } |
|
| 843 | + return $tables[$serveur]; |
|
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | /** |
@@ -860,31 +860,31 @@ discard block |
||
| 860 | 860 | * Nom de l'objet |
| 861 | 861 | **/ |
| 862 | 862 | function table_objet($type,$serveur='') { |
| 863 | - $surnoms = lister_tables_objets_surnoms(); |
|
| 864 | - $type = preg_replace(',^spip_|^id_|s$,', '', $type); |
|
| 865 | - if (!$type) return; |
|
| 866 | - if (isset($surnoms[$type])) |
|
| 867 | - return $surnoms[$type]; |
|
| 868 | - |
|
| 869 | - if ($serveur!==false){ |
|
| 870 | - $t=lister_tables_spip($serveur); |
|
| 871 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 872 | - $typetrim = rtrim($type,'s')."s"; |
|
| 873 | - if ( |
|
| 874 | - (isset($t[$typetrim]) OR in_array($typetrim,$t)) |
|
| 875 | - AND ($desc = $trouver_table(rtrim($type,'s')."s",$serveur)) |
|
| 876 | - ) |
|
| 877 | - return $desc['id_table']; |
|
| 878 | - elseif ( |
|
| 879 | - (isset($t[$type]) OR in_array($type,$t)) |
|
| 880 | - AND ($desc = $trouver_table($type,$serveur)) |
|
| 881 | - ) |
|
| 882 | - return $desc['id_table']; |
|
| 883 | - |
|
| 884 | - spip_log( 'table_objet('.$type.') calculee sans verification'); |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - return rtrim($type,'s')."s"; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 863 | + $surnoms = lister_tables_objets_surnoms(); |
|
| 864 | + $type = preg_replace(',^spip_|^id_|s$,', '', $type); |
|
| 865 | + if (!$type) return; |
|
| 866 | + if (isset($surnoms[$type])) |
|
| 867 | + return $surnoms[$type]; |
|
| 868 | + |
|
| 869 | + if ($serveur!==false){ |
|
| 870 | + $t=lister_tables_spip($serveur); |
|
| 871 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 872 | + $typetrim = rtrim($type,'s')."s"; |
|
| 873 | + if ( |
|
| 874 | + (isset($t[$typetrim]) OR in_array($typetrim,$t)) |
|
| 875 | + AND ($desc = $trouver_table(rtrim($type,'s')."s",$serveur)) |
|
| 876 | + ) |
|
| 877 | + return $desc['id_table']; |
|
| 878 | + elseif ( |
|
| 879 | + (isset($t[$type]) OR in_array($type,$t)) |
|
| 880 | + AND ($desc = $trouver_table($type,$serveur)) |
|
| 881 | + ) |
|
| 882 | + return $desc['id_table']; |
|
| 883 | + |
|
| 884 | + spip_log( 'table_objet('.$type.') calculee sans verification'); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + return rtrim($type,'s')."s"; # cas historique ne devant plus servir, sauf si $serveur=false |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
@@ -904,29 +904,29 @@ discard block |
||
| 904 | 904 | * Nom de la table SQL |
| 905 | 905 | **/ |
| 906 | 906 | function table_objet_sql($type,$serveur='') { |
| 907 | - global $table_des_tables; |
|
| 908 | - $nom = table_objet($type, $serveur); |
|
| 909 | - if (!isset($table_des_tables['articles'])) // eviter de multiples inclusions |
|
| 910 | - include_spip('public/interfaces'); |
|
| 911 | - if (isset($table_des_tables[$nom])) { |
|
| 912 | - $nom = $table_des_tables[$nom]; |
|
| 913 | - $nom = "spip_$nom"; |
|
| 914 | - } |
|
| 915 | - else { |
|
| 916 | - $infos_tables = lister_tables_objets_sql(); |
|
| 917 | - if (isset($infos_tables["spip_$nom"])) |
|
| 918 | - $nom = "spip_$nom"; |
|
| 919 | - elseif($serveur!==false) { |
|
| 920 | - $t=lister_tables_spip($serveur); |
|
| 921 | - if (isset($t[$nom]) OR in_array($nom,$t)){ |
|
| 922 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 923 | - if ($desc = $trouver_table($nom,$serveur)) |
|
| 924 | - return $desc['table_sql']; |
|
| 925 | - } |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - return $nom ; |
|
| 907 | + global $table_des_tables; |
|
| 908 | + $nom = table_objet($type, $serveur); |
|
| 909 | + if (!isset($table_des_tables['articles'])) // eviter de multiples inclusions |
|
| 910 | + include_spip('public/interfaces'); |
|
| 911 | + if (isset($table_des_tables[$nom])) { |
|
| 912 | + $nom = $table_des_tables[$nom]; |
|
| 913 | + $nom = "spip_$nom"; |
|
| 914 | + } |
|
| 915 | + else { |
|
| 916 | + $infos_tables = lister_tables_objets_sql(); |
|
| 917 | + if (isset($infos_tables["spip_$nom"])) |
|
| 918 | + $nom = "spip_$nom"; |
|
| 919 | + elseif($serveur!==false) { |
|
| 920 | + $t=lister_tables_spip($serveur); |
|
| 921 | + if (isset($t[$nom]) OR in_array($nom,$t)){ |
|
| 922 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 923 | + if ($desc = $trouver_table($nom,$serveur)) |
|
| 924 | + return $desc['table_sql']; |
|
| 925 | + } |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + return $nom ; |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | /** |
@@ -945,26 +945,26 @@ discard block |
||
| 945 | 945 | * Nom de la clé primaire |
| 946 | 946 | **/ |
| 947 | 947 | function id_table_objet($type,$serveur='') { |
| 948 | - static $trouver_table = null; |
|
| 949 | - $type = objet_type($type,$serveur); |
|
| 950 | - if (!$type) return; |
|
| 951 | - $t = table_objet($type); |
|
| 952 | - if (!$trouver_table) |
|
| 953 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 954 | - |
|
| 955 | - $ts=lister_tables_spip($serveur); |
|
| 956 | - if (in_array($t,$ts) |
|
| 957 | - OR in_array($t,lister_toutes_tables($serveur))){ |
|
| 958 | - $desc = $trouver_table($t,$serveur); |
|
| 959 | - if (isset($desc['key']['PRIMARY KEY'])) |
|
| 960 | - return $desc['key']['PRIMARY KEY']; |
|
| 961 | - if (!$desc OR isset($desc['field']["id_$type"])) |
|
| 962 | - return "id_$type"; |
|
| 963 | - // sinon renvoyer le premier champ de la table... |
|
| 964 | - $keys = array_keys($desc['field']); |
|
| 965 | - return array_shift($keys); |
|
| 966 | - } |
|
| 967 | - return "id_$type"; |
|
| 948 | + static $trouver_table = null; |
|
| 949 | + $type = objet_type($type,$serveur); |
|
| 950 | + if (!$type) return; |
|
| 951 | + $t = table_objet($type); |
|
| 952 | + if (!$trouver_table) |
|
| 953 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 954 | + |
|
| 955 | + $ts=lister_tables_spip($serveur); |
|
| 956 | + if (in_array($t,$ts) |
|
| 957 | + OR in_array($t,lister_toutes_tables($serveur))){ |
|
| 958 | + $desc = $trouver_table($t,$serveur); |
|
| 959 | + if (isset($desc['key']['PRIMARY KEY'])) |
|
| 960 | + return $desc['key']['PRIMARY KEY']; |
|
| 961 | + if (!$desc OR isset($desc['field']["id_$type"])) |
|
| 962 | + return "id_$type"; |
|
| 963 | + // sinon renvoyer le premier champ de la table... |
|
| 964 | + $keys = array_keys($desc['field']); |
|
| 965 | + return array_shift($keys); |
|
| 966 | + } |
|
| 967 | + return "id_$type"; |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -983,49 +983,49 @@ discard block |
||
| 983 | 983 | * Type de l'objet |
| 984 | 984 | **/ |
| 985 | 985 | function objet_type($table_objet, $serveur=''){ |
| 986 | - if (!$table_objet) return; |
|
| 987 | - $surnoms = lister_types_surnoms(); |
|
| 988 | - |
|
| 989 | - // scenario de base |
|
| 990 | - // le type est decline a partir du nom de la table en enlevant le prefixe eventuel |
|
| 991 | - // et la marque du pluriel |
|
| 992 | - // on accepte id_xx en entree aussi |
|
| 993 | - $type = preg_replace(',^spip_|^id_|s$,', '', $table_objet); |
|
| 994 | - if (isset($surnoms[$type])) |
|
| 995 | - return $surnoms[$type]; |
|
| 996 | - |
|
| 997 | - // securite : eliminer les caracteres non \w |
|
| 998 | - $type = preg_replace(',[^\w-],','',$type); |
|
| 999 | - |
|
| 1000 | - // si le type redonne bien la table c'est bon |
|
| 1001 | - // oui si table_objet ressemblait deja a un type |
|
| 1002 | - if ( $type==$table_objet |
|
| 1003 | - OR (table_objet($type,$serveur)==$table_objet) |
|
| 1004 | - OR (table_objet_sql($type,$serveur)==$table_objet)) |
|
| 1005 | - return $type; |
|
| 1006 | - |
|
| 1007 | - // si on ne veut pas chercher en base |
|
| 1008 | - if ($serveur===false) |
|
| 1009 | - return $type; |
|
| 1010 | - |
|
| 1011 | - // sinon on passe par la cle primaire id_xx pour trouver le type |
|
| 1012 | - // car le s a la fin est incertain |
|
| 1013 | - // notamment en cas de pluriel derogatoire |
|
| 1014 | - // id_jeu/spip_jeux id_journal/spip_journaux qui necessitent tout deux |
|
| 1015 | - // une declaration jeu => jeux, journal => journaux |
|
| 1016 | - // dans le pipeline declarer_tables_objets_surnoms |
|
| 1017 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1018 | - $ts=lister_tables_spip($serveur); |
|
| 1019 | - if (in_array($table_objet,$ts)) |
|
| 1020 | - $desc = $trouver_table($table_objet); |
|
| 1021 | - if (!$desc AND in_array($table_objet=table_objet($type,$serveur),$ts)) |
|
| 1022 | - $desc = $trouver_table($table_objet,$serveur); |
|
| 1023 | - // si le type est declare : bingo ! |
|
| 1024 | - if ($desc AND isset($desc['type'])) |
|
| 1025 | - return $desc['type']; |
|
| 1026 | - |
|
| 1027 | - // on a fait ce qu'on a pu |
|
| 1028 | - return $type; |
|
| 986 | + if (!$table_objet) return; |
|
| 987 | + $surnoms = lister_types_surnoms(); |
|
| 988 | + |
|
| 989 | + // scenario de base |
|
| 990 | + // le type est decline a partir du nom de la table en enlevant le prefixe eventuel |
|
| 991 | + // et la marque du pluriel |
|
| 992 | + // on accepte id_xx en entree aussi |
|
| 993 | + $type = preg_replace(',^spip_|^id_|s$,', '', $table_objet); |
|
| 994 | + if (isset($surnoms[$type])) |
|
| 995 | + return $surnoms[$type]; |
|
| 996 | + |
|
| 997 | + // securite : eliminer les caracteres non \w |
|
| 998 | + $type = preg_replace(',[^\w-],','',$type); |
|
| 999 | + |
|
| 1000 | + // si le type redonne bien la table c'est bon |
|
| 1001 | + // oui si table_objet ressemblait deja a un type |
|
| 1002 | + if ( $type==$table_objet |
|
| 1003 | + OR (table_objet($type,$serveur)==$table_objet) |
|
| 1004 | + OR (table_objet_sql($type,$serveur)==$table_objet)) |
|
| 1005 | + return $type; |
|
| 1006 | + |
|
| 1007 | + // si on ne veut pas chercher en base |
|
| 1008 | + if ($serveur===false) |
|
| 1009 | + return $type; |
|
| 1010 | + |
|
| 1011 | + // sinon on passe par la cle primaire id_xx pour trouver le type |
|
| 1012 | + // car le s a la fin est incertain |
|
| 1013 | + // notamment en cas de pluriel derogatoire |
|
| 1014 | + // id_jeu/spip_jeux id_journal/spip_journaux qui necessitent tout deux |
|
| 1015 | + // une declaration jeu => jeux, journal => journaux |
|
| 1016 | + // dans le pipeline declarer_tables_objets_surnoms |
|
| 1017 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1018 | + $ts=lister_tables_spip($serveur); |
|
| 1019 | + if (in_array($table_objet,$ts)) |
|
| 1020 | + $desc = $trouver_table($table_objet); |
|
| 1021 | + if (!$desc AND in_array($table_objet=table_objet($type,$serveur),$ts)) |
|
| 1022 | + $desc = $trouver_table($table_objet,$serveur); |
|
| 1023 | + // si le type est declare : bingo ! |
|
| 1024 | + if ($desc AND isset($desc['type'])) |
|
| 1025 | + return $desc['type']; |
|
| 1026 | + |
|
| 1027 | + // on a fait ce qu'on a pu |
|
| 1028 | + return $type; |
|
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | /** |
@@ -1041,37 +1041,37 @@ discard block |
||
| 1041 | 1041 | * @return bool |
| 1042 | 1042 | */ |
| 1043 | 1043 | function objet_test_si_publie($objet,$id_objet, $serveur=''){ |
| 1044 | - // voir si une fonction est definie pour faire le boulot |
|
| 1045 | - // elle a la priorite dans ce cas |
|
| 1046 | - if ($f = charger_fonction($objet."_test_si_publie","base",true)) |
|
| 1047 | - return $f($objet,$id_objet, $serveur); |
|
| 1048 | - |
|
| 1049 | - // sinon on se fie a la declaration de l'objet si presente |
|
| 1050 | - $id_table = $table_objet = table_objet($objet); |
|
| 1051 | - $id_table_objet = id_table_objet($objet, $serveur); |
|
| 1052 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1053 | - if ($desc = $trouver_table($table_objet, $serveur) |
|
| 1054 | - AND isset($desc['statut']) |
|
| 1055 | - AND $desc['statut']){ |
|
| 1056 | - $boucle = new Boucle(); |
|
| 1057 | - $boucle->show = $desc; |
|
| 1058 | - $boucle->nom = 'objet_test_si_publie'; |
|
| 1059 | - $boucle->id_boucle = $id_table; |
|
| 1060 | - $boucle->id_table = $id_table; |
|
| 1061 | - $boucle->sql_serveur = $serveur; |
|
| 1062 | - $boucle->select[] = $id_table_objet; |
|
| 1063 | - $boucle->from[$table_objet] = table_objet_sql($objet, $serveur); |
|
| 1064 | - $boucle->where[] = $id_table.".".$id_table_objet.'='.intval($id_objet); |
|
| 1065 | - |
|
| 1066 | - include_spip('public/compiler'); |
|
| 1067 | - include_spip('public/composer'); |
|
| 1068 | - instituer_boucle($boucle, false, true); |
|
| 1069 | - $res = calculer_select($boucle->select,$boucle->from,$boucle->from_type,$boucle->where,$boucle->join,$boucle->group,$boucle->order,$boucle->limit,$boucle->having,$table_objet,$id_table,$serveur); |
|
| 1070 | - if (sql_fetch($res)) |
|
| 1071 | - return true; |
|
| 1072 | - return false; |
|
| 1073 | - } |
|
| 1074 | - |
|
| 1075 | - // si pas d'info statut ni de fonction : l'objet est publie |
|
| 1076 | - return true; |
|
| 1044 | + // voir si une fonction est definie pour faire le boulot |
|
| 1045 | + // elle a la priorite dans ce cas |
|
| 1046 | + if ($f = charger_fonction($objet."_test_si_publie","base",true)) |
|
| 1047 | + return $f($objet,$id_objet, $serveur); |
|
| 1048 | + |
|
| 1049 | + // sinon on se fie a la declaration de l'objet si presente |
|
| 1050 | + $id_table = $table_objet = table_objet($objet); |
|
| 1051 | + $id_table_objet = id_table_objet($objet, $serveur); |
|
| 1052 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1053 | + if ($desc = $trouver_table($table_objet, $serveur) |
|
| 1054 | + AND isset($desc['statut']) |
|
| 1055 | + AND $desc['statut']){ |
|
| 1056 | + $boucle = new Boucle(); |
|
| 1057 | + $boucle->show = $desc; |
|
| 1058 | + $boucle->nom = 'objet_test_si_publie'; |
|
| 1059 | + $boucle->id_boucle = $id_table; |
|
| 1060 | + $boucle->id_table = $id_table; |
|
| 1061 | + $boucle->sql_serveur = $serveur; |
|
| 1062 | + $boucle->select[] = $id_table_objet; |
|
| 1063 | + $boucle->from[$table_objet] = table_objet_sql($objet, $serveur); |
|
| 1064 | + $boucle->where[] = $id_table.".".$id_table_objet.'='.intval($id_objet); |
|
| 1065 | + |
|
| 1066 | + include_spip('public/compiler'); |
|
| 1067 | + include_spip('public/composer'); |
|
| 1068 | + instituer_boucle($boucle, false, true); |
|
| 1069 | + $res = calculer_select($boucle->select,$boucle->from,$boucle->from_type,$boucle->where,$boucle->join,$boucle->group,$boucle->order,$boucle->limit,$boucle->having,$table_objet,$id_table,$serveur); |
|
| 1070 | + if (sql_fetch($res)) |
|
| 1071 | + return true; |
|
| 1072 | + return false; |
|
| 1073 | + } |
|
| 1074 | + |
|
| 1075 | + // si pas d'info statut ni de fonction : l'objet est publie |
|
| 1076 | + return true; |
|
| 1077 | 1077 | } |
@@ -28,26 +28,26 @@ discard block |
||
| 28 | 28 | // NB: Ce fichier peut ajouter des tables (old-style) |
| 29 | 29 | // donc il faut l'inclure "en globals" |
| 30 | 30 | if ($f = find_in_path('mes_fonctions.php')) { |
| 31 | - global $dossier_squelettes; |
|
| 32 | - @include_once (_ROOT_CWD . $f); |
|
| 31 | + global $dossier_squelettes; |
|
| 32 | + @include_once (_ROOT_CWD . $f); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | if (@is_readable(_CACHE_PLUGINS_FCT)){ |
| 36 | - // chargement optimise precompile |
|
| 37 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 36 | + // chargement optimise precompile |
|
| 37 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | function base_dump_meta_name($rub){ |
| 41 | - return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | + return $meta = "status_dump_{$rub}_" . abs($GLOBALS['visiteur_session']['id_auteur']); |
|
| 42 | 42 | } |
| 43 | 43 | function base_dump_dir($meta){ |
| 44 | - include_spip('inc/documents'); |
|
| 45 | - // determine upload va aussi initialiser l'index "restreint" |
|
| 46 | - $maindir = determine_upload(); |
|
| 47 | - if (!$GLOBALS['visiteur_session']['restreint']) |
|
| 48 | - $maindir = _DIR_DUMP; |
|
| 49 | - $dir = sous_repertoire($maindir, $meta); |
|
| 50 | - return $dir; |
|
| 44 | + include_spip('inc/documents'); |
|
| 45 | + // determine upload va aussi initialiser l'index "restreint" |
|
| 46 | + $maindir = determine_upload(); |
|
| 47 | + if (!$GLOBALS['visiteur_session']['restreint']) |
|
| 48 | + $maindir = _DIR_DUMP; |
|
| 49 | + $dir = sous_repertoire($maindir, $meta); |
|
| 50 | + return $dir; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -61,21 +61,21 @@ discard block |
||
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | 63 | function base_lister_toutes_tables($serveur='', $tables=array(), $exclude = array(),$affiche_vrai_prefixe=false) { |
| 64 | - spip_connect($serveur); |
|
| 65 | - $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 66 | - $prefixe = $connexion['prefixe']; |
|
| 67 | - |
|
| 68 | - $p = '/^' . $prefixe . '/'; |
|
| 69 | - $res = $tables; |
|
| 70 | - foreach(sql_alltable(null,$serveur) as $t) { |
|
| 71 | - if (preg_match($p, $t)) { |
|
| 72 | - $t1 = preg_replace($p, 'spip', $t); |
|
| 73 | - if (!in_array($t1, $tables) AND !in_array($t1, $exclude)) |
|
| 74 | - $res[]= ($affiche_vrai_prefixe?$t:$t1); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - sort($res); |
|
| 78 | - return $res; |
|
| 64 | + spip_connect($serveur); |
|
| 65 | + $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 66 | + $prefixe = $connexion['prefixe']; |
|
| 67 | + |
|
| 68 | + $p = '/^' . $prefixe . '/'; |
|
| 69 | + $res = $tables; |
|
| 70 | + foreach(sql_alltable(null,$serveur) as $t) { |
|
| 71 | + if (preg_match($p, $t)) { |
|
| 72 | + $t1 = preg_replace($p, 'spip', $t); |
|
| 73 | + if (!in_array($t1, $tables) AND !in_array($t1, $exclude)) |
|
| 74 | + $res[]= ($affiche_vrai_prefixe?$t:$t1); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + sort($res); |
|
| 78 | + return $res; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | 86 | function base_prefixe_tables($serveur=''){ |
| 87 | - spip_connect($serveur); |
|
| 88 | - $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 89 | - $prefixe = $connexion['prefixe']; |
|
| 90 | - return $prefixe; |
|
| 87 | + spip_connect($serveur); |
|
| 88 | + $connexion = $GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 89 | + $prefixe = $connexion['prefixe']; |
|
| 90 | + return $prefixe; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -102,26 +102,26 @@ discard block |
||
| 102 | 102 | * @return array |
| 103 | 103 | */ |
| 104 | 104 | function base_saisie_tables($name, $tables, $exclude = array(), $post=null, $serveur='') { |
| 105 | - include_spip('inc/filtres'); |
|
| 106 | - $res = array(); |
|
| 107 | - foreach ($tables as $k => $t) { |
|
| 108 | - // par defaut tout est coche sauf les tables dans $exclude |
|
| 109 | - if (is_null($post)) |
|
| 110 | - $check = (in_array($t,$exclude)?false:true); |
|
| 111 | - // mais si on a poste une selection, la reprendre |
|
| 112 | - else |
|
| 113 | - $check = in_array($t,$post); |
|
| 114 | - |
|
| 115 | - $res[$k] = "<input type='checkbox' value='$t' name='$name" |
|
| 116 | - . "[]' id='$name$k'" |
|
| 117 | - . ($check ? " checked='checked'" : '') |
|
| 118 | - . "/>\n" |
|
| 119 | - . "<label for='$name$k'>".$t."</label>" |
|
| 120 | - . " (" |
|
| 121 | - . sinon(singulier_ou_pluriel(sql_countsel($t,'','','',$serveur), 'dump:une_donnee', 'dump:nb_donnees'),_T('dump:aucune_donnee')) |
|
| 122 | - . ")"; |
|
| 123 | - } |
|
| 124 | - return $res; |
|
| 105 | + include_spip('inc/filtres'); |
|
| 106 | + $res = array(); |
|
| 107 | + foreach ($tables as $k => $t) { |
|
| 108 | + // par defaut tout est coche sauf les tables dans $exclude |
|
| 109 | + if (is_null($post)) |
|
| 110 | + $check = (in_array($t,$exclude)?false:true); |
|
| 111 | + // mais si on a poste une selection, la reprendre |
|
| 112 | + else |
|
| 113 | + $check = in_array($t,$post); |
|
| 114 | + |
|
| 115 | + $res[$k] = "<input type='checkbox' value='$t' name='$name" |
|
| 116 | + . "[]' id='$name$k'" |
|
| 117 | + . ($check ? " checked='checked'" : '') |
|
| 118 | + . "/>\n" |
|
| 119 | + . "<label for='$name$k'>".$t."</label>" |
|
| 120 | + . " (" |
|
| 121 | + . sinon(singulier_ou_pluriel(sql_countsel($t,'','','',$serveur), 'dump:une_donnee', 'dump:nb_donnees'),_T('dump:aucune_donnee')) |
|
| 122 | + . ")"; |
|
| 123 | + } |
|
| 124 | + return $res; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -133,25 +133,25 @@ discard block |
||
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | 135 | function lister_tables_noexport(){ |
| 136 | - // par defaut tout est exporte sauf les tables ci-dessous |
|
| 137 | - static $EXPORT_tables_noexport = null; |
|
| 138 | - if (!is_null($EXPORT_tables_noexport)) |
|
| 139 | - return $EXPORT_tables_noexport; |
|
| 140 | - |
|
| 141 | - $EXPORT_tables_noexport= array( |
|
| 142 | - 'spip_caches', // plugin invalideur |
|
| 143 | - 'spip_resultats', // resultats de recherche ... c'est un cache ! |
|
| 144 | - 'spip_test', // c'est un test ! |
|
| 145 | - #'spip_referers', |
|
| 146 | - #'spip_referers_articles', |
|
| 147 | - #'spip_visites', |
|
| 148 | - #'spip_visites_articles', |
|
| 149 | - #'spip_versions', |
|
| 150 | - #'spip_versions_fragments' |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - $EXPORT_tables_noexport = pipeline('lister_tables_noexport',$EXPORT_tables_noexport); |
|
| 154 | - return $EXPORT_tables_noexport; |
|
| 136 | + // par defaut tout est exporte sauf les tables ci-dessous |
|
| 137 | + static $EXPORT_tables_noexport = null; |
|
| 138 | + if (!is_null($EXPORT_tables_noexport)) |
|
| 139 | + return $EXPORT_tables_noexport; |
|
| 140 | + |
|
| 141 | + $EXPORT_tables_noexport= array( |
|
| 142 | + 'spip_caches', // plugin invalideur |
|
| 143 | + 'spip_resultats', // resultats de recherche ... c'est un cache ! |
|
| 144 | + 'spip_test', // c'est un test ! |
|
| 145 | + #'spip_referers', |
|
| 146 | + #'spip_referers_articles', |
|
| 147 | + #'spip_visites', |
|
| 148 | + #'spip_visites_articles', |
|
| 149 | + #'spip_versions', |
|
| 150 | + #'spip_versions_fragments' |
|
| 151 | + ); |
|
| 152 | + |
|
| 153 | + $EXPORT_tables_noexport = pipeline('lister_tables_noexport',$EXPORT_tables_noexport); |
|
| 154 | + return $EXPORT_tables_noexport; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -162,23 +162,23 @@ discard block |
||
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | 164 | function lister_tables_noimport(){ |
| 165 | - static $IMPORT_tables_noimport=null; |
|
| 166 | - if (!is_null($IMPORT_tables_noimport)) |
|
| 167 | - return $IMPORT_tables_noimport; |
|
| 168 | - |
|
| 169 | - $IMPORT_tables_noimport = array(); |
|
| 170 | - // par defaut tout est importe sauf les tables ci-dessous |
|
| 171 | - // possibiliter de definir cela tables via la meta |
|
| 172 | - // compatibilite |
|
| 173 | - if (isset($GLOBALS['meta']['IMPORT_tables_noimport'])){ |
|
| 174 | - $IMPORT_tables_noimport = unserialize($GLOBALS['meta']['IMPORT_tables_noimport']); |
|
| 175 | - if (!is_array($IMPORT_tables_noimport)){ |
|
| 176 | - include_spip('inc/meta'); |
|
| 177 | - effacer_meta('IMPORT_tables_noimport'); |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - $IMPORT_tables_noimport = pipeline('lister_tables_noimport',$IMPORT_tables_noimport); |
|
| 181 | - return $IMPORT_tables_noimport; |
|
| 165 | + static $IMPORT_tables_noimport=null; |
|
| 166 | + if (!is_null($IMPORT_tables_noimport)) |
|
| 167 | + return $IMPORT_tables_noimport; |
|
| 168 | + |
|
| 169 | + $IMPORT_tables_noimport = array(); |
|
| 170 | + // par defaut tout est importe sauf les tables ci-dessous |
|
| 171 | + // possibiliter de definir cela tables via la meta |
|
| 172 | + // compatibilite |
|
| 173 | + if (isset($GLOBALS['meta']['IMPORT_tables_noimport'])){ |
|
| 174 | + $IMPORT_tables_noimport = unserialize($GLOBALS['meta']['IMPORT_tables_noimport']); |
|
| 175 | + if (!is_array($IMPORT_tables_noimport)){ |
|
| 176 | + include_spip('inc/meta'); |
|
| 177 | + effacer_meta('IMPORT_tables_noimport'); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + $IMPORT_tables_noimport = pipeline('lister_tables_noimport',$IMPORT_tables_noimport); |
|
| 181 | + return $IMPORT_tables_noimport; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -190,21 +190,21 @@ discard block |
||
| 190 | 190 | * @return array |
| 191 | 191 | */ |
| 192 | 192 | function lister_tables_noerase(){ |
| 193 | - static $IMPORT_tables_noerase=null; |
|
| 194 | - if (!is_null($IMPORT_tables_noerase)) |
|
| 195 | - return $IMPORT_tables_noerase; |
|
| 196 | - |
|
| 197 | - $IMPORT_tables_noerase = array( |
|
| 198 | - 'spip_meta', |
|
| 199 | - // par defaut on ne vide pas les stats, car elles ne figurent pas dans les dump |
|
| 200 | - // et le cas echeant, un bouton dans l'admin permet de les vider a la main... |
|
| 201 | - 'spip_referers', |
|
| 202 | - 'spip_referers_articles', |
|
| 203 | - 'spip_visites', |
|
| 204 | - 'spip_visites_articles' |
|
| 205 | - ); |
|
| 206 | - $IMPORT_tables_noerase = pipeline('lister_tables_noerase',$IMPORT_tables_noerase); |
|
| 207 | - return $IMPORT_tables_noerase; |
|
| 193 | + static $IMPORT_tables_noerase=null; |
|
| 194 | + if (!is_null($IMPORT_tables_noerase)) |
|
| 195 | + return $IMPORT_tables_noerase; |
|
| 196 | + |
|
| 197 | + $IMPORT_tables_noerase = array( |
|
| 198 | + 'spip_meta', |
|
| 199 | + // par defaut on ne vide pas les stats, car elles ne figurent pas dans les dump |
|
| 200 | + // et le cas echeant, un bouton dans l'admin permet de les vider a la main... |
|
| 201 | + 'spip_referers', |
|
| 202 | + 'spip_referers_articles', |
|
| 203 | + 'spip_visites', |
|
| 204 | + 'spip_visites_articles' |
|
| 205 | + ); |
|
| 206 | + $IMPORT_tables_noerase = pipeline('lister_tables_noerase',$IMPORT_tables_noerase); |
|
| 207 | + return $IMPORT_tables_noerase; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | |
@@ -218,70 +218,70 @@ discard block |
||
| 218 | 218 | * @return array |
| 219 | 219 | */ |
| 220 | 220 | function base_liste_table_for_dump($exclude_tables = array()){ |
| 221 | - $tables_for_dump = array(); |
|
| 222 | - $tables_pointees = array(); |
|
| 223 | - $tables = array(); |
|
| 224 | - $tables_principales = $GLOBALS['tables_principales']; |
|
| 225 | - $tables_auxiliaires = $GLOBALS['tables_auxiliaires']; |
|
| 226 | - $tables_jointures = $GLOBALS['tables_jointures']; |
|
| 227 | - |
|
| 228 | - if (include_spip('base/objets') |
|
| 229 | - AND function_exists('lister_tables_objets_sql')){ |
|
| 230 | - $tables = lister_tables_objets_sql(); |
|
| 231 | - foreach($tables as $t=>$infos){ |
|
| 232 | - if ($infos['principale'] AND !isset($tables_principales[$t])) |
|
| 233 | - $tables_principales[$t] = true; |
|
| 234 | - if (!$infos['principale'] AND !isset($tables_auxiliaires[$t])) |
|
| 235 | - $tables_auxiliaires[$t] = true; |
|
| 236 | - if (count($infos['tables_jointures'])) |
|
| 237 | - $tables_jointures[$t] = array_merge(isset($tables_jointures[$t])?$tables_jointures[$t]:array(),$infos['tables_jointures']); |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // on construit un index des tables de liens |
|
| 242 | - // pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees |
|
| 243 | - $tables_for_link = array(); |
|
| 244 | - foreach($tables_jointures as $table => $liste_relations) |
|
| 245 | - if (is_array($liste_relations)) |
|
| 246 | - { |
|
| 247 | - $nom = $table; |
|
| 248 | - if (!isset($tables_auxiliaires[$nom])&&!isset($tables_principales[$nom])) |
|
| 249 | - $nom = "spip_$table"; |
|
| 250 | - if (isset($tables_auxiliaires[$nom])||isset($tables_principales[$nom])){ |
|
| 251 | - foreach($liste_relations as $link_table){ |
|
| 252 | - if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/){ |
|
| 253 | - $tables_for_link[$link_table][] = $nom; |
|
| 254 | - } |
|
| 255 | - else if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/){ |
|
| 256 | - $tables_for_link["spip_$link_table"][] = $nom; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - $liste_tables = array_merge(array_keys($tables_principales),array_keys($tables_auxiliaires),array_keys($tables)); |
|
| 263 | - foreach($liste_tables as $table){ |
|
| 264 | - // $name = preg_replace("{^spip_}","",$table); |
|
| 265 | - if ( !isset($tables_pointees[$table]) |
|
| 266 | - && !in_array($table,$exclude_tables) |
|
| 267 | - && !isset($tables_for_link[$table])){ |
|
| 268 | - $tables_for_dump[] = $table; |
|
| 269 | - $tables_pointees[$table] = 1; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - foreach ($tables_for_link as $link_table =>$liste){ |
|
| 273 | - $connecte = true; |
|
| 274 | - foreach($liste as $connect_table) |
|
| 275 | - if (!in_array($connect_table,$tables_for_dump)) |
|
| 276 | - $connecte = false; |
|
| 277 | - if ($connecte) |
|
| 278 | - # on ajoute les liaisons en premier |
|
| 279 | - # si une restauration est interrompue, |
|
| 280 | - # cela se verra mieux si il manque des objets |
|
| 281 | - # que des liens |
|
| 282 | - array_unshift($tables_for_dump,$link_table); |
|
| 283 | - } |
|
| 284 | - return array($tables_for_dump, $tables_for_link); |
|
| 221 | + $tables_for_dump = array(); |
|
| 222 | + $tables_pointees = array(); |
|
| 223 | + $tables = array(); |
|
| 224 | + $tables_principales = $GLOBALS['tables_principales']; |
|
| 225 | + $tables_auxiliaires = $GLOBALS['tables_auxiliaires']; |
|
| 226 | + $tables_jointures = $GLOBALS['tables_jointures']; |
|
| 227 | + |
|
| 228 | + if (include_spip('base/objets') |
|
| 229 | + AND function_exists('lister_tables_objets_sql')){ |
|
| 230 | + $tables = lister_tables_objets_sql(); |
|
| 231 | + foreach($tables as $t=>$infos){ |
|
| 232 | + if ($infos['principale'] AND !isset($tables_principales[$t])) |
|
| 233 | + $tables_principales[$t] = true; |
|
| 234 | + if (!$infos['principale'] AND !isset($tables_auxiliaires[$t])) |
|
| 235 | + $tables_auxiliaires[$t] = true; |
|
| 236 | + if (count($infos['tables_jointures'])) |
|
| 237 | + $tables_jointures[$t] = array_merge(isset($tables_jointures[$t])?$tables_jointures[$t]:array(),$infos['tables_jointures']); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + // on construit un index des tables de liens |
|
| 242 | + // pour les ajouter SI les deux tables qu'ils connectent sont sauvegardees |
|
| 243 | + $tables_for_link = array(); |
|
| 244 | + foreach($tables_jointures as $table => $liste_relations) |
|
| 245 | + if (is_array($liste_relations)) |
|
| 246 | + { |
|
| 247 | + $nom = $table; |
|
| 248 | + if (!isset($tables_auxiliaires[$nom])&&!isset($tables_principales[$nom])) |
|
| 249 | + $nom = "spip_$table"; |
|
| 250 | + if (isset($tables_auxiliaires[$nom])||isset($tables_principales[$nom])){ |
|
| 251 | + foreach($liste_relations as $link_table){ |
|
| 252 | + if (isset($tables_auxiliaires[$link_table])/*||isset($tables_principales[$link_table])*/){ |
|
| 253 | + $tables_for_link[$link_table][] = $nom; |
|
| 254 | + } |
|
| 255 | + else if (isset($tables_auxiliaires["spip_$link_table"])/*||isset($tables_principales["spip_$link_table"])*/){ |
|
| 256 | + $tables_for_link["spip_$link_table"][] = $nom; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + $liste_tables = array_merge(array_keys($tables_principales),array_keys($tables_auxiliaires),array_keys($tables)); |
|
| 263 | + foreach($liste_tables as $table){ |
|
| 264 | + // $name = preg_replace("{^spip_}","",$table); |
|
| 265 | + if ( !isset($tables_pointees[$table]) |
|
| 266 | + && !in_array($table,$exclude_tables) |
|
| 267 | + && !isset($tables_for_link[$table])){ |
|
| 268 | + $tables_for_dump[] = $table; |
|
| 269 | + $tables_pointees[$table] = 1; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + foreach ($tables_for_link as $link_table =>$liste){ |
|
| 273 | + $connecte = true; |
|
| 274 | + foreach($liste as $connect_table) |
|
| 275 | + if (!in_array($connect_table,$tables_for_dump)) |
|
| 276 | + $connecte = false; |
|
| 277 | + if ($connecte) |
|
| 278 | + # on ajoute les liaisons en premier |
|
| 279 | + # si une restauration est interrompue, |
|
| 280 | + # cela se verra mieux si il manque des objets |
|
| 281 | + # que des liens |
|
| 282 | + array_unshift($tables_for_dump,$link_table); |
|
| 283 | + } |
|
| 284 | + return array($tables_for_dump, $tables_for_link); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -296,33 +296,33 @@ discard block |
||
| 296 | 296 | * @param string $serveur |
| 297 | 297 | */ |
| 298 | 298 | function base_vider_tables_destination_copie($tables, $exclure_tables = array(), $serveur=''){ |
| 299 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 300 | - |
|
| 301 | - spip_log('Vider '.count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),'base.'._LOG_INFO_IMPORTANTE); |
|
| 302 | - foreach($tables as $table){ |
|
| 303 | - if (!in_array($table,$exclure_tables)){ |
|
| 304 | - // sur le serveur principal, il ne faut pas supprimer l'auteur loge ! |
|
| 305 | - if (($table!='spip_auteurs') OR $serveur!=''){ |
|
| 306 | - // regarder si il y a au moins un champ impt='non' |
|
| 307 | - $desc = $trouver_table($table,$serveur); |
|
| 308 | - if (isset($desc['field']['impt'])){ |
|
| 309 | - sql_delete($table, "impt='oui'", $serveur); |
|
| 310 | - } |
|
| 311 | - else{ |
|
| 312 | - sql_delete($table, "", $serveur); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - // sur le serveur principal, il ne faut pas supprimer l'auteur loge ! |
|
| 319 | - // Bidouille pour garder l'acces admin actuel pendant toute la restauration |
|
| 320 | - if ($serveur=='' |
|
| 321 | - AND in_array('spip_auteurs',$tables) |
|
| 322 | - AND !in_array('spip_auteurs',$exclure_tables)) { |
|
| 323 | - base_conserver_copieur(true, $serveur); |
|
| 324 | - sql_delete("spip_auteurs", "id_auteur>0",$serveur); |
|
| 325 | - } |
|
| 299 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 300 | + |
|
| 301 | + spip_log('Vider '.count($tables) . " tables sur serveur '$serveur' : " . join(', ', $tables),'base.'._LOG_INFO_IMPORTANTE); |
|
| 302 | + foreach($tables as $table){ |
|
| 303 | + if (!in_array($table,$exclure_tables)){ |
|
| 304 | + // sur le serveur principal, il ne faut pas supprimer l'auteur loge ! |
|
| 305 | + if (($table!='spip_auteurs') OR $serveur!=''){ |
|
| 306 | + // regarder si il y a au moins un champ impt='non' |
|
| 307 | + $desc = $trouver_table($table,$serveur); |
|
| 308 | + if (isset($desc['field']['impt'])){ |
|
| 309 | + sql_delete($table, "impt='oui'", $serveur); |
|
| 310 | + } |
|
| 311 | + else{ |
|
| 312 | + sql_delete($table, "", $serveur); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + // sur le serveur principal, il ne faut pas supprimer l'auteur loge ! |
|
| 319 | + // Bidouille pour garder l'acces admin actuel pendant toute la restauration |
|
| 320 | + if ($serveur=='' |
|
| 321 | + AND in_array('spip_auteurs',$tables) |
|
| 322 | + AND !in_array('spip_auteurs',$exclure_tables)) { |
|
| 323 | + base_conserver_copieur(true, $serveur); |
|
| 324 | + sql_delete("spip_auteurs", "id_auteur>0",$serveur); |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | 334 | function base_conserver_copieur($move = true,$serveur=''){ |
| 335 | - // s'asurer qu'on a pas deja fait la manip ! |
|
| 336 | - if ($GLOBALS['visiteur_session']['id_auteur']>0 AND sql_countsel("spip_auteurs", "id_auteur>0")) { |
|
| 337 | - spip_log('Conserver copieur '.$GLOBALS['visiteur_statut']['id_auteur'] . " dans id_auteur=".$GLOBALS['visiteur_statut']['id_auteur']." pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 338 | - sql_delete("spip_auteurs", "id_auteur<0",$serveur); |
|
| 339 | - if ($move){ |
|
| 340 | - sql_updateq('spip_auteurs', array('id_auteur'=>-$GLOBALS['visiteur_session']['id_auteur']), "id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']),array(),$serveur); |
|
| 341 | - } |
|
| 342 | - else { |
|
| 343 | - $row = sql_fetsel('*','spip_auteurs','id_auteur='.$GLOBALS['visiteur_session']['id_auteur'],'','','','',$serveur); |
|
| 344 | - $row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur']; |
|
| 345 | - sql_insertq('spip_auteurs',$row,array(),$serveur); |
|
| 346 | - } |
|
| 347 | - } |
|
| 335 | + // s'asurer qu'on a pas deja fait la manip ! |
|
| 336 | + if ($GLOBALS['visiteur_session']['id_auteur']>0 AND sql_countsel("spip_auteurs", "id_auteur>0")) { |
|
| 337 | + spip_log('Conserver copieur '.$GLOBALS['visiteur_statut']['id_auteur'] . " dans id_auteur=".$GLOBALS['visiteur_statut']['id_auteur']." pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 338 | + sql_delete("spip_auteurs", "id_auteur<0",$serveur); |
|
| 339 | + if ($move){ |
|
| 340 | + sql_updateq('spip_auteurs', array('id_auteur'=>-$GLOBALS['visiteur_session']['id_auteur']), "id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']),array(),$serveur); |
|
| 341 | + } |
|
| 342 | + else { |
|
| 343 | + $row = sql_fetsel('*','spip_auteurs','id_auteur='.$GLOBALS['visiteur_session']['id_auteur'],'','','','',$serveur); |
|
| 344 | + $row['id_auteur'] = -$GLOBALS['visiteur_session']['id_auteur']; |
|
| 345 | + sql_insertq('spip_auteurs',$row,array(),$serveur); |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -360,19 +360,19 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function base_detruire_copieur_si_besoin($serveur='') |
| 362 | 362 | { |
| 363 | - // rien a faire si ce n'est pas le serveur principal ! |
|
| 364 | - if ($serveur=='') { |
|
| 365 | - if (sql_countsel("spip_auteurs", "id_auteur>0")) { |
|
| 366 | - spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 367 | - sql_delete("spip_auteurs", "id_auteur<0", $serveur); |
|
| 368 | - } |
|
| 369 | - else { |
|
| 370 | - spip_log( "Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 371 | - sql_update('spip_auteurs', array('id_auteur'=>'-id_auteur'), "id_auteur<0"); |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - else |
|
| 375 | - spip_log("Pas de destruction copieur sur serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 363 | + // rien a faire si ce n'est pas le serveur principal ! |
|
| 364 | + if ($serveur=='') { |
|
| 365 | + if (sql_countsel("spip_auteurs", "id_auteur>0")) { |
|
| 366 | + spip_log("Detruire copieur id_auteur<0 pour le serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 367 | + sql_delete("spip_auteurs", "id_auteur<0", $serveur); |
|
| 368 | + } |
|
| 369 | + else { |
|
| 370 | + spip_log( "Restaurer copieur id_auteur<0 pour le serveur '$serveur' (aucun autre auteur en base)",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 371 | + sql_update('spip_auteurs', array('id_auteur'=>'-id_auteur'), "id_auteur<0"); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + else |
|
| 375 | + spip_log("Pas de destruction copieur sur serveur '$serveur'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
@@ -387,41 +387,41 @@ discard block |
||
| 387 | 387 | * @return array |
| 388 | 388 | */ |
| 389 | 389 | function base_preparer_table_dest($table, $desc, $serveur_dest, $init=false) { |
| 390 | - $upgrade = false; |
|
| 391 | - // si la table existe et qu'on est a l'init, la dropper |
|
| 392 | - if ($desc_dest=sql_showtable($table,true,$serveur_dest) AND $init) { |
|
| 393 | - if ($serveur_dest=='' AND in_array($table,array('spip_meta','spip_auteurs'))) { |
|
| 394 | - // ne pas dropper auteurs et meta sur le serveur principal |
|
| 395 | - // faire un simple upgrade a la place |
|
| 396 | - // pour ajouter les champs manquants |
|
| 397 | - $upgrade = true; |
|
| 398 | - // coherence avec le drop sur les autres tables |
|
| 399 | - base_vider_tables_destination_copie(array($table),array(),$serveur_dest); |
|
| 400 | - if ($table=='spip_meta'){ |
|
| 401 | - // virer les version base qui vont venir avec l'import |
|
| 402 | - sql_delete($table, "nom like '%_base_version'",$serveur_dest); |
|
| 403 | - // hum casse la base si pas version_installee a l'import ... |
|
| 404 | - sql_delete($table, "nom='version_installee'",$serveur_dest); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - else { |
|
| 408 | - sql_drop_table($table, '', $serveur_dest); |
|
| 409 | - spip_log( "drop table '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 410 | - } |
|
| 411 | - $desc_dest = false; |
|
| 412 | - } |
|
| 413 | - // si la table n'existe pas dans la destination, la creer a l'identique ! |
|
| 414 | - if (!$desc_dest) { |
|
| 415 | - spip_log( "creation '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 416 | - include_spip('base/create'); |
|
| 417 | - creer_ou_upgrader_table($table, $desc, 'auto', $upgrade,$serveur_dest); |
|
| 418 | - $desc_dest = sql_showtable($table,true,$serveur_dest); |
|
| 419 | - } |
|
| 420 | - if (!$desc_dest){ |
|
| 421 | - spip_log( "Erreur creation '$table' sur serveur '$serveur_dest'".var_export($desc,1),'dump.'._LOG_ERREUR); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - return $desc_dest; |
|
| 390 | + $upgrade = false; |
|
| 391 | + // si la table existe et qu'on est a l'init, la dropper |
|
| 392 | + if ($desc_dest=sql_showtable($table,true,$serveur_dest) AND $init) { |
|
| 393 | + if ($serveur_dest=='' AND in_array($table,array('spip_meta','spip_auteurs'))) { |
|
| 394 | + // ne pas dropper auteurs et meta sur le serveur principal |
|
| 395 | + // faire un simple upgrade a la place |
|
| 396 | + // pour ajouter les champs manquants |
|
| 397 | + $upgrade = true; |
|
| 398 | + // coherence avec le drop sur les autres tables |
|
| 399 | + base_vider_tables_destination_copie(array($table),array(),$serveur_dest); |
|
| 400 | + if ($table=='spip_meta'){ |
|
| 401 | + // virer les version base qui vont venir avec l'import |
|
| 402 | + sql_delete($table, "nom like '%_base_version'",$serveur_dest); |
|
| 403 | + // hum casse la base si pas version_installee a l'import ... |
|
| 404 | + sql_delete($table, "nom='version_installee'",$serveur_dest); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + else { |
|
| 408 | + sql_drop_table($table, '', $serveur_dest); |
|
| 409 | + spip_log( "drop table '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 410 | + } |
|
| 411 | + $desc_dest = false; |
|
| 412 | + } |
|
| 413 | + // si la table n'existe pas dans la destination, la creer a l'identique ! |
|
| 414 | + if (!$desc_dest) { |
|
| 415 | + spip_log( "creation '$table' sur serveur '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 416 | + include_spip('base/create'); |
|
| 417 | + creer_ou_upgrader_table($table, $desc, 'auto', $upgrade,$serveur_dest); |
|
| 418 | + $desc_dest = sql_showtable($table,true,$serveur_dest); |
|
| 419 | + } |
|
| 420 | + if (!$desc_dest){ |
|
| 421 | + spip_log( "Erreur creation '$table' sur serveur '$serveur_dest'".var_export($desc,1),'dump.'._LOG_ERREUR); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + return $desc_dest; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
@@ -467,165 +467,165 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | function base_copier_tables($status_file, $tables, $serveur_source, $serveur_dest, $options=array()){ |
| 469 | 469 | |
| 470 | - $callback_progression = isset($options['callback_progression'])?$options['callback_progression']:''; |
|
| 471 | - $max_time = isset($options['max_time'])?$options['max_time']:0; |
|
| 472 | - $drop_source = isset($options['drop_source'])?$options['drop_source']:false; |
|
| 473 | - $no_erase_dest = isset($options['no_erase_dest'])?$options['no_erase_dest']:array(); |
|
| 474 | - $where = isset($options['where'])?$options['where']:array(); |
|
| 475 | - $fonction_base_inserer = isset($options['fonction_base_inserer'])?$options['fonction_base_inserer']:'inserer_copie'; |
|
| 476 | - $desc_tables_dest = isset($options['desc_tables_dest'])?$options['desc_tables_dest']:array(); |
|
| 477 | - $racine_fonctions = (isset($options['racine_fonctions_dest'])?$options['racine_fonctions_dest']:'base'); |
|
| 478 | - $data_pool = (isset($options['data_pool'])?$options['data_pool']:50*1024); |
|
| 479 | - |
|
| 480 | - spip_log( "Copier ".count($tables)." tables de '$serveur_source' vers '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 481 | - |
|
| 482 | - if (!$inserer_copie = charger_fonction($fonction_base_inserer,$racine_fonctions, true)) { |
|
| 483 | - spip_log( "Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 484 | - return true; // echec mais on a fini, donc true |
|
| 485 | - } |
|
| 486 | - if (!$preparer_table_dest = charger_fonction('preparer_table_dest',$racine_fonctions, true)) { |
|
| 487 | - spip_log( "Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 488 | - return true; // echec mais on a fini, donc true |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - if (!lire_fichier($status_file, $status) |
|
| 492 | - OR !$status = unserialize($status)) |
|
| 493 | - $status = array(); |
|
| 494 | - $status['etape'] = 'basecopie'; |
|
| 495 | - |
|
| 496 | - // puis relister les tables a importer |
|
| 497 | - // et les vider si besoin, au moment du premier passage ici |
|
| 498 | - $initialisation_copie = (!isset($status["dump_status_copie"])) ? 0 : $status["dump_status_copie"]; |
|
| 499 | - |
|
| 500 | - // si init pas encore faite, vider les tables du serveur destination |
|
| 501 | - if (!$initialisation_copie) { |
|
| 502 | - if (!$vider_tables_destination_copie = charger_fonction('vider_tables_destination_copie',$racine_fonctions, true)) { |
|
| 503 | - spip_log( "Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 504 | - return true; // echec mais on a fini, donc true |
|
| 505 | - } |
|
| 506 | - $vider_tables_destination_copie($tables, $no_erase_dest, $serveur_dest); |
|
| 507 | - $status["dump_status_copie"]='ok'; |
|
| 508 | - ecrire_fichier($status_file,serialize($status)); |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - // les tables auteurs et meta doivent etre copiees en dernier ! |
|
| 512 | - if (in_array('spip_auteurs',$tables)){ |
|
| 513 | - $tables = array_diff($tables,array('spip_auteurs')); |
|
| 514 | - $tables[] = 'spip_auteurs'; |
|
| 515 | - } |
|
| 516 | - if (in_array('spip_meta',$tables)){ |
|
| 517 | - $tables = array_diff($tables,array('spip_meta')); |
|
| 518 | - $tables[] = 'spip_meta'; |
|
| 519 | - } |
|
| 520 | - spip_log( "Tables a copier :".implode(", ",$tables),'dump.'._LOG_INFO); |
|
| 521 | - |
|
| 522 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 523 | - |
|
| 524 | - foreach ($tables as $table){ |
|
| 525 | - // si table commence par spip_ c'est une table SPIP, renommer le prefixe si besoin |
|
| 526 | - // sinon chercher la vraie table |
|
| 527 | - $desc_source = false; |
|
| 528 | - if (strncmp($table,"spip_",5)==0){ |
|
| 529 | - $desc_source = $trouver_table(preg_replace(",^spip_,","",$table), $serveur_source, true); |
|
| 530 | - } |
|
| 531 | - if (!$desc_source OR !isset($desc_source['exist']) OR !$desc_source['exist']) |
|
| 532 | - $desc_source = $trouver_table($table, $serveur_source, false); |
|
| 533 | - |
|
| 534 | - // verifier que la table est presente dans la base source |
|
| 535 | - if ($desc_source){ |
|
| 536 | - // $status['tables_copiees'][$table] contient l'avancement |
|
| 537 | - // de la copie pour la $table : 0 a N et -N quand elle est finie (-1 si vide et finie...) |
|
| 538 | - if (!isset($status['tables_copiees'][$table])) |
|
| 539 | - $status['tables_copiees'][$table] = 0; |
|
| 540 | - |
|
| 541 | - if (is_numeric($status['tables_copiees'][$table]) |
|
| 542 | - AND $status['tables_copiees'][$table]>=0 |
|
| 543 | - AND $desc_dest = $preparer_table_dest( |
|
| 544 | - $table, |
|
| 545 | - isset($desc_tables_dest[$table])?$desc_tables_dest[$table]:$desc_source, |
|
| 546 | - $serveur_dest, |
|
| 547 | - $status['tables_copiees'][$table] == 0)){ |
|
| 548 | - if ($callback_progression) |
|
| 549 | - $callback_progression($status['tables_copiees'][$table],0,$table); |
|
| 550 | - while (true) { |
|
| 551 | - $n = intval($status['tables_copiees'][$table]); |
|
| 552 | - // on copie par lot de 400 |
|
| 553 | - $res = sql_select('*',$table,isset($where[$table])?$where[$table]:'','','',"$n,400",'',$serveur_source); |
|
| 554 | - while ($row = sql_fetch($res,$serveur_source)){ |
|
| 555 | - $rows = array($row); |
|
| 556 | - // lire un groupe de donnees si demande en option |
|
| 557 | - // (permet un envoi par lot vers la destination) |
|
| 558 | - if ($data_pool>0){ |
|
| 559 | - $s = strlen(serialize($row)); |
|
| 560 | - while ($s<$data_pool AND $row = sql_fetch($res,$serveur_source)){ |
|
| 561 | - $s += strlen(serialize($row)); |
|
| 562 | - $rows[]= $row; |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 566 | - // mais si ca renvoie false c'est une erreur fatale => abandon |
|
| 567 | - if ($inserer_copie($table,$rows,$desc_dest,$serveur_dest)===false) { |
|
| 568 | - // forcer la sortie, charge a l'appelant de gerer l'echec |
|
| 569 | - spip_log("Erreur fatale dans $inserer_copie table $table","dump"._LOG_ERREUR); |
|
| 570 | - $status['errors'][] = "Erreur fatale lors de la copie de la table $table"; |
|
| 571 | - ecrire_fichier($status_file,serialize($status)); |
|
| 572 | - // copie finie |
|
| 573 | - return true; |
|
| 574 | - } |
|
| 575 | - $status['tables_copiees'][$table]+=count($rows); |
|
| 576 | - if ($max_time AND time()>$max_time) |
|
| 577 | - break; |
|
| 578 | - } |
|
| 579 | - if ($n == $status['tables_copiees'][$table]) |
|
| 580 | - break; |
|
| 581 | - spip_log( "recopie $table ".$status['tables_copiees'][$table],'dump.'._LOG_INFO_IMPORTANTE); |
|
| 582 | - if ($callback_progression) |
|
| 583 | - $callback_progression($status['tables_copiees'][$table],0,$table); |
|
| 584 | - ecrire_fichier($status_file,serialize($status)); |
|
| 585 | - if ($max_time AND time()>$max_time) |
|
| 586 | - return false; // on a pas fini, mais le temps imparti est ecoule |
|
| 587 | - } |
|
| 588 | - if ($drop_source) { |
|
| 589 | - sql_drop_table($table,'',$serveur_source); |
|
| 590 | - spip_log( "drop $table sur serveur source '$serveur_source'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 591 | - } |
|
| 592 | - $status['tables_copiees'][$table]=($status['tables_copiees'][$table]?-$status['tables_copiees'][$table]:"zero"); |
|
| 593 | - ecrire_fichier($status_file,serialize($status)); |
|
| 594 | - spip_log( "tables_recopiees ".implode(',',$status['tables_copiees']),'dump.'._LOG_INFO); |
|
| 595 | - if ($callback_progression) |
|
| 596 | - $callback_progression($status['tables_copiees'][$table],$status['tables_copiees'][$table],$table); |
|
| 597 | - } |
|
| 598 | - else { |
|
| 599 | - if ($status['tables_copiees'][$table]<0) |
|
| 600 | - spip_log("Table $table deja copiee : ".$status['tables_copiees'][$table],"dump."._LOG_INFO); |
|
| 601 | - if ($callback_progression) |
|
| 602 | - $callback_progression(0,$status['tables_copiees'][$table],"$table".((is_numeric($status['tables_copiees'][$table]) AND $status['tables_copiees'][$table]>=0)?"[Echec]":"")); |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - else { |
|
| 606 | - $status['errors'][] = "Impossible de lire la description de la table $table"; |
|
| 607 | - ecrire_fichier($status_file,serialize($status)); |
|
| 608 | - spip_log("Impossible de lire la description de la table $table","dump."._LOG_ERREUR); |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - // si le nombre de tables envoyees n'est pas egal au nombre de tables demandees |
|
| 613 | - // abandonner |
|
| 614 | - if (count($status['tables_copiees'])<count($tables)){ |
|
| 615 | - spip_log("Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables),"dump."._LOG_ERREUR); |
|
| 616 | - $status['errors'][] = "Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables); |
|
| 617 | - ecrire_fichier($status_file,serialize($status)); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin',$racine_fonctions, true)) { |
|
| 621 | - $detruire_copieur_si_besoin($serveur_dest); |
|
| 622 | - } |
|
| 623 | - else { |
|
| 624 | - spip_log( "Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - // OK, copie complete |
|
| 628 | - return true; |
|
| 470 | + $callback_progression = isset($options['callback_progression'])?$options['callback_progression']:''; |
|
| 471 | + $max_time = isset($options['max_time'])?$options['max_time']:0; |
|
| 472 | + $drop_source = isset($options['drop_source'])?$options['drop_source']:false; |
|
| 473 | + $no_erase_dest = isset($options['no_erase_dest'])?$options['no_erase_dest']:array(); |
|
| 474 | + $where = isset($options['where'])?$options['where']:array(); |
|
| 475 | + $fonction_base_inserer = isset($options['fonction_base_inserer'])?$options['fonction_base_inserer']:'inserer_copie'; |
|
| 476 | + $desc_tables_dest = isset($options['desc_tables_dest'])?$options['desc_tables_dest']:array(); |
|
| 477 | + $racine_fonctions = (isset($options['racine_fonctions_dest'])?$options['racine_fonctions_dest']:'base'); |
|
| 478 | + $data_pool = (isset($options['data_pool'])?$options['data_pool']:50*1024); |
|
| 479 | + |
|
| 480 | + spip_log( "Copier ".count($tables)." tables de '$serveur_source' vers '$serveur_dest'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 481 | + |
|
| 482 | + if (!$inserer_copie = charger_fonction($fonction_base_inserer,$racine_fonctions, true)) { |
|
| 483 | + spip_log( "Fonction '{$racine_fonctions}_$fonction_base_inserer' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 484 | + return true; // echec mais on a fini, donc true |
|
| 485 | + } |
|
| 486 | + if (!$preparer_table_dest = charger_fonction('preparer_table_dest',$racine_fonctions, true)) { |
|
| 487 | + spip_log( "Fonction '{$racine_fonctions}_$preparer_table_dest' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 488 | + return true; // echec mais on a fini, donc true |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + if (!lire_fichier($status_file, $status) |
|
| 492 | + OR !$status = unserialize($status)) |
|
| 493 | + $status = array(); |
|
| 494 | + $status['etape'] = 'basecopie'; |
|
| 495 | + |
|
| 496 | + // puis relister les tables a importer |
|
| 497 | + // et les vider si besoin, au moment du premier passage ici |
|
| 498 | + $initialisation_copie = (!isset($status["dump_status_copie"])) ? 0 : $status["dump_status_copie"]; |
|
| 499 | + |
|
| 500 | + // si init pas encore faite, vider les tables du serveur destination |
|
| 501 | + if (!$initialisation_copie) { |
|
| 502 | + if (!$vider_tables_destination_copie = charger_fonction('vider_tables_destination_copie',$racine_fonctions, true)) { |
|
| 503 | + spip_log( "Fonction '{$racine_fonctions}_vider_tables_destination_copie' inconnue. Abandon",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 504 | + return true; // echec mais on a fini, donc true |
|
| 505 | + } |
|
| 506 | + $vider_tables_destination_copie($tables, $no_erase_dest, $serveur_dest); |
|
| 507 | + $status["dump_status_copie"]='ok'; |
|
| 508 | + ecrire_fichier($status_file,serialize($status)); |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + // les tables auteurs et meta doivent etre copiees en dernier ! |
|
| 512 | + if (in_array('spip_auteurs',$tables)){ |
|
| 513 | + $tables = array_diff($tables,array('spip_auteurs')); |
|
| 514 | + $tables[] = 'spip_auteurs'; |
|
| 515 | + } |
|
| 516 | + if (in_array('spip_meta',$tables)){ |
|
| 517 | + $tables = array_diff($tables,array('spip_meta')); |
|
| 518 | + $tables[] = 'spip_meta'; |
|
| 519 | + } |
|
| 520 | + spip_log( "Tables a copier :".implode(", ",$tables),'dump.'._LOG_INFO); |
|
| 521 | + |
|
| 522 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 523 | + |
|
| 524 | + foreach ($tables as $table){ |
|
| 525 | + // si table commence par spip_ c'est une table SPIP, renommer le prefixe si besoin |
|
| 526 | + // sinon chercher la vraie table |
|
| 527 | + $desc_source = false; |
|
| 528 | + if (strncmp($table,"spip_",5)==0){ |
|
| 529 | + $desc_source = $trouver_table(preg_replace(",^spip_,","",$table), $serveur_source, true); |
|
| 530 | + } |
|
| 531 | + if (!$desc_source OR !isset($desc_source['exist']) OR !$desc_source['exist']) |
|
| 532 | + $desc_source = $trouver_table($table, $serveur_source, false); |
|
| 533 | + |
|
| 534 | + // verifier que la table est presente dans la base source |
|
| 535 | + if ($desc_source){ |
|
| 536 | + // $status['tables_copiees'][$table] contient l'avancement |
|
| 537 | + // de la copie pour la $table : 0 a N et -N quand elle est finie (-1 si vide et finie...) |
|
| 538 | + if (!isset($status['tables_copiees'][$table])) |
|
| 539 | + $status['tables_copiees'][$table] = 0; |
|
| 540 | + |
|
| 541 | + if (is_numeric($status['tables_copiees'][$table]) |
|
| 542 | + AND $status['tables_copiees'][$table]>=0 |
|
| 543 | + AND $desc_dest = $preparer_table_dest( |
|
| 544 | + $table, |
|
| 545 | + isset($desc_tables_dest[$table])?$desc_tables_dest[$table]:$desc_source, |
|
| 546 | + $serveur_dest, |
|
| 547 | + $status['tables_copiees'][$table] == 0)){ |
|
| 548 | + if ($callback_progression) |
|
| 549 | + $callback_progression($status['tables_copiees'][$table],0,$table); |
|
| 550 | + while (true) { |
|
| 551 | + $n = intval($status['tables_copiees'][$table]); |
|
| 552 | + // on copie par lot de 400 |
|
| 553 | + $res = sql_select('*',$table,isset($where[$table])?$where[$table]:'','','',"$n,400",'',$serveur_source); |
|
| 554 | + while ($row = sql_fetch($res,$serveur_source)){ |
|
| 555 | + $rows = array($row); |
|
| 556 | + // lire un groupe de donnees si demande en option |
|
| 557 | + // (permet un envoi par lot vers la destination) |
|
| 558 | + if ($data_pool>0){ |
|
| 559 | + $s = strlen(serialize($row)); |
|
| 560 | + while ($s<$data_pool AND $row = sql_fetch($res,$serveur_source)){ |
|
| 561 | + $s += strlen(serialize($row)); |
|
| 562 | + $rows[]= $row; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 566 | + // mais si ca renvoie false c'est une erreur fatale => abandon |
|
| 567 | + if ($inserer_copie($table,$rows,$desc_dest,$serveur_dest)===false) { |
|
| 568 | + // forcer la sortie, charge a l'appelant de gerer l'echec |
|
| 569 | + spip_log("Erreur fatale dans $inserer_copie table $table","dump"._LOG_ERREUR); |
|
| 570 | + $status['errors'][] = "Erreur fatale lors de la copie de la table $table"; |
|
| 571 | + ecrire_fichier($status_file,serialize($status)); |
|
| 572 | + // copie finie |
|
| 573 | + return true; |
|
| 574 | + } |
|
| 575 | + $status['tables_copiees'][$table]+=count($rows); |
|
| 576 | + if ($max_time AND time()>$max_time) |
|
| 577 | + break; |
|
| 578 | + } |
|
| 579 | + if ($n == $status['tables_copiees'][$table]) |
|
| 580 | + break; |
|
| 581 | + spip_log( "recopie $table ".$status['tables_copiees'][$table],'dump.'._LOG_INFO_IMPORTANTE); |
|
| 582 | + if ($callback_progression) |
|
| 583 | + $callback_progression($status['tables_copiees'][$table],0,$table); |
|
| 584 | + ecrire_fichier($status_file,serialize($status)); |
|
| 585 | + if ($max_time AND time()>$max_time) |
|
| 586 | + return false; // on a pas fini, mais le temps imparti est ecoule |
|
| 587 | + } |
|
| 588 | + if ($drop_source) { |
|
| 589 | + sql_drop_table($table,'',$serveur_source); |
|
| 590 | + spip_log( "drop $table sur serveur source '$serveur_source'",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 591 | + } |
|
| 592 | + $status['tables_copiees'][$table]=($status['tables_copiees'][$table]?-$status['tables_copiees'][$table]:"zero"); |
|
| 593 | + ecrire_fichier($status_file,serialize($status)); |
|
| 594 | + spip_log( "tables_recopiees ".implode(',',$status['tables_copiees']),'dump.'._LOG_INFO); |
|
| 595 | + if ($callback_progression) |
|
| 596 | + $callback_progression($status['tables_copiees'][$table],$status['tables_copiees'][$table],$table); |
|
| 597 | + } |
|
| 598 | + else { |
|
| 599 | + if ($status['tables_copiees'][$table]<0) |
|
| 600 | + spip_log("Table $table deja copiee : ".$status['tables_copiees'][$table],"dump."._LOG_INFO); |
|
| 601 | + if ($callback_progression) |
|
| 602 | + $callback_progression(0,$status['tables_copiees'][$table],"$table".((is_numeric($status['tables_copiees'][$table]) AND $status['tables_copiees'][$table]>=0)?"[Echec]":"")); |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + else { |
|
| 606 | + $status['errors'][] = "Impossible de lire la description de la table $table"; |
|
| 607 | + ecrire_fichier($status_file,serialize($status)); |
|
| 608 | + spip_log("Impossible de lire la description de la table $table","dump."._LOG_ERREUR); |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + // si le nombre de tables envoyees n'est pas egal au nombre de tables demandees |
|
| 613 | + // abandonner |
|
| 614 | + if (count($status['tables_copiees'])<count($tables)){ |
|
| 615 | + spip_log("Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables),"dump."._LOG_ERREUR); |
|
| 616 | + $status['errors'][] = "Nombre de tables copiees incorrect : ".count($status['tables_copiees'])."/".count($tables); |
|
| 617 | + ecrire_fichier($status_file,serialize($status)); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + if ($detruire_copieur_si_besoin = charger_fonction('detruire_copieur_si_besoin',$racine_fonctions, true)) { |
|
| 621 | + $detruire_copieur_si_besoin($serveur_dest); |
|
| 622 | + } |
|
| 623 | + else { |
|
| 624 | + spip_log( "Fonction '{$racine_fonctions}_detruire_copieur_si_besoin' inconnue.",'dump.'._LOG_INFO_IMPORTANTE); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + // OK, copie complete |
|
| 628 | + return true; |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -639,25 +639,25 @@ discard block |
||
| 639 | 639 | */ |
| 640 | 640 | function base_inserer_copie($table,$rows,$desc_dest,$serveur_dest){ |
| 641 | 641 | |
| 642 | - // verifier le nombre d'insertion |
|
| 643 | - $nb1 = sql_countsel($table,'','','',$serveur_dest); |
|
| 644 | - // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 645 | - $r = sql_insertq_multi($table,$rows,$desc_dest,$serveur_dest); |
|
| 646 | - $nb = sql_countsel($table,'','','',$serveur_dest); |
|
| 647 | - if ($nb-$nb1<count($rows)){ |
|
| 648 | - spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows).". On retente 1 par 1","dump"._LOG_INFO_IMPORTANTE); |
|
| 649 | - foreach($rows as $row){ |
|
| 650 | - // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 651 | - $r = sql_insertq($table,$row,$desc_dest,$serveur_dest); |
|
| 652 | - } |
|
| 653 | - // on reverifie le total |
|
| 654 | - $r = 0; |
|
| 655 | - $nb = sql_countsel($table,'','','',$serveur_dest); |
|
| 656 | - if ($nb-$nb1<count($rows)){ |
|
| 657 | - spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows)." apres insertion 1 par 1","dump"._LOG_ERREUR); |
|
| 658 | - $r = false; |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - return $r; |
|
| 642 | + // verifier le nombre d'insertion |
|
| 643 | + $nb1 = sql_countsel($table,'','','',$serveur_dest); |
|
| 644 | + // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 645 | + $r = sql_insertq_multi($table,$rows,$desc_dest,$serveur_dest); |
|
| 646 | + $nb = sql_countsel($table,'','','',$serveur_dest); |
|
| 647 | + if ($nb-$nb1<count($rows)){ |
|
| 648 | + spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows).". On retente 1 par 1","dump"._LOG_INFO_IMPORTANTE); |
|
| 649 | + foreach($rows as $row){ |
|
| 650 | + // si l'enregistrement est deja en base, ca fera un echec ou un doublon |
|
| 651 | + $r = sql_insertq($table,$row,$desc_dest,$serveur_dest); |
|
| 652 | + } |
|
| 653 | + // on reverifie le total |
|
| 654 | + $r = 0; |
|
| 655 | + $nb = sql_countsel($table,'','','',$serveur_dest); |
|
| 656 | + if ($nb-$nb1<count($rows)){ |
|
| 657 | + spip_log("base_inserer_copie : ".($nb-$nb1)." insertions au lieu de ".count($rows)." apres insertion 1 par 1","dump"._LOG_ERREUR); |
|
| 658 | + $r = false; |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + return $r; |
|
| 662 | 662 | } |
| 663 | 663 | ?> |
@@ -15,109 +15,109 @@ |
||
| 15 | 15 | // http://doc.spip.org/@base_admin_repair_dist |
| 16 | 16 | function base_repair_dist($titre='', $reprise='') { |
| 17 | 17 | |
| 18 | - $res = admin_repair_tables(); |
|
| 19 | - if (!$res) { |
|
| 20 | - $res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."</div>\n"; |
|
| 21 | - } else { |
|
| 22 | - include_spip('inc/rubriques'); |
|
| 23 | - calculer_rubriques(); |
|
| 24 | - propager_les_secteurs(); |
|
| 25 | - } |
|
| 26 | - include_spip('inc/minipres'); |
|
| 27 | - $res .= pipeline('base_admin_repair',$res); |
|
| 28 | - echo minipres(_T('texte_tentative_recuperation'), |
|
| 29 | - $res . generer_form_ecrire('accueil', '','',_T('public:accueil_site'))); |
|
| 18 | + $res = admin_repair_tables(); |
|
| 19 | + if (!$res) { |
|
| 20 | + $res = "<div class='error'>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."</div>\n"; |
|
| 21 | + } else { |
|
| 22 | + include_spip('inc/rubriques'); |
|
| 23 | + calculer_rubriques(); |
|
| 24 | + propager_les_secteurs(); |
|
| 25 | + } |
|
| 26 | + include_spip('inc/minipres'); |
|
| 27 | + $res .= pipeline('base_admin_repair',$res); |
|
| 28 | + echo minipres(_T('texte_tentative_recuperation'), |
|
| 29 | + $res . generer_form_ecrire('accueil', '','',_T('public:accueil_site'))); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // http://doc.spip.org/@admin_repair_plat |
| 33 | 33 | function admin_repair_plat(){ |
| 34 | - spip_log( "verification des documents joints", _LOG_INFO_IMPORTANTE); |
|
| 35 | - $out = ""; |
|
| 36 | - $repertoire = array(); |
|
| 37 | - include_spip('inc/getdocument'); |
|
| 38 | - $res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'"); |
|
| 34 | + spip_log( "verification des documents joints", _LOG_INFO_IMPORTANTE); |
|
| 35 | + $out = ""; |
|
| 36 | + $repertoire = array(); |
|
| 37 | + include_spip('inc/getdocument'); |
|
| 38 | + $res = sql_select('*','spip_documents',"fichier REGEXP CONCAT('^',extension,'[^/\]') AND distant='non'"); |
|
| 39 | 39 | |
| 40 | - while ($row=sql_fetch($res)){ |
|
| 41 | - $ext = $row['extension']; |
|
| 42 | - if (!$ext) { |
|
| 43 | - spip_log("document sans extension: " . $row['id_document'], _LOG_INFO_IMPORTANTE); |
|
| 44 | - continue; |
|
| 45 | - } |
|
| 46 | - if (!isset($repertoire[$ext])){ |
|
| 47 | - if (@file_exists($plat = _DIR_IMG. $ext .".plat")) |
|
| 48 | - spip_unlink($plat); |
|
| 49 | - $repertoire[$ext] = creer_repertoire_documents($ext); |
|
| 50 | - if (preg_match(',_$,',$repertoire[$ext])) |
|
| 51 | - $repertoire[$ext] = false; |
|
| 52 | - } |
|
| 53 | - if ($d=$repertoire[$ext]){ |
|
| 54 | - $d = substr($d,strlen(_DIR_IMG)); |
|
| 55 | - $src = $row['fichier']; |
|
| 56 | - $dest = $d . substr($src,strlen($d)); |
|
| 57 | - if (@copy(_DIR_IMG . $src, _DIR_IMG . $dest) |
|
| 58 | - AND file_exists(_DIR_IMG . $dest)) { |
|
| 59 | - sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document'])); |
|
| 60 | - spip_unlink(_DIR_IMG . $src); |
|
| 61 | - $out .= "$src => $dest<br />"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 40 | + while ($row=sql_fetch($res)){ |
|
| 41 | + $ext = $row['extension']; |
|
| 42 | + if (!$ext) { |
|
| 43 | + spip_log("document sans extension: " . $row['id_document'], _LOG_INFO_IMPORTANTE); |
|
| 44 | + continue; |
|
| 45 | + } |
|
| 46 | + if (!isset($repertoire[$ext])){ |
|
| 47 | + if (@file_exists($plat = _DIR_IMG. $ext .".plat")) |
|
| 48 | + spip_unlink($plat); |
|
| 49 | + $repertoire[$ext] = creer_repertoire_documents($ext); |
|
| 50 | + if (preg_match(',_$,',$repertoire[$ext])) |
|
| 51 | + $repertoire[$ext] = false; |
|
| 52 | + } |
|
| 53 | + if ($d=$repertoire[$ext]){ |
|
| 54 | + $d = substr($d,strlen(_DIR_IMG)); |
|
| 55 | + $src = $row['fichier']; |
|
| 56 | + $dest = $d . substr($src,strlen($d)); |
|
| 57 | + if (@copy(_DIR_IMG . $src, _DIR_IMG . $dest) |
|
| 58 | + AND file_exists(_DIR_IMG . $dest)) { |
|
| 59 | + sql_updateq('spip_documents',array('fichier'=>$dest),'id_document='.intval($row['id_document'])); |
|
| 60 | + spip_unlink(_DIR_IMG . $src); |
|
| 61 | + $out .= "$src => $dest<br />"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - return $out; |
|
| 66 | + return $out; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // http://doc.spip.org/@admin_repair_tables |
| 70 | 70 | function admin_repair_tables() { |
| 71 | 71 | |
| 72 | - $repair = sql_repair('repair', NULL, 'continue'); |
|
| 72 | + $repair = sql_repair('repair', NULL, 'continue'); |
|
| 73 | 73 | |
| 74 | - // recreer les tables manquantes eventuelles |
|
| 75 | - include_spip('base/create'); |
|
| 76 | - creer_base(); |
|
| 74 | + // recreer les tables manquantes eventuelles |
|
| 75 | + include_spip('base/create'); |
|
| 76 | + creer_base(); |
|
| 77 | 77 | |
| 78 | - $connexion = $GLOBALS['connexions'][0]; |
|
| 79 | - $prefixe = $connexion['prefixe']; |
|
| 80 | - $res1 = sql_showbase(); |
|
| 81 | - $res = ""; |
|
| 82 | - if ($res1) { |
|
| 83 | - while ($r = sql_fetch($res1)) { |
|
| 84 | - $tab = array_shift($r); |
|
| 78 | + $connexion = $GLOBALS['connexions'][0]; |
|
| 79 | + $prefixe = $connexion['prefixe']; |
|
| 80 | + $res1 = sql_showbase(); |
|
| 81 | + $res = ""; |
|
| 82 | + if ($res1) { |
|
| 83 | + while ($r = sql_fetch($res1)) { |
|
| 84 | + $tab = array_shift($r); |
|
| 85 | 85 | |
| 86 | - $class = ""; |
|
| 87 | - $m = "<strong>$tab</strong> "; |
|
| 88 | - spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 89 | - // supprimer la meta avant de lancer la reparation |
|
| 90 | - // car le repair peut etre long ; on ne veut pas boucler |
|
| 91 | - effacer_meta('admin_repair'); |
|
| 92 | - if ($repair){ |
|
| 93 | - $result_repair = sql_repair($tab); |
|
| 94 | - if (!$result_repair) return false; |
|
| 95 | - } |
|
| 86 | + $class = ""; |
|
| 87 | + $m = "<strong>$tab</strong> "; |
|
| 88 | + spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 89 | + // supprimer la meta avant de lancer la reparation |
|
| 90 | + // car le repair peut etre long ; on ne veut pas boucler |
|
| 91 | + effacer_meta('admin_repair'); |
|
| 92 | + if ($repair){ |
|
| 93 | + $result_repair = sql_repair($tab); |
|
| 94 | + if (!$result_repair) return false; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // essayer de maj la table (creation de champs manquants) |
|
| 98 | - maj_tables($tab); |
|
| 97 | + // essayer de maj la table (creation de champs manquants) |
|
| 98 | + maj_tables($tab); |
|
| 99 | 99 | |
| 100 | - $count = sql_countsel($tab); |
|
| 100 | + $count = sql_countsel($tab); |
|
| 101 | 101 | |
| 102 | - if ($count>1) |
|
| 103 | - $m .= "("._T('texte_compte_elements', array('count' => $count)).")\n"; |
|
| 104 | - else if ($count==1) |
|
| 105 | - $m .= "("._T('texte_compte_element', array('count' => $count)).")\n"; |
|
| 106 | - else |
|
| 107 | - $m .= "("._T('texte_vide').")\n"; |
|
| 102 | + if ($count>1) |
|
| 103 | + $m .= "("._T('texte_compte_elements', array('count' => $count)).")\n"; |
|
| 104 | + else if ($count==1) |
|
| 105 | + $m .= "("._T('texte_compte_element', array('count' => $count)).")\n"; |
|
| 106 | + else |
|
| 107 | + $m .= "("._T('texte_vide').")\n"; |
|
| 108 | 108 | |
| 109 | - if ($result_repair |
|
| 110 | - AND $msg = join(" ", sql_fetch($result_repair)) . ' ' |
|
| 111 | - AND strpos($msg, ' OK ')==FALSE){ |
|
| 112 | - $class = " class='notice'"; |
|
| 113 | - $m .= "<br /><tt>".spip_htmlentities($msg)."</tt>\n"; |
|
| 114 | - } |
|
| 115 | - else |
|
| 116 | - $m .= " "._T('texte_table_ok'); |
|
| 109 | + if ($result_repair |
|
| 110 | + AND $msg = join(" ", sql_fetch($result_repair)) . ' ' |
|
| 111 | + AND strpos($msg, ' OK ')==FALSE){ |
|
| 112 | + $class = " class='notice'"; |
|
| 113 | + $m .= "<br /><tt>".spip_htmlentities($msg)."</tt>\n"; |
|
| 114 | + } |
|
| 115 | + else |
|
| 116 | + $m .= " "._T('texte_table_ok'); |
|
| 117 | 117 | |
| 118 | - $res .="<div$class>$m</div>"; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - return $res; |
|
| 118 | + $res .="<div$class>$m</div>"; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + return $res; |
|
| 122 | 122 | } |
| 123 | 123 | ?> |
@@ -15,26 +15,26 @@ |
||
| 15 | 15 | // http://doc.spip.org/@base_delete_all_dist |
| 16 | 16 | function base_delete_all_dist($titre) |
| 17 | 17 | { |
| 18 | - $delete = _request('delete'); |
|
| 19 | - $res = array(); |
|
| 20 | - if (is_array($delete)) { |
|
| 21 | - foreach ($delete as $table) { |
|
| 22 | - if (sql_drop_table($table)) |
|
| 23 | - $res[] = $table; |
|
| 24 | - else spip_log( "SPIP n'a pas pu detruire $table.", _LOG_ERREUR); |
|
| 25 | - } |
|
| 18 | + $delete = _request('delete'); |
|
| 19 | + $res = array(); |
|
| 20 | + if (is_array($delete)) { |
|
| 21 | + foreach ($delete as $table) { |
|
| 22 | + if (sql_drop_table($table)) |
|
| 23 | + $res[] = $table; |
|
| 24 | + else spip_log( "SPIP n'a pas pu detruire $table.", _LOG_ERREUR); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - // un pipeline pour detruire les tables installees par les plugins |
|
| 28 | - pipeline('delete_tables', ''); |
|
| 27 | + // un pipeline pour detruire les tables installees par les plugins |
|
| 28 | + pipeline('delete_tables', ''); |
|
| 29 | 29 | |
| 30 | - spip_unlink(_FILE_CONNECT); |
|
| 31 | - spip_unlink(_FILE_CHMOD); |
|
| 32 | - spip_unlink(_FILE_META); |
|
| 33 | - spip_unlink(_ACCESS_FILE_NAME); |
|
| 34 | - spip_unlink(_CACHE_RUBRIQUES); |
|
| 35 | - } |
|
| 36 | - $d = count($delete); |
|
| 37 | - $r = count($res); |
|
| 38 | - spip_log("Tables detruites: $r sur $d: " . join(', ',$res), _LOG_INFO_IMPORTANTE); |
|
| 30 | + spip_unlink(_FILE_CONNECT); |
|
| 31 | + spip_unlink(_FILE_CHMOD); |
|
| 32 | + spip_unlink(_FILE_META); |
|
| 33 | + spip_unlink(_ACCESS_FILE_NAME); |
|
| 34 | + spip_unlink(_CACHE_RUBRIQUES); |
|
| 35 | + } |
|
| 36 | + $d = count($delete); |
|
| 37 | + $r = count($res); |
|
| 38 | + spip_log("Tables detruites: $r sur $d: " . join(', ',$res), _LOG_INFO_IMPORTANTE); |
|
| 39 | 39 | } |
| 40 | 40 | ?> |
@@ -29,78 +29,78 @@ discard block |
||
| 29 | 29 | // l'impossibilite de telecharger une image |
| 30 | 30 | // http://trac.rezo.net/trac/spip/ticket/1238 |
| 31 | 31 | $GLOBALS['maj'][11171] = array( |
| 32 | - array('spip_query', "UPDATE spip_types_documents SET upload='oui' WHERE upload IS NULL OR upload!='non'") |
|
| 32 | + array('spip_query', "UPDATE spip_types_documents SET upload='oui' WHERE upload IS NULL OR upload!='non'") |
|
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | 35 | function maj_11268() { |
| 36 | - global $tables_auxiliaires; |
|
| 37 | - include_spip('base/auxiliaires'); |
|
| 38 | - $v = $tables_auxiliaires[$k='spip_resultats']; |
|
| 39 | - sql_create($k, $v['field'], $v['key'], false, false); |
|
| 36 | + global $tables_auxiliaires; |
|
| 37 | + include_spip('base/auxiliaires'); |
|
| 38 | + $v = $tables_auxiliaires[$k='spip_resultats']; |
|
| 39 | + sql_create($k, $v['field'], $v['key'], false, false); |
|
| 40 | 40 | } |
| 41 | 41 | $GLOBALS['maj'][11268] = array(array('maj_11268')); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | function maj_11276 () { |
| 45 | - include_spip('maj/v019'); |
|
| 46 | - maj_1_938(); |
|
| 45 | + include_spip('maj/v019'); |
|
| 46 | + maj_1_938(); |
|
| 47 | 47 | } |
| 48 | 48 | $GLOBALS['maj'][11276] = array(array('maj_11276')); |
| 49 | 49 | |
| 50 | 50 | // reparer les referers d'article, qui sont vides depuis [10572] |
| 51 | 51 | function maj_11388 () { |
| 52 | - $s = sql_select('referer_md5', 'spip_referers_articles', "referer='' OR referer IS NULL"); |
|
| 53 | - while ($t = sql_fetch($s)) { |
|
| 54 | - $k = sql_fetsel('referer', 'spip_referers', 'referer_md5='.sql_quote($t['referer_md5'])); |
|
| 55 | - if ($k['referer']) { |
|
| 56 | - spip_query('UPDATE spip_referers_articles |
|
| 52 | + $s = sql_select('referer_md5', 'spip_referers_articles', "referer='' OR referer IS NULL"); |
|
| 53 | + while ($t = sql_fetch($s)) { |
|
| 54 | + $k = sql_fetsel('referer', 'spip_referers', 'referer_md5='.sql_quote($t['referer_md5'])); |
|
| 55 | + if ($k['referer']) { |
|
| 56 | + spip_query('UPDATE spip_referers_articles |
|
| 57 | 57 | SET referer='.sql_quote($k['referer']).' |
| 58 | 58 | WHERE referer_md5='.sql_quote($t['referer_md5']) |
| 59 | - ." AND (referer='' OR referer IS NULL)" |
|
| 60 | - ); |
|
| 61 | - } |
|
| 62 | - } |
|
| 59 | + ." AND (referer='' OR referer IS NULL)" |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | $GLOBALS['maj'][11388] = array(array('maj_11388')); |
| 65 | 65 | |
| 66 | 66 | // reparer spip_mots.type = titre du groupe |
| 67 | 67 | function maj_11431 () { |
| 68 | - // mysql only |
|
| 69 | - // spip_query("UPDATE spip_mots AS a LEFT JOIN spip_groupes_mots AS b ON (a.id_groupe = b.id_groupe) SET a.type=b.titre"); |
|
| 70 | - |
|
| 71 | - // selection des mots cles dont le type est different du groupe |
|
| 72 | - $res = sql_select( |
|
| 73 | - array("a.id_mot AS id_mot", "b.titre AS type"), |
|
| 74 | - array("spip_mots AS a LEFT JOIN spip_groupes_mots AS b ON (a.id_groupe = b.id_groupe)"), |
|
| 75 | - array("a.type != b.titre")); |
|
| 76 | - // mise a jour de ces mots la |
|
| 77 | - if ($res){ |
|
| 78 | - while ($r = sql_fetch($res)){ |
|
| 79 | - sql_updateq('spip_mots', array('type'=>$r['type']), 'id_mot='.sql_quote($r['id_mot'])); |
|
| 80 | - } |
|
| 81 | - } |
|
| 68 | + // mysql only |
|
| 69 | + // spip_query("UPDATE spip_mots AS a LEFT JOIN spip_groupes_mots AS b ON (a.id_groupe = b.id_groupe) SET a.type=b.titre"); |
|
| 70 | + |
|
| 71 | + // selection des mots cles dont le type est different du groupe |
|
| 72 | + $res = sql_select( |
|
| 73 | + array("a.id_mot AS id_mot", "b.titre AS type"), |
|
| 74 | + array("spip_mots AS a LEFT JOIN spip_groupes_mots AS b ON (a.id_groupe = b.id_groupe)"), |
|
| 75 | + array("a.type != b.titre")); |
|
| 76 | + // mise a jour de ces mots la |
|
| 77 | + if ($res){ |
|
| 78 | + while ($r = sql_fetch($res)){ |
|
| 79 | + sql_updateq('spip_mots', array('type'=>$r['type']), 'id_mot='.sql_quote($r['id_mot'])); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | $GLOBALS['maj'][11431] = array(array('maj_11431')); |
| 84 | 84 | |
| 85 | 85 | // reparer spip_types_documents.id_type |
| 86 | 86 | // qui est parfois encore present |
| 87 | 87 | function maj_11778 () { |
| 88 | - // si presence id_type |
|
| 89 | - $s = sql_showtable('spip_types_documents'); |
|
| 90 | - if (isset($s['field']['id_type'])) { |
|
| 91 | - sql_alter('TABLE spip_types_documents CHANGE id_type id_type BIGINT(21) NOT NULL'); |
|
| 92 | - sql_alter('TABLE spip_types_documents DROP id_type'); |
|
| 93 | - sql_alter('TABLE spip_types_documents ADD PRIMARY KEY (extension)'); |
|
| 94 | - } |
|
| 88 | + // si presence id_type |
|
| 89 | + $s = sql_showtable('spip_types_documents'); |
|
| 90 | + if (isset($s['field']['id_type'])) { |
|
| 91 | + sql_alter('TABLE spip_types_documents CHANGE id_type id_type BIGINT(21) NOT NULL'); |
|
| 92 | + sql_alter('TABLE spip_types_documents DROP id_type'); |
|
| 93 | + sql_alter('TABLE spip_types_documents ADD PRIMARY KEY (extension)'); |
|
| 94 | + } |
|
| 95 | 95 | } |
| 96 | 96 | $GLOBALS['maj'][11778] = array(array('maj_11778')); |
| 97 | 97 | |
| 98 | 98 | // Optimisation des forums |
| 99 | 99 | function maj_11790 () { |
| 100 | 100 | # sql_alter('TABLE spip_forum DROP INDEX id_message id_message'); |
| 101 | - sql_alter('TABLE spip_forum ADD INDEX id_parent (id_parent)'); |
|
| 102 | - sql_alter('TABLE spip_forum ADD INDEX id_auteur (id_auteur)'); |
|
| 103 | - sql_alter('TABLE spip_forum ADD INDEX id_thread (id_thread)'); |
|
| 101 | + sql_alter('TABLE spip_forum ADD INDEX id_parent (id_parent)'); |
|
| 102 | + sql_alter('TABLE spip_forum ADD INDEX id_auteur (id_auteur)'); |
|
| 103 | + sql_alter('TABLE spip_forum ADD INDEX id_thread (id_thread)'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $GLOBALS['maj'][11790] = array(array('maj_11790')); |
@@ -124,34 +124,34 @@ discard block |
||
| 124 | 124 | // Reunir en une seule table les liens de documents |
| 125 | 125 | // spip_documents_articles et spip_documents_forum |
| 126 | 126 | function maj_12008 () { |
| 127 | - // Creer spip_documents_liens |
|
| 128 | - global $tables_auxiliaires; |
|
| 129 | - include_spip('base/auxiliaires'); |
|
| 130 | - $v = $tables_auxiliaires[$k='spip_documents_liens']; |
|
| 131 | - sql_create($k, $v['field'], $v['key'], false, false); |
|
| 132 | - |
|
| 133 | - // Recopier les donnees |
|
| 134 | - foreach (array('article', 'breve', 'rubrique', 'auteur', 'forum') as $l) { |
|
| 135 | - if ($s = sql_select('*', 'spip_documents_'.$l.'s') |
|
| 136 | - OR $s = sql_select('*', 'spip_documents_'.$l)) { |
|
| 137 | - $tampon = array(); |
|
| 138 | - while ($t = sql_fetch($s)) { |
|
| 139 | - // transformer id_xx=N en (id_objet=N, objet=xx) |
|
| 140 | - $t['id_objet'] = $t["id_$l"]; |
|
| 141 | - $t['objet'] = $l; |
|
| 142 | - unset($t["id_$l"]); |
|
| 143 | - unset($t['maj']); |
|
| 144 | - $tampon[] = $t; |
|
| 145 | - if (count($tampon)>10000) { |
|
| 146 | - sql_insertq_multi('spip_documents_liens',$tampon); |
|
| 147 | - $tampon = array(); |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - if (count($tampon)) { |
|
| 151 | - sql_insertq_multi('spip_documents_liens', $tampon); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - } |
|
| 127 | + // Creer spip_documents_liens |
|
| 128 | + global $tables_auxiliaires; |
|
| 129 | + include_spip('base/auxiliaires'); |
|
| 130 | + $v = $tables_auxiliaires[$k='spip_documents_liens']; |
|
| 131 | + sql_create($k, $v['field'], $v['key'], false, false); |
|
| 132 | + |
|
| 133 | + // Recopier les donnees |
|
| 134 | + foreach (array('article', 'breve', 'rubrique', 'auteur', 'forum') as $l) { |
|
| 135 | + if ($s = sql_select('*', 'spip_documents_'.$l.'s') |
|
| 136 | + OR $s = sql_select('*', 'spip_documents_'.$l)) { |
|
| 137 | + $tampon = array(); |
|
| 138 | + while ($t = sql_fetch($s)) { |
|
| 139 | + // transformer id_xx=N en (id_objet=N, objet=xx) |
|
| 140 | + $t['id_objet'] = $t["id_$l"]; |
|
| 141 | + $t['objet'] = $l; |
|
| 142 | + unset($t["id_$l"]); |
|
| 143 | + unset($t['maj']); |
|
| 144 | + $tampon[] = $t; |
|
| 145 | + if (count($tampon)>10000) { |
|
| 146 | + sql_insertq_multi('spip_documents_liens',$tampon); |
|
| 147 | + $tampon = array(); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + if (count($tampon)) { |
|
| 151 | + sql_insertq_multi('spip_documents_liens', $tampon); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $GLOBALS['maj'][12008] = array( |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | ); |
| 193 | 193 | |
| 194 | 194 | function maj_13135 () { |
| 195 | - include_spip('inc/rubriques'); |
|
| 196 | - calculer_prochain_postdate(); |
|
| 195 | + include_spip('inc/rubriques'); |
|
| 196 | + calculer_prochain_postdate(); |
|
| 197 | 197 | |
| 198 | - // supprimer les eventuels vieux cache plugin qui n'utilisaient pas _chemin |
|
| 199 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 200 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 198 | + // supprimer les eventuels vieux cache plugin qui n'utilisaient pas _chemin |
|
| 199 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 200 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $GLOBALS['maj'][13135] = array(array('maj_13135')); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | // sites plantes en mode "'su" au lieu de "sus" |
| 223 | 223 | $GLOBALS['maj'][13929] = array( |
| 224 | - array('sql_update',"spip_syndic",array('syndication'=>"'sus'"),"syndication LIKE '\\'%'") |
|
| 224 | + array('sql_update',"spip_syndic",array('syndication'=>"'sus'"),"syndication LIKE '\\'%'") |
|
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | // Types de fichiers m4a/m4b/m4p/m4u/m4v/dv |
@@ -236,18 +236,18 @@ discard block |
||
| 236 | 236 | // Retour en arriere pour ceux qui l'ont subi, ne rien faire sinon |
| 237 | 237 | if (@$GLOBALS['meta']['version_installee'] >= 14588) { |
| 238 | 238 | |
| 239 | - // "mode" est un mot-cle d'Oracle |
|
| 240 | - $GLOBALS['maj'][14588] = array( |
|
| 241 | - array('sql_alter',"TABLE spip_documents DROP INDEX mode"), |
|
| 242 | - array('sql_alter',"TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL"), |
|
| 243 | - array('sql_alter',"TABLE spip_documents ADD INDEX genre(genre)") |
|
| 244 | - ); |
|
| 245 | - // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 246 | - $GLOBALS['maj'][14598] = array( |
|
| 247 | - array('sql_alter',"TABLE spip_documents DROP INDEX genre"), |
|
| 248 | - array('sql_alter',"TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL"), |
|
| 249 | - array('sql_alter',"TABLE spip_documents ADD INDEX mode(mode)") |
|
| 250 | - ); |
|
| 239 | + // "mode" est un mot-cle d'Oracle |
|
| 240 | + $GLOBALS['maj'][14588] = array( |
|
| 241 | + array('sql_alter',"TABLE spip_documents DROP INDEX mode"), |
|
| 242 | + array('sql_alter',"TABLE spip_documents CHANGE mode genre ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL"), |
|
| 243 | + array('sql_alter',"TABLE spip_documents ADD INDEX genre(genre)") |
|
| 244 | + ); |
|
| 245 | + // solution moins intrusive au pb de mot-cle d'Oracle, retour avant 14588 |
|
| 246 | + $GLOBALS['maj'][14598] = array( |
|
| 247 | + array('sql_alter',"TABLE spip_documents DROP INDEX genre"), |
|
| 248 | + array('sql_alter',"TABLE spip_documents CHANGE genre mode ENUM('vignette', 'image', 'document') DEFAULT 'document' NOT NULL"), |
|
| 249 | + array('sql_alter',"TABLE spip_documents ADD INDEX mode(mode)") |
|
| 250 | + ); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | // Restauration correcte des types mime des fichiers Ogg |
@@ -260,246 +260,246 @@ discard block |
||
| 260 | 260 | $GLOBALS['maj'][15827] = array(array('upgrade_types_documents')); |
| 261 | 261 | |
| 262 | 262 | $GLOBALS['maj'][16428] = array( |
| 263 | - array('maj_liens','auteur'), // creer la table liens |
|
| 264 | - array('maj_liens','auteur','article'), |
|
| 265 | - array('sql_drop_table',"spip_auteurs_articles"), |
|
| 266 | - array('maj_liens','auteur','rubrique'), |
|
| 267 | - array('sql_drop_table',"spip_auteurs_rubriques"), |
|
| 268 | - array('maj_liens','auteur','message'), |
|
| 269 | - array('sql_drop_table',"spip_auteurs_messages"), |
|
| 263 | + array('maj_liens','auteur'), // creer la table liens |
|
| 264 | + array('maj_liens','auteur','article'), |
|
| 265 | + array('sql_drop_table',"spip_auteurs_articles"), |
|
| 266 | + array('maj_liens','auteur','rubrique'), |
|
| 267 | + array('sql_drop_table',"spip_auteurs_rubriques"), |
|
| 268 | + array('maj_liens','auteur','message'), |
|
| 269 | + array('sql_drop_table',"spip_auteurs_messages"), |
|
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | // Reunir en une seule table les liens de documents |
| 273 | 273 | // spip_documents_articles et spip_documents_forum |
| 274 | 274 | function maj_liens($pivot,$l='') { |
| 275 | 275 | |
| 276 | - @define('_LOG_FILTRE_GRAVITE',8); |
|
| 277 | - |
|
| 278 | - $exceptions_pluriel = array('forum'=>'forum','syndic'=>'syndic'); |
|
| 279 | - |
|
| 280 | - $pivot = preg_replace(',[^\w],','',$pivot); // securite |
|
| 281 | - $pivots = (isset($exceptions_pluriel[$pivot])?$exceptions_pluriel[$pivot]:$pivot."s"); |
|
| 282 | - $liens = "spip_".$pivots."_liens"; |
|
| 283 | - $id_pivot = "id_".$pivot; |
|
| 284 | - // Creer spip_auteurs_liens |
|
| 285 | - global $tables_auxiliaires; |
|
| 286 | - if (!$l) { |
|
| 287 | - include_spip('base/auxiliaires'); |
|
| 288 | - include_spip('base/create'); |
|
| 289 | - creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false); |
|
| 290 | - } |
|
| 291 | - else { |
|
| 292 | - // Preparer |
|
| 293 | - $l = preg_replace(',[^\w],','',$l); // securite |
|
| 294 | - $primary = "id_$l"; |
|
| 295 | - $objet = ($l=='syndic'?'site':$l); |
|
| 296 | - $ls = (isset($exceptions_pluriel[$l])?$exceptions_pluriel[$l]:$l."s"); |
|
| 297 | - $ancienne_table = 'spip_'.$pivots.'_'.$ls; |
|
| 298 | - $pool = 400; |
|
| 299 | - |
|
| 300 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 301 | - if (!$desc = $trouver_table($ancienne_table)) |
|
| 302 | - return; |
|
| 303 | - |
|
| 304 | - // securite pour ne pas perdre de donnees |
|
| 305 | - if (!$trouver_table($liens)) |
|
| 306 | - return; |
|
| 307 | - |
|
| 308 | - $champs = $desc['field']; |
|
| 309 | - if (isset($champs['maj'])) unset($champs['maj']); |
|
| 310 | - if (isset($champs[$primary])) unset($champs[$primary]); |
|
| 311 | - |
|
| 312 | - $champs = array_keys($champs); |
|
| 313 | - // ne garder que les champs qui existent sur la table destination |
|
| 314 | - if ($desc_cible = $trouver_table($liens)){ |
|
| 315 | - $champs = array_intersect($champs,array_keys($desc_cible['field'])); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $champs[] = "$primary as id_objet"; |
|
| 319 | - $champs[] = "'$objet' as objet"; |
|
| 320 | - $champs = implode(', ',$champs); |
|
| 321 | - |
|
| 322 | - // Recopier les donnees |
|
| 323 | - $sub_pool = 100; |
|
| 324 | - while ($ids = array_map('reset',sql_allfetsel("$primary",$ancienne_table,'','','',"0,$sub_pool"))){ |
|
| 325 | - $insert = array(); |
|
| 326 | - foreach($ids as $id){ |
|
| 327 | - $n = sql_countsel($liens,"objet='$objet' AND id_objet=".intval($id)); |
|
| 328 | - while ($t = sql_allfetsel($champs, $ancienne_table,"$primary=".intval($id),'',$id_pivot,"$n,$pool")) { |
|
| 329 | - $n+=count($t); |
|
| 330 | - // empiler en s'assurant a minima de l'unicite |
|
| 331 | - while ($r = array_shift($t)) |
|
| 332 | - $insert[$r[$id_pivot].':'.$r['id_objet']] = $r; |
|
| 333 | - if (count($insert)>=$sub_pool){ |
|
| 334 | - maj_liens_insertq_multi_check($liens,$insert,$tables_auxiliaires[$liens]); |
|
| 335 | - $insert = array(); |
|
| 336 | - } |
|
| 337 | - // si timeout, sortir, la relance nous ramenera dans cette fonction |
|
| 338 | - // et on verifiera/repartira de la |
|
| 339 | - if (time() >= _TIME_OUT) return; |
|
| 340 | - } |
|
| 341 | - if (time() >= _TIME_OUT) return; |
|
| 342 | - } |
|
| 343 | - if (count($insert)) |
|
| 344 | - maj_liens_insertq_multi_check($liens,$insert,$tables_auxiliaires[$liens]); |
|
| 345 | - sql_delete ($ancienne_table, sql_in($primary,$ids)); |
|
| 346 | - } |
|
| 347 | - } |
|
| 276 | + @define('_LOG_FILTRE_GRAVITE',8); |
|
| 277 | + |
|
| 278 | + $exceptions_pluriel = array('forum'=>'forum','syndic'=>'syndic'); |
|
| 279 | + |
|
| 280 | + $pivot = preg_replace(',[^\w],','',$pivot); // securite |
|
| 281 | + $pivots = (isset($exceptions_pluriel[$pivot])?$exceptions_pluriel[$pivot]:$pivot."s"); |
|
| 282 | + $liens = "spip_".$pivots."_liens"; |
|
| 283 | + $id_pivot = "id_".$pivot; |
|
| 284 | + // Creer spip_auteurs_liens |
|
| 285 | + global $tables_auxiliaires; |
|
| 286 | + if (!$l) { |
|
| 287 | + include_spip('base/auxiliaires'); |
|
| 288 | + include_spip('base/create'); |
|
| 289 | + creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false); |
|
| 290 | + } |
|
| 291 | + else { |
|
| 292 | + // Preparer |
|
| 293 | + $l = preg_replace(',[^\w],','',$l); // securite |
|
| 294 | + $primary = "id_$l"; |
|
| 295 | + $objet = ($l=='syndic'?'site':$l); |
|
| 296 | + $ls = (isset($exceptions_pluriel[$l])?$exceptions_pluriel[$l]:$l."s"); |
|
| 297 | + $ancienne_table = 'spip_'.$pivots.'_'.$ls; |
|
| 298 | + $pool = 400; |
|
| 299 | + |
|
| 300 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 301 | + if (!$desc = $trouver_table($ancienne_table)) |
|
| 302 | + return; |
|
| 303 | + |
|
| 304 | + // securite pour ne pas perdre de donnees |
|
| 305 | + if (!$trouver_table($liens)) |
|
| 306 | + return; |
|
| 307 | + |
|
| 308 | + $champs = $desc['field']; |
|
| 309 | + if (isset($champs['maj'])) unset($champs['maj']); |
|
| 310 | + if (isset($champs[$primary])) unset($champs[$primary]); |
|
| 311 | + |
|
| 312 | + $champs = array_keys($champs); |
|
| 313 | + // ne garder que les champs qui existent sur la table destination |
|
| 314 | + if ($desc_cible = $trouver_table($liens)){ |
|
| 315 | + $champs = array_intersect($champs,array_keys($desc_cible['field'])); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $champs[] = "$primary as id_objet"; |
|
| 319 | + $champs[] = "'$objet' as objet"; |
|
| 320 | + $champs = implode(', ',$champs); |
|
| 321 | + |
|
| 322 | + // Recopier les donnees |
|
| 323 | + $sub_pool = 100; |
|
| 324 | + while ($ids = array_map('reset',sql_allfetsel("$primary",$ancienne_table,'','','',"0,$sub_pool"))){ |
|
| 325 | + $insert = array(); |
|
| 326 | + foreach($ids as $id){ |
|
| 327 | + $n = sql_countsel($liens,"objet='$objet' AND id_objet=".intval($id)); |
|
| 328 | + while ($t = sql_allfetsel($champs, $ancienne_table,"$primary=".intval($id),'',$id_pivot,"$n,$pool")) { |
|
| 329 | + $n+=count($t); |
|
| 330 | + // empiler en s'assurant a minima de l'unicite |
|
| 331 | + while ($r = array_shift($t)) |
|
| 332 | + $insert[$r[$id_pivot].':'.$r['id_objet']] = $r; |
|
| 333 | + if (count($insert)>=$sub_pool){ |
|
| 334 | + maj_liens_insertq_multi_check($liens,$insert,$tables_auxiliaires[$liens]); |
|
| 335 | + $insert = array(); |
|
| 336 | + } |
|
| 337 | + // si timeout, sortir, la relance nous ramenera dans cette fonction |
|
| 338 | + // et on verifiera/repartira de la |
|
| 339 | + if (time() >= _TIME_OUT) return; |
|
| 340 | + } |
|
| 341 | + if (time() >= _TIME_OUT) return; |
|
| 342 | + } |
|
| 343 | + if (count($insert)) |
|
| 344 | + maj_liens_insertq_multi_check($liens,$insert,$tables_auxiliaires[$liens]); |
|
| 345 | + sql_delete ($ancienne_table, sql_in($primary,$ids)); |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | function maj_liens_insertq_multi_check($table,$couples,$desc=array()){ |
| 350 | - $n_before = sql_countsel($table); |
|
| 351 | - sql_insertq_multi($table,$couples,$desc); |
|
| 352 | - $n_after = sql_countsel($table); |
|
| 353 | - if (($n_after-$n_before)==count($couples)) |
|
| 354 | - return; |
|
| 355 | - // si ecart, on recommence l'insertion ligne par ligne... |
|
| 356 | - // moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie |
|
| 357 | - foreach($couples as $c) |
|
| 358 | - sql_insertq($table,$c,$desc); |
|
| 350 | + $n_before = sql_countsel($table); |
|
| 351 | + sql_insertq_multi($table,$couples,$desc); |
|
| 352 | + $n_after = sql_countsel($table); |
|
| 353 | + if (($n_after-$n_before)==count($couples)) |
|
| 354 | + return; |
|
| 355 | + // si ecart, on recommence l'insertion ligne par ligne... |
|
| 356 | + // moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie |
|
| 357 | + foreach($couples as $c) |
|
| 358 | + sql_insertq($table,$c,$desc); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | $GLOBALS['maj'][17311] = array( |
| 362 | - array('ecrire_meta',"multi_objets",implode(',', |
|
| 363 | - array_diff( |
|
| 364 | - array($GLOBALS['meta']['multi_rubriques']=='oui'?'spip_rubriques':'',$GLOBALS['meta']['multi_articles']=='oui'?'spip_articles':''), |
|
| 365 | - array('') |
|
| 366 | - ))), |
|
| 367 | - array('ecrire_meta',"gerer_trad_objets",implode(',', |
|
| 368 | - array_diff( |
|
| 369 | - array($GLOBALS['meta']['gerer_trad']=='oui'?'spip_articles':''), |
|
| 370 | - array('') |
|
| 371 | - ))), |
|
| 362 | + array('ecrire_meta',"multi_objets",implode(',', |
|
| 363 | + array_diff( |
|
| 364 | + array($GLOBALS['meta']['multi_rubriques']=='oui'?'spip_rubriques':'',$GLOBALS['meta']['multi_articles']=='oui'?'spip_articles':''), |
|
| 365 | + array('') |
|
| 366 | + ))), |
|
| 367 | + array('ecrire_meta',"gerer_trad_objets",implode(',', |
|
| 368 | + array_diff( |
|
| 369 | + array($GLOBALS['meta']['gerer_trad']=='oui'?'spip_articles':''), |
|
| 370 | + array('') |
|
| 371 | + ))), |
|
| 372 | 372 | ); |
| 373 | 373 | $GLOBALS['maj'][17555] = array( |
| 374 | - array('sql_alter',"TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"), |
|
| 375 | - array('sql_alter',"TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"), |
|
| 374 | + array('sql_alter',"TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"), |
|
| 375 | + array('sql_alter',"TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"), |
|
| 376 | 376 | ); |
| 377 | 377 | |
| 378 | 378 | $GLOBALS['maj'][17563] = array( |
| 379 | - array('sql_alter',"TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"), |
|
| 380 | - array('sql_update','spip_articles',array('virtuel'=>'SUBSTRING(chapo,2)','chapo'=>"''"),"chapo LIKE '=_%'"), |
|
| 379 | + array('sql_alter',"TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"), |
|
| 380 | + array('sql_update','spip_articles',array('virtuel'=>'SUBSTRING(chapo,2)','chapo'=>"''"),"chapo LIKE '=_%'"), |
|
| 381 | 381 | ); |
| 382 | 382 | |
| 383 | 383 | $GLOBALS['maj'][17577] = array( |
| 384 | - array('maj_tables',array('spip_jobs','spip_jobs_liens')), |
|
| 384 | + array('maj_tables',array('spip_jobs','spip_jobs_liens')), |
|
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | $GLOBALS['maj'][17743] = array( |
| 388 | - array('sql_update','spip_auteurs',array('prefs'=>'bio','bio'=>"''"),"statut='nouveau' AND bio<>''"), |
|
| 388 | + array('sql_update','spip_auteurs',array('prefs'=>'bio','bio'=>"''"),"statut='nouveau' AND bio<>''"), |
|
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | 391 | $GLOBALS['maj'][18219] = array( |
| 392 | - array('sql_alter',"TABLE spip_rubriques DROP id_import"), |
|
| 393 | - array('sql_alter',"TABLE spip_rubriques DROP export"), |
|
| 392 | + array('sql_alter',"TABLE spip_rubriques DROP id_import"), |
|
| 393 | + array('sql_alter',"TABLE spip_rubriques DROP export"), |
|
| 394 | 394 | ); |
| 395 | 395 | |
| 396 | 396 | $GLOBALS['maj'][18310] = array( |
| 397 | - array('sql_alter',"TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"), |
|
| 397 | + array('sql_alter',"TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"), |
|
| 398 | 398 | ); |
| 399 | 399 | |
| 400 | 400 | $GLOBALS['maj'][18597] = array( |
| 401 | - array('sql_alter',"TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"), |
|
| 402 | - array('maj_propager_les_secteurs'), |
|
| 401 | + array('sql_alter',"TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"), |
|
| 402 | + array('maj_propager_les_secteurs'), |
|
| 403 | 403 | ); |
| 404 | 404 | |
| 405 | 405 | $GLOBALS['maj'][18955] = array( |
| 406 | - array('sql_alter',"TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)"), |
|
| 407 | - array('sql_alter',"TABLE spip_auteurs_liens ADD INDEX objet (objet)"), |
|
| 406 | + array('sql_alter',"TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)"), |
|
| 407 | + array('sql_alter',"TABLE spip_auteurs_liens ADD INDEX objet (objet)"), |
|
| 408 | 408 | ); |
| 409 | 409 | |
| 410 | 410 | |
| 411 | 411 | function maj_propager_les_secteurs(){ |
| 412 | - include_spip('inc/rubriques'); |
|
| 413 | - propager_les_secteurs(); |
|
| 412 | + include_spip('inc/rubriques'); |
|
| 413 | + propager_les_secteurs(); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
| 417 | 417 | function maj_collation_sqlite(){ |
| 418 | 418 | |
| 419 | 419 | |
| 420 | - include_spip('base/dump'); |
|
| 421 | - $tables = base_lister_toutes_tables(); |
|
| 422 | - |
|
| 423 | - // rien a faire si base non sqlite |
|
| 424 | - if (strncmp($GLOBALS['connexions'][0]['type'],'sqlite',6)!==0) |
|
| 425 | - return; |
|
| 426 | - |
|
| 427 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 428 | - // forcer le vidage de cache |
|
| 429 | - $trouver_table(''); |
|
| 430 | - |
|
| 431 | - // cas particulier spip_auteurs : retablir le collate binary sur le login |
|
| 432 | - $desc = $trouver_table("spip_auteurs"); |
|
| 433 | - spip_log("spip_auteurs : ".var_export($desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 434 | - if (stripos($desc['field']['login'],"BINARY")===false){ |
|
| 435 | - spip_log("Retablir champ login BINARY sur table spip_auteurs","maj"); |
|
| 436 | - sql_alter("table spip_auteurs change login login VARCHAR(255) BINARY"); |
|
| 437 | - $trouver_table(''); |
|
| 438 | - $new_desc = $trouver_table("spip_auteurs"); |
|
| 439 | - spip_log("Apres conversion spip_auteurs : ".var_export($new_desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - foreach ($tables as $table){ |
|
| 443 | - if (time() >= _TIME_OUT) return; |
|
| 444 | - if ($desc = $trouver_table($table)){ |
|
| 445 | - $desc_collate = _sqlite_remplacements_definitions_table($desc['field']); |
|
| 446 | - if ($d=array_diff($desc['field'],$desc_collate)){ |
|
| 447 | - spip_log("Table $table COLLATE incorrects","maj"); |
|
| 448 | - |
|
| 449 | - // cas particulier spip_urls : |
|
| 450 | - // supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes) |
|
| 451 | - if ($table=='spip_urls'){ |
|
| 452 | - // par date DESC pour conserver les urls les plus recentes |
|
| 453 | - $data = sql_allfetsel("*","spip_urls",'','','date DESC'); |
|
| 454 | - $urls = array(); |
|
| 455 | - foreach ($data as $d){ |
|
| 456 | - $key = $d['id_parent']."::".strtolower($d['url']); |
|
| 457 | - if (!isset($urls[$key])) |
|
| 458 | - $urls[$key] = true; |
|
| 459 | - else { |
|
| 460 | - spip_log("Suppression doublon dans spip_urls avant conversion : ".serialize($d),"maj."._LOG_INFO_IMPORTANTE); |
|
| 461 | - sql_delete("spip_urls","id_parent=".sql_quote($d['id_parent'])." AND url=".sql_quote($d['url'])); |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - foreach ($desc['field'] as $field=>$type){ |
|
| 466 | - if ($desc['field'][$field]!==$desc_collate[$field]){ |
|
| 467 | - spip_log("Conversion COLLATE table $table","maj."._LOG_INFO_IMPORTANTE); |
|
| 468 | - sql_alter("table $table change $field $field ".$desc_collate[$field]); |
|
| 469 | - $trouver_table(''); |
|
| 470 | - $new_desc = $trouver_table($table); |
|
| 471 | - spip_log("Apres conversion $table : ".var_export($new_desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 472 | - continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - // forcer le vidage de cache |
|
| 480 | - $trouver_table(''); |
|
| 420 | + include_spip('base/dump'); |
|
| 421 | + $tables = base_lister_toutes_tables(); |
|
| 422 | + |
|
| 423 | + // rien a faire si base non sqlite |
|
| 424 | + if (strncmp($GLOBALS['connexions'][0]['type'],'sqlite',6)!==0) |
|
| 425 | + return; |
|
| 426 | + |
|
| 427 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 428 | + // forcer le vidage de cache |
|
| 429 | + $trouver_table(''); |
|
| 430 | + |
|
| 431 | + // cas particulier spip_auteurs : retablir le collate binary sur le login |
|
| 432 | + $desc = $trouver_table("spip_auteurs"); |
|
| 433 | + spip_log("spip_auteurs : ".var_export($desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 434 | + if (stripos($desc['field']['login'],"BINARY")===false){ |
|
| 435 | + spip_log("Retablir champ login BINARY sur table spip_auteurs","maj"); |
|
| 436 | + sql_alter("table spip_auteurs change login login VARCHAR(255) BINARY"); |
|
| 437 | + $trouver_table(''); |
|
| 438 | + $new_desc = $trouver_table("spip_auteurs"); |
|
| 439 | + spip_log("Apres conversion spip_auteurs : ".var_export($new_desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + foreach ($tables as $table){ |
|
| 443 | + if (time() >= _TIME_OUT) return; |
|
| 444 | + if ($desc = $trouver_table($table)){ |
|
| 445 | + $desc_collate = _sqlite_remplacements_definitions_table($desc['field']); |
|
| 446 | + if ($d=array_diff($desc['field'],$desc_collate)){ |
|
| 447 | + spip_log("Table $table COLLATE incorrects","maj"); |
|
| 448 | + |
|
| 449 | + // cas particulier spip_urls : |
|
| 450 | + // supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes) |
|
| 451 | + if ($table=='spip_urls'){ |
|
| 452 | + // par date DESC pour conserver les urls les plus recentes |
|
| 453 | + $data = sql_allfetsel("*","spip_urls",'','','date DESC'); |
|
| 454 | + $urls = array(); |
|
| 455 | + foreach ($data as $d){ |
|
| 456 | + $key = $d['id_parent']."::".strtolower($d['url']); |
|
| 457 | + if (!isset($urls[$key])) |
|
| 458 | + $urls[$key] = true; |
|
| 459 | + else { |
|
| 460 | + spip_log("Suppression doublon dans spip_urls avant conversion : ".serialize($d),"maj."._LOG_INFO_IMPORTANTE); |
|
| 461 | + sql_delete("spip_urls","id_parent=".sql_quote($d['id_parent'])." AND url=".sql_quote($d['url'])); |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + foreach ($desc['field'] as $field=>$type){ |
|
| 466 | + if ($desc['field'][$field]!==$desc_collate[$field]){ |
|
| 467 | + spip_log("Conversion COLLATE table $table","maj."._LOG_INFO_IMPORTANTE); |
|
| 468 | + sql_alter("table $table change $field $field ".$desc_collate[$field]); |
|
| 469 | + $trouver_table(''); |
|
| 470 | + $new_desc = $trouver_table($table); |
|
| 471 | + spip_log("Apres conversion $table : ".var_export($new_desc['field'],true),"maj."._LOG_INFO_IMPORTANTE); |
|
| 472 | + continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + // forcer le vidage de cache |
|
| 480 | + $trouver_table(''); |
|
| 481 | 481 | |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | |
| 485 | 485 | $GLOBALS['maj'][19236] = array( |
| 486 | - array('sql_updateq','spip_meta',array('impt'=>'oui'),"nom='version_installee'"), // version base principale |
|
| 487 | - array('sql_updateq','spip_meta',array('impt'=>'oui'),"nom LIKE '%_base_version'"), // version base plugins |
|
| 488 | - array('maj_collation_sqlite'), |
|
| 486 | + array('sql_updateq','spip_meta',array('impt'=>'oui'),"nom='version_installee'"), // version base principale |
|
| 487 | + array('sql_updateq','spip_meta',array('impt'=>'oui'),"nom LIKE '%_base_version'"), // version base plugins |
|
| 488 | + array('maj_collation_sqlite'), |
|
| 489 | 489 | ); |
| 490 | 490 | |
| 491 | 491 | $GLOBALS['maj'][19268] = array( |
| 492 | - array('supprimer_toutes_sessions'), |
|
| 492 | + array('supprimer_toutes_sessions'), |
|
| 493 | 493 | ); |
| 494 | 494 | |
| 495 | 495 | |
| 496 | 496 | function supprimer_toutes_sessions() { |
| 497 | - spip_log("supprimer sessions auteur"); |
|
| 498 | - $dir = opendir(_DIR_SESSIONS); |
|
| 499 | - while(($f = readdir($dir)) !== false) { |
|
| 500 | - spip_unlink(_DIR_SESSIONS . $f); |
|
| 501 | - if (time() >= _TIME_OUT) return; |
|
| 502 | - } |
|
| 497 | + spip_log("supprimer sessions auteur"); |
|
| 498 | + $dir = opendir(_DIR_SESSIONS); |
|
| 499 | + while(($f = readdir($dir)) !== false) { |
|
| 500 | + spip_unlink(_DIR_SESSIONS . $f); |
|
| 501 | + if (time() >= _TIME_OUT) return; |
|
| 502 | + } |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | ?> |
@@ -15,50 +15,50 @@ |
||
| 15 | 15 | |
| 16 | 16 | function maj_v013_dist($version_installee, $version_cible) |
| 17 | 17 | { |
| 18 | - if (upgrade_vers(1.3, $version_installee, $version_cible)) { |
|
| 19 | - // Modifier la syndication (pour liste de sites) |
|
| 20 | - spip_query("ALTER TABLE spip_syndic ADD syndication VARCHAR(3) NOT NULL"); |
|
| 21 | - spip_query("ALTER TABLE spip_syndic ADD statut VARCHAR(10) NOT NULL"); |
|
| 22 | - spip_query("ALTER TABLE spip_syndic ADD date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 23 | - spip_query("UPDATE spip_syndic SET syndication='oui', statut='publie', date=NOW()"); |
|
| 18 | + if (upgrade_vers(1.3, $version_installee, $version_cible)) { |
|
| 19 | + // Modifier la syndication (pour liste de sites) |
|
| 20 | + spip_query("ALTER TABLE spip_syndic ADD syndication VARCHAR(3) NOT NULL"); |
|
| 21 | + spip_query("ALTER TABLE spip_syndic ADD statut VARCHAR(10) NOT NULL"); |
|
| 22 | + spip_query("ALTER TABLE spip_syndic ADD date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 23 | + spip_query("UPDATE spip_syndic SET syndication='oui', statut='publie', date=NOW()"); |
|
| 24 | 24 | |
| 25 | - // Statut pour articles syndication, pour pouvoir desactiver un article |
|
| 26 | - spip_query("ALTER TABLE spip_syndic_articles ADD statut VARCHAR(10) NOT NULL"); |
|
| 27 | - spip_query("UPDATE spip_syndic_articles SET statut='publie'"); |
|
| 28 | - maj_version (1.3); |
|
| 29 | - } |
|
| 25 | + // Statut pour articles syndication, pour pouvoir desactiver un article |
|
| 26 | + spip_query("ALTER TABLE spip_syndic_articles ADD statut VARCHAR(10) NOT NULL"); |
|
| 27 | + spip_query("UPDATE spip_syndic_articles SET statut='publie'"); |
|
| 28 | + maj_version (1.3); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - if (upgrade_vers(1.301, $version_installee, $version_cible)) { |
|
| 32 | - spip_query("ALTER TABLE spip_forum ADD id_syndic bigint(21) DEFAULT '0' NOT NULL"); |
|
| 33 | - maj_version (1.301); |
|
| 34 | - } |
|
| 31 | + if (upgrade_vers(1.301, $version_installee, $version_cible)) { |
|
| 32 | + spip_query("ALTER TABLE spip_forum ADD id_syndic bigint(21) DEFAULT '0' NOT NULL"); |
|
| 33 | + maj_version (1.301); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - if (upgrade_vers(1.302, $version_installee, $version_cible)) { |
|
| 37 | - # spip_query("ALTER TABLE spip_forum_cache DROP PRIMARY KEY"); |
|
| 38 | - # spip_query("ALTER TABLE spip_forum_cache DROP INDEX fichier"); |
|
| 39 | - # spip_query("ALTER TABLE spip_forum_cache ADD PRIMARY KEY (fichier, id_forum, id_article, id_rubrique, id_breve, id_syndic)"); |
|
| 40 | - spip_query("ALTER TABLE spip_forum ADD INDEX id_syndic (id_syndic)"); |
|
| 41 | - maj_version (1.302); |
|
| 42 | - } |
|
| 36 | + if (upgrade_vers(1.302, $version_installee, $version_cible)) { |
|
| 37 | + # spip_query("ALTER TABLE spip_forum_cache DROP PRIMARY KEY"); |
|
| 38 | + # spip_query("ALTER TABLE spip_forum_cache DROP INDEX fichier"); |
|
| 39 | + # spip_query("ALTER TABLE spip_forum_cache ADD PRIMARY KEY (fichier, id_forum, id_article, id_rubrique, id_breve, id_syndic)"); |
|
| 40 | + spip_query("ALTER TABLE spip_forum ADD INDEX id_syndic (id_syndic)"); |
|
| 41 | + maj_version (1.302); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if (upgrade_vers(1.303, $version_installee, $version_cible)) { |
|
| 45 | - spip_query("ALTER TABLE spip_rubriques ADD date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 46 | - spip_query("ALTER TABLE spip_syndic ADD date_syndic datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 47 | - spip_query("UPDATE spip_syndic SET date_syndic=date"); |
|
| 48 | - maj_version (1.303); |
|
| 49 | - } |
|
| 44 | + if (upgrade_vers(1.303, $version_installee, $version_cible)) { |
|
| 45 | + spip_query("ALTER TABLE spip_rubriques ADD date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 46 | + spip_query("ALTER TABLE spip_syndic ADD date_syndic datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 47 | + spip_query("UPDATE spip_syndic SET date_syndic=date"); |
|
| 48 | + maj_version (1.303); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if (upgrade_vers(1.306, $version_installee, $version_cible)) { |
|
| 52 | - spip_query("DROP TABLE spip_index_syndic_articles"); |
|
| 53 | - spip_query("ALTER TABLE spip_syndic ADD date_index datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 54 | - spip_query("ALTER TABLE spip_syndic ADD INDEX date_index (date_index)"); |
|
| 55 | - maj_version (1.306); |
|
| 56 | - } |
|
| 51 | + if (upgrade_vers(1.306, $version_installee, $version_cible)) { |
|
| 52 | + spip_query("DROP TABLE spip_index_syndic_articles"); |
|
| 53 | + spip_query("ALTER TABLE spip_syndic ADD date_index datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 54 | + spip_query("ALTER TABLE spip_syndic ADD INDEX date_index (date_index)"); |
|
| 55 | + maj_version (1.306); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if (upgrade_vers(1.307, $version_installee, $version_cible)) { |
|
| 59 | - spip_query("ALTER TABLE spip_syndic_articles ADD descriptif blob NOT NULL"); |
|
| 60 | - maj_version (1.307); |
|
| 61 | - } |
|
| 58 | + if (upgrade_vers(1.307, $version_installee, $version_cible)) { |
|
| 59 | + spip_query("ALTER TABLE spip_syndic_articles ADD descriptif blob NOT NULL"); |
|
| 60 | + maj_version (1.307); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -14,178 +14,178 @@ |
||
| 14 | 14 | |
| 15 | 15 | function maj_v017_dist($version_installee, $version_cible) |
| 16 | 16 | { |
| 17 | - if (upgrade_vers(1.702, $version_installee, $version_cible)) { |
|
| 18 | - spip_query("ALTER TABLE spip_articles ADD extra longblob NULL"); |
|
| 19 | - spip_query("ALTER TABLE spip_auteurs ADD extra longblob NULL"); |
|
| 20 | - spip_query("ALTER TABLE spip_breves ADD extra longblob NULL"); |
|
| 21 | - spip_query("ALTER TABLE spip_rubriques ADD extra longblob NULL"); |
|
| 22 | - spip_query("ALTER TABLE spip_mots ADD extra longblob NULL"); |
|
| 23 | - |
|
| 24 | - // recuperer les eventuels 'supplement' installes en 1.701 |
|
| 25 | - if ($version_installee == 1.701) { |
|
| 26 | - spip_query("UPDATE spip_articles SET extra = supplement"); |
|
| 27 | - spip_query("ALTER TABLE spip_articles DROP supplement"); |
|
| 28 | - spip_query("UPDATE spip_auteurs SET extra = supplement"); |
|
| 29 | - spip_query("ALTER TABLE spip_auteurs DROP supplement"); |
|
| 30 | - spip_query("UPDATE spip_breves SET extra = supplement"); |
|
| 31 | - spip_query("ALTER TABLE spip_breves DROP supplement"); |
|
| 32 | - spip_query("UPDATE spip_rubriques SET extra = supplement"); |
|
| 33 | - spip_query("ALTER TABLE spip_rubriques DROP supplement"); |
|
| 34 | - spip_query("UPDATE spip_mots SET extra = supplement"); |
|
| 35 | - spip_query("ALTER TABLE spip_mots DROP supplement"); |
|
| 36 | - } |
|
| 17 | + if (upgrade_vers(1.702, $version_installee, $version_cible)) { |
|
| 18 | + spip_query("ALTER TABLE spip_articles ADD extra longblob NULL"); |
|
| 19 | + spip_query("ALTER TABLE spip_auteurs ADD extra longblob NULL"); |
|
| 20 | + spip_query("ALTER TABLE spip_breves ADD extra longblob NULL"); |
|
| 21 | + spip_query("ALTER TABLE spip_rubriques ADD extra longblob NULL"); |
|
| 22 | + spip_query("ALTER TABLE spip_mots ADD extra longblob NULL"); |
|
| 23 | + |
|
| 24 | + // recuperer les eventuels 'supplement' installes en 1.701 |
|
| 25 | + if ($version_installee == 1.701) { |
|
| 26 | + spip_query("UPDATE spip_articles SET extra = supplement"); |
|
| 27 | + spip_query("ALTER TABLE spip_articles DROP supplement"); |
|
| 28 | + spip_query("UPDATE spip_auteurs SET extra = supplement"); |
|
| 29 | + spip_query("ALTER TABLE spip_auteurs DROP supplement"); |
|
| 30 | + spip_query("UPDATE spip_breves SET extra = supplement"); |
|
| 31 | + spip_query("ALTER TABLE spip_breves DROP supplement"); |
|
| 32 | + spip_query("UPDATE spip_rubriques SET extra = supplement"); |
|
| 33 | + spip_query("ALTER TABLE spip_rubriques DROP supplement"); |
|
| 34 | + spip_query("UPDATE spip_mots SET extra = supplement"); |
|
| 35 | + spip_query("ALTER TABLE spip_mots DROP supplement"); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $u = spip_query("SELECT extra FROM spip_articles"); |
|
| 39 | - $u&= spip_query("SELECT extra FROM spip_auteurs"); |
|
| 40 | - $u&= spip_query("SELECT extra FROM spip_breves"); |
|
| 41 | - $u&= spip_query("SELECT extra FROM spip_rubriques"); |
|
| 42 | - $u&= spip_query("SELECT extra FROM spip_mots"); |
|
| 43 | - maj_version (1.702,$u); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (upgrade_vers(1.703, $version_installee, $version_cible)) { |
|
| 47 | - spip_query("ALTER TABLE spip_articles ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 48 | - spip_query("ALTER TABLE spip_rubriques ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 49 | - maj_version (1.703); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - if (upgrade_vers(1.704, $version_installee, $version_cible)) { |
|
| 53 | - spip_query("ALTER TABLE spip_articles ADD INDEX lang (lang)"); |
|
| 54 | - spip_query("ALTER TABLE spip_auteurs ADD INDEX lang (lang)"); |
|
| 55 | - spip_query("ALTER TABLE spip_rubriques ADD INDEX lang (lang)"); |
|
| 56 | - maj_version (1.704); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (upgrade_vers(1.705, $version_installee, $version_cible)) { |
|
| 60 | - spip_query("ALTER TABLE spip_articles ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 61 | - spip_query("ALTER TABLE spip_rubriques ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 62 | - maj_version (1.705); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (upgrade_vers(1.707, $version_installee, $version_cible)) { |
|
| 66 | - spip_query("UPDATE spip_articles SET langue_choisie='oui' WHERE MID(lang,1,1) != '.' AND lang != ''"); |
|
| 67 | - spip_query("UPDATE spip_articles SET lang=MID(lang,2,8) WHERE langue_choisie = 'non'"); |
|
| 68 | - spip_query("UPDATE spip_rubriques SET langue_choisie='oui' WHERE MID(lang,1,1) != '.' AND lang != ''"); |
|
| 69 | - spip_query("UPDATE spip_rubriques SET lang=MID(lang,2,8) WHERE langue_choisie = 'non'"); |
|
| 70 | - maj_version (1.707); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - if (upgrade_vers(1.708, $version_installee, $version_cible)) { |
|
| 74 | - spip_query("ALTER TABLE spip_breves ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 75 | - spip_query("ALTER TABLE spip_breves ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 76 | - maj_version (1.708); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - if (upgrade_vers(1.709, $version_installee, $version_cible)) { |
|
| 80 | - spip_query("ALTER TABLE spip_articles ADD id_trad bigint(21) DEFAULT '0' NOT NULL"); |
|
| 81 | - spip_query("ALTER TABLE spip_articles ADD INDEX id_trad (id_trad)"); |
|
| 82 | - maj_version (1.709); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (upgrade_vers(1.717, $version_installee, $version_cible)) { |
|
| 86 | - spip_query("ALTER TABLE spip_articles ADD INDEX date_modif (date_modif)"); |
|
| 87 | - maj_version (1.717); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if (upgrade_vers(1.718, $version_installee, $version_cible)) { |
|
| 91 | - spip_query("ALTER TABLE spip_referers DROP domaine"); |
|
| 92 | - spip_query("ALTER TABLE spip_referers_articles DROP domaine"); |
|
| 93 | - spip_query("ALTER TABLE spip_referers_temp DROP domaine"); |
|
| 94 | - maj_version (1.718); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (upgrade_vers(1.722, $version_installee, $version_cible)) { |
|
| 98 | - spip_query("ALTER TABLE spip_articles ADD nom_site tinytext NOT NULL"); |
|
| 99 | - spip_query("ALTER TABLE spip_articles ADD url_site VARCHAR(255) NOT NULL"); |
|
| 100 | - spip_query("ALTER TABLE spip_articles ADD INDEX url_site (url_site)"); |
|
| 101 | - if ($version_installee >= 1.720) { |
|
| 102 | - spip_query("UPDATE spip_articles SET url_site=url_ref"); |
|
| 103 | - spip_query("ALTER TABLE spip_articles DROP INDEX url_ref"); |
|
| 104 | - spip_query("ALTER TABLE spip_articles DROP url_ref"); |
|
| 105 | - } |
|
| 106 | - maj_version (1.722); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if (upgrade_vers(1.723, $version_installee, $version_cible)) { |
|
| 110 | - if ($version_installee == 1.722) { |
|
| 111 | - spip_query("ALTER TABLE spip_articles MODIFY url_site VARCHAR(255) NOT NULL"); |
|
| 112 | - spip_query("ALTER TABLE spip_articles DROP INDEX url_site;"); |
|
| 113 | - spip_query("ALTER TABLE spip_articles ADD INDEX url_site (url_site);"); |
|
| 114 | - } |
|
| 115 | - maj_version (1.723); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if (upgrade_vers(1.724, $version_installee, $version_cible)) { |
|
| 119 | - spip_query("ALTER TABLE spip_messages ADD date_fin datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 120 | - maj_version (1.724); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - if (upgrade_vers(1.726, $version_installee, $version_cible)) { |
|
| 124 | - spip_query("ALTER TABLE spip_auteurs ADD low_sec tinytext NOT NULL"); |
|
| 125 | - maj_version (1.726); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if (upgrade_vers(1.727, $version_installee, $version_cible)) { |
|
| 129 | - // occitans : oci_xx -> oc_xx |
|
| 130 | - spip_query("UPDATE spip_auteurs SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 131 | - spip_query("UPDATE spip_rubriques SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 132 | - spip_query("UPDATE spip_articles SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 133 | - spip_query("UPDATE spip_breves SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 134 | - maj_version (1.727); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // Ici version 1.7 officielle |
|
| 138 | - if (upgrade_vers(1.728, $version_installee, $version_cible)) { |
|
| 139 | - spip_query("ALTER TABLE spip_articles ADD id_version int unsigned DEFAULT '0' NOT NULL"); |
|
| 140 | - maj_version (1.728); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if (upgrade_vers(1.730, $version_installee, $version_cible)) { |
|
| 144 | - spip_query("ALTER TABLE spip_articles ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 145 | - spip_query("ALTER TABLE spip_articles ADD INDEX idx (idx)"); |
|
| 146 | - spip_query("ALTER TABLE spip_auteurs ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 147 | - spip_query("ALTER TABLE spip_auteurs ADD INDEX idx (idx)"); |
|
| 148 | - spip_query("ALTER TABLE spip_breves ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 149 | - spip_query("ALTER TABLE spip_breves ADD INDEX idx (idx)"); |
|
| 150 | - spip_query("ALTER TABLE spip_mots ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 151 | - spip_query("ALTER TABLE spip_mots ADD INDEX idx (idx)"); |
|
| 152 | - spip_query("ALTER TABLE spip_rubriques ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 153 | - spip_query("ALTER TABLE spip_rubriques ADD INDEX idx (idx)"); |
|
| 154 | - spip_query("ALTER TABLE spip_syndic ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 155 | - spip_query("ALTER TABLE spip_syndic ADD INDEX idx (idx)"); |
|
| 156 | - spip_query("ALTER TABLE spip_forum ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 157 | - spip_query("ALTER TABLE spip_forum ADD INDEX idx (idx)"); |
|
| 158 | - spip_query("ALTER TABLE spip_signatures ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 159 | - spip_query("ALTER TABLE spip_signatures ADD INDEX idx (idx)"); |
|
| 160 | - maj_version (1.730); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (upgrade_vers(1.731, $version_installee, $version_cible)) { |
|
| 164 | - spip_query("UPDATE spip_articles SET idx='1' where lang IN ('de','vi')"); |
|
| 165 | - spip_query("UPDATE spip_rubriques SET idx='1' where lang IN ('de','vi')"); |
|
| 166 | - spip_query("UPDATE spip_breves SET idx='1' where lang IN ('de','vi')"); |
|
| 167 | - spip_query("UPDATE spip_auteurs SET idx='1' where lang IN ('de','vi')"); |
|
| 168 | - maj_version (1.731); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if (upgrade_vers(1.732, $version_installee, $version_cible)) { // en correction d'un vieux truc qui avait fait sauter le champ inclus sur les bases version 1.415 |
|
| 172 | - spip_query("ALTER TABLE spip_documents ADD inclus VARCHAR(3) DEFAULT 'non'"); |
|
| 173 | - maj_version (1.732); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - if (upgrade_vers(1.733, $version_installee, $version_cible)) { |
|
| 177 | - // spip_query("ALTER TABLE spip_articles ADD id_version int unsigned DEFAULT '0' NOT NULL"); |
|
| 178 | - spip_query("DROP TABLE spip_versions"); |
|
| 179 | - spip_query("DROP TABLE spip_versions_fragments"); |
|
| 180 | - creer_base(); |
|
| 181 | - maj_version(1.733); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - #if ($version_installee < 1.734) { |
|
| 185 | - # // integrer nouvelles tables auxiliaires du compilateur ESJ |
|
| 186 | - # creer_base(); |
|
| 187 | - # maj_version(1.734); |
|
| 188 | - #} |
|
| 38 | + $u = spip_query("SELECT extra FROM spip_articles"); |
|
| 39 | + $u&= spip_query("SELECT extra FROM spip_auteurs"); |
|
| 40 | + $u&= spip_query("SELECT extra FROM spip_breves"); |
|
| 41 | + $u&= spip_query("SELECT extra FROM spip_rubriques"); |
|
| 42 | + $u&= spip_query("SELECT extra FROM spip_mots"); |
|
| 43 | + maj_version (1.702,$u); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (upgrade_vers(1.703, $version_installee, $version_cible)) { |
|
| 47 | + spip_query("ALTER TABLE spip_articles ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 48 | + spip_query("ALTER TABLE spip_rubriques ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 49 | + maj_version (1.703); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + if (upgrade_vers(1.704, $version_installee, $version_cible)) { |
|
| 53 | + spip_query("ALTER TABLE spip_articles ADD INDEX lang (lang)"); |
|
| 54 | + spip_query("ALTER TABLE spip_auteurs ADD INDEX lang (lang)"); |
|
| 55 | + spip_query("ALTER TABLE spip_rubriques ADD INDEX lang (lang)"); |
|
| 56 | + maj_version (1.704); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + if (upgrade_vers(1.705, $version_installee, $version_cible)) { |
|
| 60 | + spip_query("ALTER TABLE spip_articles ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 61 | + spip_query("ALTER TABLE spip_rubriques ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 62 | + maj_version (1.705); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (upgrade_vers(1.707, $version_installee, $version_cible)) { |
|
| 66 | + spip_query("UPDATE spip_articles SET langue_choisie='oui' WHERE MID(lang,1,1) != '.' AND lang != ''"); |
|
| 67 | + spip_query("UPDATE spip_articles SET lang=MID(lang,2,8) WHERE langue_choisie = 'non'"); |
|
| 68 | + spip_query("UPDATE spip_rubriques SET langue_choisie='oui' WHERE MID(lang,1,1) != '.' AND lang != ''"); |
|
| 69 | + spip_query("UPDATE spip_rubriques SET lang=MID(lang,2,8) WHERE langue_choisie = 'non'"); |
|
| 70 | + maj_version (1.707); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + if (upgrade_vers(1.708, $version_installee, $version_cible)) { |
|
| 74 | + spip_query("ALTER TABLE spip_breves ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 75 | + spip_query("ALTER TABLE spip_breves ADD langue_choisie VARCHAR(3) DEFAULT 'non'"); |
|
| 76 | + maj_version (1.708); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + if (upgrade_vers(1.709, $version_installee, $version_cible)) { |
|
| 80 | + spip_query("ALTER TABLE spip_articles ADD id_trad bigint(21) DEFAULT '0' NOT NULL"); |
|
| 81 | + spip_query("ALTER TABLE spip_articles ADD INDEX id_trad (id_trad)"); |
|
| 82 | + maj_version (1.709); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (upgrade_vers(1.717, $version_installee, $version_cible)) { |
|
| 86 | + spip_query("ALTER TABLE spip_articles ADD INDEX date_modif (date_modif)"); |
|
| 87 | + maj_version (1.717); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if (upgrade_vers(1.718, $version_installee, $version_cible)) { |
|
| 91 | + spip_query("ALTER TABLE spip_referers DROP domaine"); |
|
| 92 | + spip_query("ALTER TABLE spip_referers_articles DROP domaine"); |
|
| 93 | + spip_query("ALTER TABLE spip_referers_temp DROP domaine"); |
|
| 94 | + maj_version (1.718); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (upgrade_vers(1.722, $version_installee, $version_cible)) { |
|
| 98 | + spip_query("ALTER TABLE spip_articles ADD nom_site tinytext NOT NULL"); |
|
| 99 | + spip_query("ALTER TABLE spip_articles ADD url_site VARCHAR(255) NOT NULL"); |
|
| 100 | + spip_query("ALTER TABLE spip_articles ADD INDEX url_site (url_site)"); |
|
| 101 | + if ($version_installee >= 1.720) { |
|
| 102 | + spip_query("UPDATE spip_articles SET url_site=url_ref"); |
|
| 103 | + spip_query("ALTER TABLE spip_articles DROP INDEX url_ref"); |
|
| 104 | + spip_query("ALTER TABLE spip_articles DROP url_ref"); |
|
| 105 | + } |
|
| 106 | + maj_version (1.722); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if (upgrade_vers(1.723, $version_installee, $version_cible)) { |
|
| 110 | + if ($version_installee == 1.722) { |
|
| 111 | + spip_query("ALTER TABLE spip_articles MODIFY url_site VARCHAR(255) NOT NULL"); |
|
| 112 | + spip_query("ALTER TABLE spip_articles DROP INDEX url_site;"); |
|
| 113 | + spip_query("ALTER TABLE spip_articles ADD INDEX url_site (url_site);"); |
|
| 114 | + } |
|
| 115 | + maj_version (1.723); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if (upgrade_vers(1.724, $version_installee, $version_cible)) { |
|
| 119 | + spip_query("ALTER TABLE spip_messages ADD date_fin datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
|
| 120 | + maj_version (1.724); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + if (upgrade_vers(1.726, $version_installee, $version_cible)) { |
|
| 124 | + spip_query("ALTER TABLE spip_auteurs ADD low_sec tinytext NOT NULL"); |
|
| 125 | + maj_version (1.726); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if (upgrade_vers(1.727, $version_installee, $version_cible)) { |
|
| 129 | + // occitans : oci_xx -> oc_xx |
|
| 130 | + spip_query("UPDATE spip_auteurs SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 131 | + spip_query("UPDATE spip_rubriques SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 132 | + spip_query("UPDATE spip_articles SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 133 | + spip_query("UPDATE spip_breves SET lang=REPLACE(lang,'oci_', 'oc_') WHERE lang LIKE 'oci_%'"); |
|
| 134 | + maj_version (1.727); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // Ici version 1.7 officielle |
|
| 138 | + if (upgrade_vers(1.728, $version_installee, $version_cible)) { |
|
| 139 | + spip_query("ALTER TABLE spip_articles ADD id_version int unsigned DEFAULT '0' NOT NULL"); |
|
| 140 | + maj_version (1.728); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if (upgrade_vers(1.730, $version_installee, $version_cible)) { |
|
| 144 | + spip_query("ALTER TABLE spip_articles ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 145 | + spip_query("ALTER TABLE spip_articles ADD INDEX idx (idx)"); |
|
| 146 | + spip_query("ALTER TABLE spip_auteurs ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 147 | + spip_query("ALTER TABLE spip_auteurs ADD INDEX idx (idx)"); |
|
| 148 | + spip_query("ALTER TABLE spip_breves ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 149 | + spip_query("ALTER TABLE spip_breves ADD INDEX idx (idx)"); |
|
| 150 | + spip_query("ALTER TABLE spip_mots ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 151 | + spip_query("ALTER TABLE spip_mots ADD INDEX idx (idx)"); |
|
| 152 | + spip_query("ALTER TABLE spip_rubriques ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 153 | + spip_query("ALTER TABLE spip_rubriques ADD INDEX idx (idx)"); |
|
| 154 | + spip_query("ALTER TABLE spip_syndic ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 155 | + spip_query("ALTER TABLE spip_syndic ADD INDEX idx (idx)"); |
|
| 156 | + spip_query("ALTER TABLE spip_forum ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 157 | + spip_query("ALTER TABLE spip_forum ADD INDEX idx (idx)"); |
|
| 158 | + spip_query("ALTER TABLE spip_signatures ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL"); |
|
| 159 | + spip_query("ALTER TABLE spip_signatures ADD INDEX idx (idx)"); |
|
| 160 | + maj_version (1.730); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (upgrade_vers(1.731, $version_installee, $version_cible)) { |
|
| 164 | + spip_query("UPDATE spip_articles SET idx='1' where lang IN ('de','vi')"); |
|
| 165 | + spip_query("UPDATE spip_rubriques SET idx='1' where lang IN ('de','vi')"); |
|
| 166 | + spip_query("UPDATE spip_breves SET idx='1' where lang IN ('de','vi')"); |
|
| 167 | + spip_query("UPDATE spip_auteurs SET idx='1' where lang IN ('de','vi')"); |
|
| 168 | + maj_version (1.731); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if (upgrade_vers(1.732, $version_installee, $version_cible)) { // en correction d'un vieux truc qui avait fait sauter le champ inclus sur les bases version 1.415 |
|
| 172 | + spip_query("ALTER TABLE spip_documents ADD inclus VARCHAR(3) DEFAULT 'non'"); |
|
| 173 | + maj_version (1.732); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + if (upgrade_vers(1.733, $version_installee, $version_cible)) { |
|
| 177 | + // spip_query("ALTER TABLE spip_articles ADD id_version int unsigned DEFAULT '0' NOT NULL"); |
|
| 178 | + spip_query("DROP TABLE spip_versions"); |
|
| 179 | + spip_query("DROP TABLE spip_versions_fragments"); |
|
| 180 | + creer_base(); |
|
| 181 | + maj_version(1.733); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + #if ($version_installee < 1.734) { |
|
| 185 | + # // integrer nouvelles tables auxiliaires du compilateur ESJ |
|
| 186 | + # creer_base(); |
|
| 187 | + # maj_version(1.734); |
|
| 188 | + #} |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -15,39 +15,39 @@ |
||
| 15 | 15 | function maj_v016_dist($version_installee, $version_cible) |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - if (upgrade_vers(1.600, $version_installee, $version_cible)) { |
|
| 18 | + if (upgrade_vers(1.600, $version_installee, $version_cible)) { |
|
| 19 | 19 | #8/08/07 plus d'indexation dans le core |
| 20 | 20 | # include_spip('inc/indexation'); |
| 21 | 21 | # purger_index(); |
| 22 | 22 | # creer_liste_indexation(); |
| 23 | - maj_version (1.600); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - if (upgrade_vers(1.601, $version_installee, $version_cible)) { |
|
| 27 | - spip_query("ALTER TABLE spip_forum ADD INDEX id_syndic (id_syndic)"); |
|
| 28 | - maj_version (1.601); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - if (upgrade_vers(1.603, $version_installee, $version_cible)) { |
|
| 32 | - // supprimer les fichiers deplaces |
|
| 33 | - spip_unlink('inc_meta_cache.php'); |
|
| 34 | - spip_unlink('inc_meta_cache.php3'); |
|
| 35 | - spip_unlink('data/engines-list.ini'); |
|
| 36 | - maj_version (1.603); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - if (upgrade_vers(1.604, $version_installee, $version_cible)) { |
|
| 40 | - spip_query("ALTER TABLE spip_auteurs ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 41 | - $u = spip_query("SELECT * FROM spip_auteurs WHERE prefs LIKE '%spip_lang%'"); |
|
| 42 | - while ($row = sql_fetch($u)) { |
|
| 43 | - $prefs = unserialize($row['prefs']); |
|
| 44 | - $l = $prefs['spip_lang']; |
|
| 45 | - unset ($prefs['spip_lang']); |
|
| 46 | - spip_query("UPDATE spip_auteurs SET lang=" . _q($l) . ", prefs='".addslashes(serialize($prefs))."' WHERE id_auteur=".$row['id_auteur']); |
|
| 47 | - } |
|
| 48 | - $u = spip_query("SELECT lang FROM spip_auteurs"); |
|
| 49 | - maj_version (1.604, $u); |
|
| 50 | - } |
|
| 23 | + maj_version (1.600); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + if (upgrade_vers(1.601, $version_installee, $version_cible)) { |
|
| 27 | + spip_query("ALTER TABLE spip_forum ADD INDEX id_syndic (id_syndic)"); |
|
| 28 | + maj_version (1.601); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + if (upgrade_vers(1.603, $version_installee, $version_cible)) { |
|
| 32 | + // supprimer les fichiers deplaces |
|
| 33 | + spip_unlink('inc_meta_cache.php'); |
|
| 34 | + spip_unlink('inc_meta_cache.php3'); |
|
| 35 | + spip_unlink('data/engines-list.ini'); |
|
| 36 | + maj_version (1.603); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + if (upgrade_vers(1.604, $version_installee, $version_cible)) { |
|
| 40 | + spip_query("ALTER TABLE spip_auteurs ADD lang VARCHAR(10) DEFAULT '' NOT NULL"); |
|
| 41 | + $u = spip_query("SELECT * FROM spip_auteurs WHERE prefs LIKE '%spip_lang%'"); |
|
| 42 | + while ($row = sql_fetch($u)) { |
|
| 43 | + $prefs = unserialize($row['prefs']); |
|
| 44 | + $l = $prefs['spip_lang']; |
|
| 45 | + unset ($prefs['spip_lang']); |
|
| 46 | + spip_query("UPDATE spip_auteurs SET lang=" . _q($l) . ", prefs='".addslashes(serialize($prefs))."' WHERE id_auteur=".$row['id_auteur']); |
|
| 47 | + } |
|
| 48 | + $u = spip_query("SELECT lang FROM spip_auteurs"); |
|
| 49 | + maj_version (1.604, $u); |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -16,11 +16,11 @@ |
||
| 16 | 16 | function maj_v011_dist($version_installee, $version_cible) |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - if (upgrade_vers(1.1, $version_installee, $version_cible)) { |
|
| 20 | - spip_query("DROP TABLE spip_petition"); |
|
| 21 | - spip_query("DROP TABLE spip_signatures_petition"); |
|
| 22 | - maj_version (1.1); |
|
| 23 | - } |
|
| 19 | + if (upgrade_vers(1.1, $version_installee, $version_cible)) { |
|
| 20 | + spip_query("DROP TABLE spip_petition"); |
|
| 21 | + spip_query("DROP TABLE spip_signatures_petition"); |
|
| 22 | + maj_version (1.1); |
|
| 23 | + } |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |