Completed
Push — spip-2.1 ( b6b097 )
by cam
42:28 queued 30:44
created

v018.php ➔ maj_v018_dist()   F

Complexity

Conditions 25
Paths > 20000

Size

Total Lines 184
Code Lines 105

Duplication

Lines 45
Ratio 24.46 %

Importance

Changes 0
Metric Value
cc 25
eloc 105
nc 8388608
nop 2
dl 45
loc 184
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2016                                                *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
8
 *                                                                         *
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
\***************************************************************************/
12
13
if (!defined('_ECRIRE_INC_VERSION')) return;
14
15
function maj_v018_dist($version_installee, $version_cible)
16
{
17 View Code Duplication
	if (upgrade_vers(1.801, $version_installee, $version_cible)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
		spip_query("ALTER TABLE spip_rubriques	ADD statut_tmp VARCHAR(10) NOT NULL,	ADD date_tmp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL");
19
		include_spip('inc/rubriques');
20
		calculer_rubriques();
21
		maj_version(1.801);
22
	}
23
24
	// Nouvelles tables d'invalidation
25
	if (upgrade_vers(1.802, $version_installee, $version_cible)) {
26
		spip_query("DROP TABLE spip_id_article_caches");
27
		spip_query("DROP TABLE spip_id_auteur_caches");
28
		spip_query("DROP TABLE spip_id_breve_caches");
29
		spip_query("DROP TABLE spip_id_document_caches");
30
		spip_query("DROP TABLE spip_id_forum_caches");
31
		spip_query("DROP TABLE spip_id_groupe_caches");
32
		spip_query("DROP TABLE spip_id_message_caches");
33
		spip_query("DROP TABLE spip_id_mot_caches");
34
		spip_query("DROP TABLE spip_id_rubrique_caches");
35
		spip_query("DROP TABLE spip_id_signature_caches");
36
		spip_query("DROP TABLE spip_id_syndic_article_caches");
37
		spip_query("DROP TABLE spip_id_syndic_caches");
38
		spip_query("DROP TABLE spip_id_type_caches");
39
		spip_query("DROP TABLE spip_inclure_caches");
40
		maj_version(1.802);
41
	}
42
	if (upgrade_vers(1.803, $version_installee, $version_cible)) {
43
44
	#	27 AOUT 2004 : conservons cette table pour autoriser les retours
45
	#	de SPIP 1.8a6 CVS vers 1.7.2
46
	#	spip_query("DROP TABLE spip_forum_cache");
47
48
		spip_query("DROP TABLE spip_inclure_caches");
49
		maj_version(1.803);
50
	}
51
	if (upgrade_vers(1.804, $version_installee, $version_cible)) {
52
		// recreer la table spip_caches
53
		spip_query("DROP TABLE spip_caches");
54
		creer_base();
55
		maj_version(1.804);
56
	}
57
58 View Code Duplication
	if (upgrade_vers(1.805, $version_installee, $version_cible)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
		spip_query("ALTER TABLE spip_forum ADD id_thread bigint(21) DEFAULT '0' NOT NULL");
60
		include_spip('inc/forum');
61
		calculer_threads();
62
		maj_version(1.805);
63
	}
64
65
	// tables d'orthographe
66
	#if ($version_installee < 1.806)
67
	#	maj_version(1.806);
68
69
	// URLs propres (inc_version = 0.12)
70
	if (upgrade_vers(1.807, $version_installee, $version_cible)) {
71
		foreach (array('articles', 'breves', 'rubriques', 'mots') as $objets) {
72
			spip_query("ALTER TABLE spip_$objets ADD url_propre VARCHAR(255) NOT NULL");
73
			spip_query("ALTER TABLE spip_$objets ADD INDEX url_propre (url_propre)");
74
		}
75
		maj_version(1.807);
76
	}
77
78
	// referers de la veille
79
	if (upgrade_vers(1.808, $version_installee, $version_cible)) {
80
		spip_query("ALTER TABLE spip_referers ADD visites_veille INT UNSIGNED NOT NULL");
81
		maj_version(1.808);
82
	}
83
84
85
	// corrections diverses
86 View Code Duplication
	if (upgrade_vers(1.809, $version_installee, $version_cible)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
87
		// plus de retour possible vers 1.7.2
88
		spip_query("DROP TABLE spip_forum_cache");
89
90
		// les requetes ci-dessous ne s'appliqueront que si on est passe
91
		// par une certaine version de developpement - oublie de le faire
92
		// plus tot, car le code d'alors recreait purement et simplement
93
		// cette table
94
		spip_query("ALTER TABLE spip_versions DROP chapo");
95
		spip_query("ALTER TABLE spip_versions DROP texte");
96
		spip_query("ALTER TABLE spip_versions DROP ps");
97
		spip_query("ALTER TABLE spip_versions DROP extra");
98
		spip_query("ALTER TABLE spip_versions ADD champs text NOT NULL");
99
100
		maj_version(1.809);
101
	}
102
103
	// Annuler les brouillons de forum jamais valides
104
	if (upgrade_vers(1.810, $version_installee, $version_cible)) {
105
		sql_delete("spip_forum", "statut='redac'");
106
		maj_version(1.810);
107
	}
108
109
	if (upgrade_vers(1.811, $version_installee, $version_cible)) {
110
		spip_query("ALTER TABLE spip_syndic ADD extra longblob NULL");
111
		maj_version(1.811);
112
	}
113
	
114
	if (upgrade_vers(1.812, $version_installee, $version_cible)) {
115
		spip_query("ALTER TABLE spip_documents ADD idx ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL");
116
		maj_version(1.812);
117
	}
118
119
	// Mise a jour des types MIME
120
	if (upgrade_vers(1.813, $version_installee, $version_cible)) {
121
		# rien a faire car c'est creer_base() qui s'en charge
122
		maj_version(1.813);
123
	}
124
125
	// URLs propres auteurs
126
	if (upgrade_vers(1.814, $version_installee, $version_cible)) {
127
		spip_query("ALTER TABLE spip_auteurs ADD url_propre VARCHAR(255) NOT NULL");
128
		spip_query("ALTER TABLE spip_auteurs ADD INDEX url_propre (url_propre)");
129
		maj_version(1.814);
130
	}
131
132
	// Mots-cles sur les documents
133
	// + liens documents <-> sites et articles syndiques (podcasting)
134
	if (upgrade_vers(1.815, $version_installee, $version_cible)) {
135
		spip_query("ALTER TABLE spip_documents	ADD distant VARCHAR(3) DEFAULT 'non'");
136
		maj_version(1.815);
137
	}
138
139
	// Indexation des documents (rien a faire sauf reinstaller inc_auxbase)
140
	if (upgrade_vers(1.816, $version_installee, $version_cible)) {
141
		maj_version(1.816);
142
	}
143
144
	// Texte et descriptif des groupes de mots-cles
145
	if (upgrade_vers(1.817, $version_installee, $version_cible)) {
146
		spip_query("ALTER TABLE spip_groupes_mots ADD descriptif text NOT NULL AFTER titre");
147
		spip_query("ALTER TABLE spip_groupes_mots ADD COLUMN texte longblob NOT NULL AFTER descriptif");
148
		maj_version(1.817);
149
	}
150
151
	// Conformite des noms de certains champs (0minirezo => minirezo)
152 View Code Duplication
	if (upgrade_vers(1.818, $version_installee, $version_cible)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
153
		spip_query("ALTER TABLE spip_groupes_mots CHANGE COLUMN 0minirezo minirezo char(3) NOT NULL");
154
		spip_query("ALTER TABLE spip_groupes_mots CHANGE COLUMN 1comite comite char(3) NOT NULL");
155
		spip_query("ALTER TABLE spip_groupes_mots CHANGE COLUMN 6forum forum char(3) NOT NULL");
156
		maj_version(1.818);
157
	}
158
159
	// Options de syndication : miroir + oubli
160
	if (upgrade_vers(1.819, $version_installee, $version_cible)) {
161
		spip_query("ALTER TABLE spip_syndic ADD miroir VARCHAR(3) DEFAULT 'non'");
162
		spip_query("ALTER TABLE spip_syndic ADD oubli VARCHAR(3) DEFAULT 'non'");
163
		maj_version(1.819);
164
	}
165
166
	// Un bug dans les 1.730 (il manquait le "ADD")
167 View Code Duplication
	if (upgrade_vers(1.820, $version_installee, $version_cible)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
168
		spip_query("ALTER TABLE spip_articles ADD INDEX idx (idx)");
169
		spip_query("ALTER TABLE spip_auteurs ADD INDEX idx (idx)");
170
		spip_query("ALTER TABLE spip_breves ADD INDEX idx (idx)");
171
		spip_query("ALTER TABLE spip_mots ADD INDEX idx (idx)");
172
		spip_query("ALTER TABLE spip_rubriques ADD INDEX idx (idx)");
173
		spip_query("ALTER TABLE spip_syndic ADD INDEX idx (idx)");
174
		spip_query("ALTER TABLE spip_forum ADD INDEX idx (idx)");
175
		spip_query("ALTER TABLE spip_signatures ADD INDEX idx (idx)");
176
		maj_version(1.820);
177
	}
178
179
	// reindexer les articles (on avait oublie les auteurs)
180
	if (upgrade_vers(1.821, $version_installee, $version_cible)) {
181
		spip_query("UPDATE spip_articles SET idx='1' WHERE idx='oui'");
182
		maj_version(1.821);
183
	}
184
	// le 'type' des mots doit etre du texte, sinon on depasse en champ multi
185
	if (upgrade_vers(1.822, $version_installee, $version_cible)) {
186
		spip_query("ALTER TABLE spip_mots DROP INDEX type");
187
		spip_query("ALTER TABLE spip_mots CHANGE type type TEXT NOT NULL");
188
		maj_version(1.822);
189
	}
190
	// ajouter une table de fonctions pour ajax
191
	if (upgrade_vers(1.825, $version_installee, $version_cible)) {
192
		maj_version(1.825);
193
	}
194
	if (upgrade_vers(1.826, $version_installee, $version_cible)) {
195
		spip_query("ALTER TABLE spip_ajax_fonc DROP fonction");
196
		maj_version(1.826);
197
	}
198
}
199
200
201
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
202