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

v017.php ➔ maj_v017_dist()   F

Complexity

Conditions 23
Paths > 20000

Size

Total Lines 175
Code Lines 121

Duplication

Lines 72
Ratio 41.14 %

Importance

Changes 0
Metric Value
cc 23
eloc 121
c 0
b 0
f 0
nc 1769472
nop 2
dl 72
loc 175
rs 2

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_v017_dist($version_installee, $version_cible)
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 View Code Duplication
		if ($version_installee == 1.701) {
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...
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
		
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 View Code Duplication
	if (upgrade_vers(1.704, $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...
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 View Code Duplication
	if (upgrade_vers(1.707, $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...
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 View Code Duplication
	if (upgrade_vers(1.718, $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...
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 View Code Duplication
	if (upgrade_vers(1.722, $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...
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 View Code Duplication
	if (upgrade_vers(1.723, $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...
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 View Code Duplication
	if (upgrade_vers(1.727, $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...
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 View Code Duplication
	if (upgrade_vers(1.731, $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...
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 View Code Duplication
	if (upgrade_vers(1.733, $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...
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
}
190
191
192
?>
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...
193