Completed
Push — master ( 3e6f39...ee2ef7 )
by cam
04:21
created

v014.php ➔ maj_legacy_v014_dist()   F

Complexity

Conditions 49
Paths > 20000

Size

Total Lines 309

Duplication

Lines 92
Ratio 29.77 %

Importance

Changes 0
Metric Value
cc 49
nc 4294967295
nop 2
dl 92
loc 309
rs 0
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, Système de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright © avec tendresse depuis 2001                                 *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribué sous licence GNU/GPL.     *
10
 *  Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
13
/**
14
 * Gestion des mises à jour de SPIP, versions 1.4*
15
 *
16
 * @package SPIP\Core\SQL\Upgrade
17
 **/
18
if (!defined('_ECRIRE_INC_VERSION')) {
19
	return;
20
}
21
22
/**
23
 * Mises à jour de SPIP n°014
24
 *
25
 * @param float $version_installee Version actuelle
26
 * @param float $version_cible Version de destination
27
 **/
28
function maj_legacy_v014_dist($version_installee, $version_cible) {
29 View Code Duplication
	if (upgrade_vers(1.404, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
30
		sql_query("UPDATE spip_mots SET type='Mots sans groupe...' WHERE type=''");
31
32
		$result = sql_query("SELECT * FROM spip_mots GROUP BY type");
33
		while ($row = sql_fetch($result)) {
34
			$type = addslashes($row['type']);
35
			// Old style, doit echouer
36
			spip_log('ne pas tenir compte de l erreur spip_groupes_mots ci-dessous:', 'mysql');
37
			sql_query("INSERT INTO spip_groupes_mots 					(titre, unseul, obligatoire, articles, breves, rubriques, syndic, 0minirezo, 1comite, 6forum)					VALUES (\"$type\", 'non', 'non', 'oui', 'oui', 'non', 'oui', 'oui', 'oui', 'non')");
38
			// New style, devrait marcher
39
			sql_query("INSERT INTO spip_groupes_mots 					(titre, unseul, obligatoire, articles, breves, rubriques, syndic, minirezo, comite, forum)					VALUES (\"$type\", 'non', 'non', 'oui', 'oui', 'non', 'oui', 'oui', 'oui', 'non')");
40
		}
41
		sql_delete("spip_mots", "titre='kawax'");
42
		maj_version(1.404);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
43
	}
44
45 View Code Duplication
	if (upgrade_vers(1.405, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
46
		sql_query("ALTER TABLE spip_mots ADD id_groupe bigint(21) NOT NULL");
47
48
		$result = sql_query("SELECT * FROM spip_groupes_mots");
49
		while ($row = sql_fetch($result)) {
50
			$id_groupe = addslashes($row['id_groupe']);
51
			$type = addslashes($row['titre']);
52
			sql_query("UPDATE spip_mots SET id_groupe = '$id_groupe' WHERE type='$type'");
53
		}
54
		maj_version(1.405);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
55
	}
56
57
	if (upgrade_vers(1.408, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
58
		// Images articles passent dans spip_documents
59
		$result = sql_query("SELECT id_article, images FROM spip_articles WHERE LENGTH(images) > 0");
60
61
62
		$types = array('jpg' => 1, 'png' => 2, 'gif' => 3);
63
64
		while ($row = @sql_fetch($result)) {
65
			$id_article = $row['id_article'];
66
			$images = $row['images'];
67
			$images = explode(",", $images);
68
			reset($images);
69
			$replace = '_orig_';
70
			foreach ($images as $val) {
71
				$image = explode("|", $val);
72
				$fichier = $image[0];
73
				$largeur = $image[1];
74
				$hauteur = $image[2];
75
				preg_match(",-([0-9]+)\.(gif|jpg|png)$,i", $fichier, $match);
76
				$id_type = intval($types[$match[2]]);
77
				$num_img = $match[1];
78
				$fichier = _DIR_IMG . $fichier;
79
				$taille = @filesize($fichier);
80
				// ici on n'a pas les fonctions absctract !
81
				sql_query("INSERT INTO spip_documents (titre, id_type, fichier, mode, largeur, hauteur, taille) VALUES ('image $largeur x $hauteur', $id_type, '$fichier', 'vignette', '$largeur', '$hauteur', '$taille')");
82
				$id_document = mysqli_insert_id(_mysql_link());
83
				if ($id_document > 0) {
84
					sql_query("INSERT INTO spip_documents_articles (id_document, id_article) VALUES ($id_document, $id_article)");
85
					$replace = "REPLACE($replace, '<IMG$num_img|', '<IM_$id_document|')";
86
				} else {
87
					echo _T('texte_erreur_mise_niveau_base', array('fichier' => $fichier, 'id_article' => $id_article));
88
					exit;
89
				}
90
			}
91
			$replace = "REPLACE($replace, '<IM_', '<IMG')";
92
			$replace_chapo = str_replace('_orig_', 'chapo', $replace);
93
			$replace_descriptif = str_replace('_orig_', 'descriptif', $replace);
94
			$replace_texte = str_replace('_orig_', 'texte', $replace);
95
			$replace_ps = str_replace('_orig_', 'ps', $replace);
96
			sql_query("UPDATE spip_articles SET chapo=$replace_chapo, descriptif=$replace_descriptif, texte=$replace_texte, ps=$replace_ps WHERE id_article=$id_article");
97
98
		}
99
		sql_query("ALTER TABLE spip_articles DROP images");
100
		maj_version(1.408);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
101
	}
102
103
	if (upgrade_vers(1.414, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
104
		// Forum par defaut "en dur" dans les spip_articles
105
		// -> non, prio (priori), pos (posteriori), abo (abonnement)
106
		$accepter_forum = substr($GLOBALS['meta']["forums_publics"], 0, 3);
107
		$result = sql_query("ALTER TABLE spip_articles CHANGE accepter_forum accepter_forum CHAR(3) NOT NULL");
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
108
109
		$result = sql_query("UPDATE spip_articles SET accepter_forum='$accepter_forum' WHERE accepter_forum != 'non'");
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
110
111
		maj_version(1.414);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
112
	}
113
114
	/*
115
	if ($version_installee == 1.415) {
116
		sql_query("ALTER TABLE spip_documents DROP inclus");
117
		maj_version (1.415);
118
	}
119
	*/
120
121
	if (upgrade_vers(1.417, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
122
		sql_query("ALTER TABLE spip_syndic_articles DROP date_index");
123
		maj_version(1.417);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
124
	}
125
126
	if (upgrade_vers(1.418, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
127
		$result = sql_query("SELECT * FROM spip_auteurs WHERE statut = '0minirezo' AND email != '' ORDER BY id_auteur LIMIT 1");
128
129
		if ($webmaster = sql_fetch($result)) {
130
			ecrire_meta('email_webmaster', $webmaster['email']);
131
		}
132
		maj_version(1.418);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
133
	}
134
135 View Code Duplication
	if (upgrade_vers(1.419, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
136
		sql_query("ALTER TABLE spip_auteurs ADD alea_actuel TINYTEXT DEFAULT ''");
137
		sql_query("ALTER TABLE spip_auteurs ADD alea_futur TINYTEXT DEFAULT ''");
138
		sql_query("UPDATE spip_auteurs SET alea_futur = FLOOR(32000*RAND())");
139
		maj_version(1.419);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
140
	}
141
142
	if (upgrade_vers(1.420, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
143
		sql_query("UPDATE spip_auteurs SET alea_actuel='' WHERE statut='nouveau'");
144
		maj_version(1.420);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
145
	}
146
147
	if (upgrade_vers(1.421, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
148
		sql_query("ALTER TABLE spip_articles ADD auteur_modif bigint(21) DEFAULT '0' NOT NULL");
149
		sql_query("ALTER TABLE spip_articles ADD date_modif datetime DEFAULT '0000-00-00 00:00:00' NOT NULL");
150
		maj_version(1.421);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
151
	}
152
153 View Code Duplication
	if (upgrade_vers(1.432, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
154
		sql_query("ALTER TABLE spip_articles DROP referers");
155
		sql_query("ALTER TABLE spip_articles ADD referers INTEGER DEFAULT '0' NOT NULL");
156
		sql_query("ALTER TABLE spip_articles ADD popularite INTEGER DEFAULT '0' NOT NULL");
157
		maj_version(1.432);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
158
	}
159
160
	if (upgrade_vers(1.436, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
161
		sql_query("ALTER TABLE spip_documents ADD date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL");
162
		maj_version(1.436);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
163
	}
164
165
	if (upgrade_vers(1.437, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
166
		sql_query("ALTER TABLE spip_visites ADD maj TIMESTAMP");
167
		sql_query("ALTER TABLE spip_visites_referers ADD maj TIMESTAMP");
168
		maj_version(1.437);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
169
	}
170
171
	if (upgrade_vers(1.438, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
172
		sql_query("ALTER TABLE spip_articles ADD INDEX id_secteur (id_secteur)");
173
		sql_query("ALTER TABLE spip_articles ADD INDEX statut (statut, date)");
174
		maj_version(1.438);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
175
	}
176
177 View Code Duplication
	if (upgrade_vers(1.439, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
178
		sql_query("ALTER TABLE spip_syndic ADD INDEX statut (statut, date_syndic)");
179
		sql_query("ALTER TABLE spip_syndic_articles ADD INDEX statut (statut)");
180
		sql_query("ALTER TABLE spip_syndic_articles CHANGE url url VARCHAR(255) NOT NULL");
181
		sql_query("ALTER TABLE spip_syndic_articles ADD INDEX url (url)");
182
		maj_version(1.439);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
183
	}
184
185
	if (upgrade_vers(1.440, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
186
		sql_query("ALTER TABLE spip_visites_temp CHANGE ip ip INTEGER UNSIGNED NOT NULL");
187
		maj_version(1.440);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
188
	}
189
190 View Code Duplication
	if (upgrade_vers(1.441, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
191
		sql_query("ALTER TABLE spip_visites_temp CHANGE date date DATE NOT NULL");
192
		sql_query("ALTER TABLE spip_visites CHANGE date date DATE NOT NULL");
193
		sql_query("ALTER TABLE spip_visites_referers CHANGE date date DATE NOT NULL");
194
		maj_version(1.441);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
195
	}
196
197
	if (upgrade_vers(1.442, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
198
		sql_query("ALTER TABLE spip_auteurs ADD prefs TINYTEXT NOT NULL");
199
		maj_version(1.442);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
200
	}
201
202 View Code Duplication
	if (upgrade_vers(1.443, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
203
		sql_query("ALTER TABLE spip_auteurs CHANGE login login VARCHAR(255) BINARY NOT NULL");
204
		sql_query("ALTER TABLE spip_auteurs CHANGE statut statut VARCHAR(255) NOT NULL");
205
		sql_query("ALTER TABLE spip_auteurs ADD INDEX login (login)");
206
		sql_query("ALTER TABLE spip_auteurs ADD INDEX statut (statut)");
207
		maj_version(1.443);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
208
	}
209
210
	if (upgrade_vers(1.444, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
211
		sql_query("ALTER TABLE spip_syndic ADD moderation VARCHAR(3) NOT NULL");
212
		maj_version(1.444);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
213
	}
214
215 View Code Duplication
	if (upgrade_vers(1.457, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
216
		sql_query("DROP TABLE spip_visites");
217
		sql_query("DROP TABLE spip_visites_temp");
218
		sql_query("DROP TABLE spip_visites_referers");
219
		creer_base(); // crade, a ameliorer :-((
220
		maj_version(1.457);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
221
	}
222
223
	if (upgrade_vers(1.458, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
224
		sql_query("ALTER TABLE spip_auteurs ADD cookie_oubli TINYTEXT NOT NULL");
225
		maj_version(1.458);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
226
	}
227
228
	if (upgrade_vers(1.459, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
229
		$result = sql_query("SELECT type FROM spip_mots GROUP BY type");
230
		while ($row = sql_fetch($result)) {
231
			$type = addslashes($row['type']);
232
			$res = sql_query("SELECT * FROM spip_groupes_mots WHERE titre='$type'");
233
			if (sql_count($res) == 0) {
234
				sql_query("INSERT INTO spip_groupes_mots (titre, unseul, obligatoire, articles, breves, rubriques, syndic, minirezo, comite, forum) VALUES ('$type', 'non', 'non', 'oui', 'oui', 'non', 'oui', 'oui', 'oui', 'non')");
235
				if ($id_groupe = mysqli_insert_id(_mysql_link())) {
236
					sql_query("UPDATE spip_mots SET id_groupe = '$id_groupe' WHERE type='$type'");
237
				}
238
			}
239
		}
240
		sql_query("UPDATE spip_articles SET popularite=0");
241
		maj_version(1.459);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
242
	}
243
244
	if (upgrade_vers(1.460, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
245
		// remettre les mots dans les groupes dupliques par erreur
246
		// dans la precedente version du paragraphe de maj 1.459
247
		// et supprimer ceux-ci
248
		$result = sql_query("SELECT * FROM spip_groupes_mots ORDER BY id_groupe");
249
		while ($row = sql_fetch($result)) {
250
			$titre = addslashes($row['titre']);
251
			if (!$vu[$titre]) {
0 ignored issues
show
Bug introduced by
The variable $vu does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
252
				$vu[$titre] = true;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$vu was never initialized. Although not strictly required by PHP, it is generally a good practice to add $vu = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
253
				$id_groupe = $row['id_groupe'];
254
				sql_query("UPDATE spip_mots SET id_groupe=$id_groupe WHERE type='$titre'");
255
				sql_delete("spip_groupes_mots", "titre='$titre' AND id_groupe<>$id_groupe");
256
			}
257
		}
258
		maj_version(1.460);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
259
	}
260
261
	if (upgrade_vers(1.462, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
262
		sql_query("UPDATE spip_types_documents SET inclus='embed' WHERE inclus!='non' AND extension IN ('aiff', 'asf', 'avi', 'mid', 'mov', 'mp3', 'mpg', 'ogg', 'qt', 'ra', 'ram', 'rm', 'swf', 'wav', 'wmv')");
263
		maj_version(1.462);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
264
	}
265
266 View Code Duplication
	if (upgrade_vers(1.463, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
267
		sql_query("ALTER TABLE spip_articles CHANGE popularite popularite DOUBLE");
268
		sql_query("ALTER TABLE spip_visites_temp ADD maj TIMESTAMP");
269
		sql_query("ALTER TABLE spip_referers_temp ADD maj TIMESTAMP");
270
		maj_version(1.463);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
271
	}
272
273
	// l'upgrade < 1.462 ci-dessus etait fausse, d'ou correctif
274
	if (upgrade_vers(1.464, $version_installee, $version_cible) and ($version_installee >= 1.462)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
275
		$res = sql_query("SELECT id_type, extension FROM spip_types_documents WHERE id_type NOT IN (1,2,3)");
276
		while ($row = sql_fetch($res)) {
277
			$extension = $row['extension'];
278
			$id_type = $row['id_type'];
279
			sql_query("UPDATE spip_documents SET id_type=$id_type	WHERE fichier like '%.$extension'");
280
		}
281
		maj_version(1.464);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
282
	}
283
284
	if (upgrade_vers(1.465, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
285
		sql_query("ALTER TABLE spip_articles CHANGE popularite popularite DOUBLE NOT NULL");
286
		maj_version(1.465);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
287
	}
288
289
	if (upgrade_vers(1.466, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
290
		sql_query("ALTER TABLE spip_auteurs ADD source VARCHAR(10) DEFAULT 'spip' NOT NULL");
291
		maj_version(1.466);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
292
	}
293
294
	if (upgrade_vers(1.468, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
295
		sql_query("ALTER TABLE spip_auteurs ADD INDEX en_ligne (en_ligne)");
296
		sql_query("ALTER TABLE spip_forum ADD INDEX statut (statut, date_heure)");
297
		maj_version(1.468);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
298
	}
299
300 View Code Duplication
	if (upgrade_vers(1.470, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
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...
301
		if ($version_installee >= 1.467) {  // annule les "listes de diff"
302
			sql_query("DROP TABLE spip_listes");
303
			sql_query("ALTER TABLE spip_auteurs DROP abonne");
304
			sql_query("ALTER TABLE spip_auteurs DROP abonne_pass");
305
		}
306
		maj_version(1.470);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
307
	}
308
309
	if (upgrade_vers(1.471, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
310 View Code Duplication
		if ($version_installee >= 1.470) {  // annule les "maj"
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...
311
			sql_query("ALTER TABLE spip_auteurs_articles DROP maj TIMESTAMP");
312
			sql_query("ALTER TABLE spip_auteurs_rubriques DROP maj TIMESTAMP");
313
			sql_query("ALTER TABLE spip_auteurs_messages DROP maj TIMESTAMP");
314
			sql_query("ALTER TABLE spip_documents_articles DROP maj TIMESTAMP");
315
			sql_query("ALTER TABLE spip_documents_rubriques DROP maj TIMESTAMP");
316
			sql_query("ALTER TABLE spip_documents_breves DROP maj TIMESTAMP");
317
			sql_query("ALTER TABLE spip_mots_articles DROP maj TIMESTAMP");
318
			sql_query("ALTER TABLE spip_mots_breves DROP maj TIMESTAMP");
319
			sql_query("ALTER TABLE spip_mots_rubriques DROP maj TIMESTAMP");
320
			sql_query("ALTER TABLE spip_mots_syndic DROP maj TIMESTAMP");
321
			sql_query("ALTER TABLE spip_mots_forum DROP maj TIMESTAMP");
322
		}
323
		maj_version(1.471);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
324
	}
325
326
	if (upgrade_vers(1.472, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
327
		sql_query("ALTER TABLE spip_referers ADD visites_jour INTEGER UNSIGNED NOT NULL");
328
		maj_version(1.472);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
329
	}
330
331
	if (upgrade_vers(1.473, $version_installee, $version_cible)) {
0 ignored issues
show
Deprecated Code introduced by
The function upgrade_vers() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
332
		sql_query("UPDATE spip_syndic_articles SET url = REPLACE(url, '&amp;', '&')");
333
		sql_query("UPDATE spip_syndic SET url_site = REPLACE(url_site, '&amp;', '&')");
334
		maj_version(1.473);
0 ignored issues
show
Deprecated Code introduced by
The function maj_version() has been deprecated with message: Utiliser `maj_plugin()` ou la globale `maj` pour le core.

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
335
	}
336
}
337