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

v012.php ➔ maj_legacy_v012_dist()   B

Complexity

Conditions 7
Paths 32

Size

Total Lines 64

Duplication

Lines 41
Ratio 64.06 %

Importance

Changes 0
Metric Value
cc 7
nc 32
nop 2
dl 41
loc 64
rs 7.8521
c 0
b 0
f 0

How to fix   Long Method   

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.2*
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°012
24
 *
25
 * @param float $version_installee Version actuelle
26
 * @param float $version_cible Version de destination
27
 **/
28
function maj_legacy_v012_dist($version_installee, $version_cible) {
29
	// Correction de l'oubli des modifs creations depuis 1.04
30 View Code Duplication
	if (upgrade_vers(1.204, $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...
31
		sql_query("ALTER TABLE spip_articles ADD accepter_forum VARCHAR(3) NOT NULL");
32
		sql_query("ALTER TABLE spip_forum ADD id_message bigint(21) NOT NULL");
33
		sql_query("ALTER TABLE spip_forum ADD INDEX id_message (id_message)");
34
		sql_query("ALTER TABLE spip_auteurs ADD en_ligne datetime DEFAULT '0000-00-00 00:00:00' NOT NULL");
35
		sql_query("ALTER TABLE spip_auteurs ADD imessage VARCHAR(3) not null");
36
		sql_query("ALTER TABLE spip_auteurs ADD messagerie VARCHAR(3) not null");
37
		maj_version(1.204);
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...
38
	}
39
40 View Code Duplication
	if (upgrade_vers(1.207, $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...
41
		sql_query("ALTER TABLE spip_rubriques DROP INDEX id_rubrique");
42
		sql_query("ALTER TABLE spip_rubriques ADD INDEX id_parent (id_parent)");
43
		sql_query("ALTER TABLE spip_rubriques ADD statut VARCHAR(10) NOT NULL");
44
		// Declencher le calcul des rubriques publiques
45
		include_spip('inc/rubriques');
46
		calculer_rubriques();
47
		maj_version(1.207);
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...
48
	}
49
50 View Code Duplication
	if (upgrade_vers(1.208, $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...
51
		sql_query("ALTER TABLE spip_auteurs_messages CHANGE forum vu CHAR(3) NOT NULL");
52
		sql_query("UPDATE spip_auteurs_messages SET vu='oui'");
53
		sql_query("UPDATE spip_auteurs_messages SET vu='non' WHERE statut='a'");
54
55
		sql_query("ALTER TABLE spip_messages ADD id_auteur bigint(21) NOT NULL");
56
		sql_query("ALTER TABLE spip_messages ADD INDEX id_auteur (id_auteur)");
57
		$result = sql_query("SELECT id_auteur, id_message FROM spip_auteurs_messages WHERE statut='de'");
58
		while ($row = sql_fetch($result)) {
59
			$id_auteur = $row['id_auteur'];
60
			$id_message = $row['id_message'];
61
			sql_query("UPDATE spip_messages SET id_auteur=$id_auteur WHERE id_message=$id_message");
62
		}
63
64
		sql_query("ALTER TABLE spip_auteurs_messages DROP statut");
65
		maj_version(1.208);
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...
66
	}
67
68 View Code Duplication
	if (upgrade_vers(1.209, $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...
69
		sql_query("ALTER TABLE spip_syndic ADD maj TIMESTAMP");
70
		sql_query("ALTER TABLE spip_syndic_articles ADD maj TIMESTAMP");
71
		sql_query("ALTER TABLE spip_messages ADD maj TIMESTAMP");
72
		maj_version(1.209);
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...
73
	}
74
75
	if (upgrade_vers(1.210, $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...
76
		sql_query("ALTER TABLE spip_messages DROP page");
77
78
		stripslashes_base('spip_articles', array('surtitre', 'titre', 'soustitre', 'descriptif', 'chapo', 'texte', 'ps'));
79
		stripslashes_base('spip_auteurs', array('nom', 'bio', 'nom_site'));
80
		stripslashes_base('spip_breves', array('titre', 'texte', 'lien_titre'));
81
		stripslashes_base('spip_forum', array('titre', 'texte', 'auteur', 'nom_site'));
82
		stripslashes_base('spip_messages', array('titre', 'texte'));
83
		stripslashes_base('spip_mots', array('type', 'titre', 'descriptif', 'texte'));
84
		stripslashes_base('spip_petitions', array('texte'));
85
		stripslashes_base('spip_rubriques', array('titre', 'descriptif', 'texte'));
86
		stripslashes_base('spip_signatures', array('nom_email', 'nom_site', 'message'));
87
		stripslashes_base('spip_syndic', array('nom_site', 'descriptif'));
88
		stripslashes_base('spip_syndic_articles', array('titre', 'lesauteurs'));
89
		maj_version(1.210);
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...
90
	}
91
}
92