3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 /*--------------------------------------------------------------------- */
16 /* Gestion des MAJ par tableau indexe par le numero SVN du chgt */
17 /*--------------------------------------------------------------------- */
19 // Type cls et sty pour LaTeX
20 $GLOBALS['maj'][10990] = array(array('upgrade_types_documents'));
22 // Type 3gp: http://www.faqs.org/rfcs/rfc3839.html
23 // Aller plus vite pour les vieilles versions en redeclarant une seule les doc
24 unset($GLOBALS['maj'][10990]);
25 $GLOBALS['maj'][11042] = array(array('upgrade_types_documents'));
28 // Un bug permettait au champ 'upload' d'etre vide, provoquant
29 // l'impossibilite de telecharger une image
30 // http://trac.rezo.net/trac/spip/ticket/1238
31 $GLOBALS['maj'][11171] = array(
32 array('spip_query', "UPDATE spip_types_documents SET upload='oui' WHERE upload IS NULL OR upload!='non'")
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);
41 $GLOBALS['maj'][11268] = array(array('maj_11268'));
44 function maj_11276 () {
45 include_spip('maj/v019');
48 $GLOBALS['maj'][11276] = array(array('maj_11276'));
50 // reparer les referers d'article, qui sont vides depuis [10572]
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']));
56 spip_query('UPDATE spip_referers_articles
57 SET referer='.sql_quote($k['referer']).'
58 WHERE referer_md5='.sql_quote($t['referer_md5'])
59 ." AND (referer='' OR referer IS NULL)"
64 $GLOBALS['maj'][11388] = array(array('maj_11388'));
66 // reparer spip_mots.type = titre du groupe
67 function maj_11431 () {
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");
71 // selection des mots cles dont le type est different du groupe
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
78 while ($r = sql_fetch($res)){
79 sql_updateq('spip_mots', array('type'=>$r['type']), 'id_mot='.sql_quote($r['id_mot']));
83 $GLOBALS['maj'][11431] = array(array('maj_11431'));
85 // reparer spip_types_documents.id_type
86 // qui est parfois encore present
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)');
96 $GLOBALS['maj'][11778] = array(array('maj_11778'));
98 // Optimisation des forums
99 function maj_11790 () {
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)');
106 $GLOBALS['maj'][11790] = array(array('maj_11790'));
108 $GLOBALS['maj'][11794] = array(); // ajout de spip_documents_forum
112 $GLOBALS['maj'][11961] = array(
113 array('sql_alter',"TABLE spip_groupes_mots CHANGE `tables` tables_liees text DEFAULT '' NOT NULL AFTER obligatoire"), // si tables a ete cree on le renomme
114 array('sql_alter',"TABLE spip_groupes_mots ADD tables_liees text DEFAULT '' NOT NULL AFTER obligatoire"), // sinon on l'ajoute
115 array('sql_update','spip_groupes_mots',array('tables_liees'=>"''"),"articles REGEXP '.*'"), // si le champ articles est encore la, on reinit la conversion
116 array('sql_update','spip_groupes_mots',array('tables_liees'=>"concat(tables_liees,'articles,')"),"articles='oui'"), // sinon ces 4 requetes ne feront rien
117 array('sql_update','spip_groupes_mots',array('tables_liees'=>"concat(tables_liees,'breves,')"),"breves='oui'"),
118 array('sql_update','spip_groupes_mots',array('tables_liees'=>"concat(tables_liees,'rubriques,')"),"rubriques='oui'"),
119 array('sql_update','spip_groupes_mots',array('tables_liees'=>"concat(tables_liees,'syndic,')"),"syndic='oui'"),
124 // Reunir en une seule table les liens de documents
125 // spip_documents_articles et spip_documents_forum
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);
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)) {
138 while ($t = sql_fetch($s)) {
139 // transformer id_xx=N en (id_objet=N, objet=xx)
140 $t['id_objet'] = $t["id_$l"];
145 if (count($tampon)>10000) {
146 sql_insertq_multi('spip_documents_liens',$tampon);
150 if (count($tampon)) {
151 sql_insertq_multi('spip_documents_liens', $tampon);
157 $GLOBALS['maj'][12008] = array(
158 //array('sql_drop_table',"spip_documents_liens"), // tant pis pour ceux qui ont joue a 11974
159 array('sql_alter',"TABLE spip_documents_liens DROP PRIMARY KEY"),
160 array('sql_alter',"TABLE spip_documents_liens ADD id_objet bigint(21) DEFAULT '0' NOT NULL AFTER id_document"),
161 array('sql_alter',"TABLE spip_documents_liens ADD objet VARCHAR (25) DEFAULT '' NOT NULL AFTER id_objet"),
162 array('sql_update','spip_documents_liens',array('id_objet'=>"id_article",'objet'=>"'article'"),"id_article IS NOT NULL AND id_article>0"),
163 array('sql_update','spip_documents_liens',array('id_objet'=>"id_rubrique",'objet'=>"'rubrique'"),"id_rubrique IS NOT NULL AND id_rubrique>0"),
164 array('sql_update','spip_documents_liens',array('id_objet'=>"id_breve",'objet'=>"'breve'"),"id_breve IS NOT NULL AND id_breve>0"),
165 array('sql_update','spip_documents_liens',array('id_objet'=>"id_auteur",'objet'=>"'auteur'"),"id_auteur IS NOT NULL AND id_auteur>0"),
166 array('sql_update','spip_documents_liens',array('id_objet'=>"id_forum",'objet'=>"'forum'"),"id_forum IS NOT NULL AND id_forum>0"),
167 array('sql_alter',"TABLE spip_documents_liens ADD PRIMARY KEY (id_document,id_objet,objet)"),
168 array('sql_alter',"TABLE spip_documents_liens DROP id_article"),
169 array('sql_alter',"TABLE spip_documents_liens DROP id_rubrique"),
170 array('sql_alter',"TABLE spip_documents_liens DROP id_breve"),
171 array('sql_alter',"TABLE spip_documents_liens DROP id_auteur"),
172 array('sql_alter',"TABLE spip_documents_liens DROP id_forum"),
177 // destruction des tables spip_documents_articles etc, cf. 12008
178 $GLOBALS['maj'][12009] = array(
179 array('sql_drop_table',"spip_documents_articles"),
180 array('sql_drop_table',"spip_documents_breves"),
181 array('sql_drop_table',"spip_documents_rubriques"),
182 array('sql_drop_table',"spip_documents_auteurs"), # plugin #FORMULAIRE_UPLOAD
183 array('sql_drop_table',"spip_documents_syndic") # plugin podcast_client
186 // destruction des champs articles breves rubriques et syndic, cf. 11961
187 $GLOBALS['maj'][12010] = array(
188 array('sql_alter',"TABLE spip_groupes_mots DROP articles"),
189 array('sql_alter',"TABLE spip_groupes_mots DROP breves"),
190 array('sql_alter',"TABLE spip_groupes_mots DROP rubriques"),
191 array('sql_alter',"TABLE spip_groupes_mots DROP syndic"),
194 function maj_13135 () {
195 include_spip('inc/rubriques');
196 calculer_prochain_postdate();
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 @spip_unlink
(_CACHE_PLUGINS_VERIF
);
204 $GLOBALS['maj'][13135] = array(array('maj_13135'));
206 // Type flac: http://flac.sourceforge.net
207 $GLOBALS['maj'][13333] = array(array('upgrade_types_documents'));
209 // http://archives.rezo.net/spip-zone.mbox/200903.mbox/%3Cbfc33ad70903141606q2e4c53f2k4fef6b45e611a04f@mail.gmail.com%3E
211 $GLOBALS['maj'][13833] = array(
212 array('sql_alter',"TABLE spip_documents_liens ADD INDEX objet(id_objet,objet)"))
215 // Fin upgrade commun branche 2.0
217 include_spip('inc/autoriser');
218 $GLOBALS['maj'][13904] = array(
219 array('sql_alter',"TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"),
220 array('sql_update','spip_auteurs',array('webmestre'=>"'oui'"),sql_in("id_auteur",defined('_ID_WEBMESTRES')?
explode(':',_ID_WEBMESTRES
):(autoriser('configurer')?
array($GLOBALS['visiteur_session']['id_auteur']):array(0)))) // le webmestre est celui qui fait l'upgrade si rien de defini
224 // sites plantes en mode "'su" au lieu de "sus"
225 $GLOBALS['maj'][13929] = array(
226 array('sql_update',"spip_syndic",array('syndication'=>"'sus'"),"syndication LIKE '\\'%'")
229 // Types de fichiers m4a/m4b/m4p/m4u/m4v/dv
230 // Types de fichiers Open XML (cro$oft)
231 $GLOBALS['maj'][14558] = array(array('upgrade_types_documents'));
233 // refaire les upgrade dont les numeros sont inferieurs a ceux de la branche 2.0
234 // etre sur qu'ils sont bien unipotents(?)...
235 $GLOBALS['maj'][14559] = $GLOBALS['maj'][13904]+
$GLOBALS['maj'][13929]+
$GLOBALS['maj'][14558];
237 // Restauration correcte des types mime des fichiers Ogg
238 // http://trac.rezo.net/trac/spip/ticket/1941
239 // + Types de fichiers : f4a/f4b/f4p/f4v/mpc http://en.wikipedia.org/wiki/Flv#File_formats
240 $GLOBALS['maj'][15676] = array(array('upgrade_types_documents'));
242 // Type de fichiers : webm http://en.wikipedia.org/wiki/Flv#File_formats
243 $GLOBALS['maj'][15827] = array(array('upgrade_types_documents'));
245 // IP en 40 caracteres pour IP v6
246 $GLOBALS['maj'][15828] = array(array('sql_alter',"TABLE spip_forum CHANGE `ip` `ip` VARCHAR(40) DEFAULT '' NOT NULL"));