| Conditions | 18 |
| Paths | 24 |
| Total Lines | 123 |
| Lines | 72 |
| Ratio | 58.54 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 28 | function maj_legacy_v009_dist($version_installee, $version_cible) { |
||
| 29 | if (upgrade_vers(0.98, $version_installee, $version_cible)) { |
||
|
|
|||
| 30 | |||
| 31 | sql_query("ALTER TABLE spip_articles ADD maj TIMESTAMP"); |
||
| 32 | sql_query("ALTER TABLE spip_articles ADD export VARCHAR(10) DEFAULT 'oui'"); |
||
| 33 | sql_query("ALTER TABLE spip_articles ADD images TEXT DEFAULT ''"); |
||
| 34 | sql_query("ALTER TABLE spip_articles ADD date_redac datetime DEFAULT '0000-00-00 00:00:00' NOT NULL"); |
||
| 35 | sql_query("ALTER TABLE spip_articles DROP INDEX id_article"); |
||
| 36 | sql_query("ALTER TABLE spip_articles ADD INDEX id_rubrique (id_rubrique)"); |
||
| 37 | sql_query("ALTER TABLE spip_articles ADD visites INTEGER DEFAULT '0' NOT NULL"); |
||
| 38 | sql_query("ALTER TABLE spip_articles ADD referers BLOB NOT NULL"); |
||
| 39 | |||
| 40 | sql_query("ALTER TABLE spip_auteurs ADD maj TIMESTAMP"); |
||
| 41 | sql_query("ALTER TABLE spip_auteurs ADD pgp BLOB NOT NULL"); |
||
| 42 | |||
| 43 | sql_query("ALTER TABLE spip_auteurs_articles ADD INDEX id_auteur (id_auteur), ADD INDEX id_article (id_article)"); |
||
| 44 | |||
| 45 | sql_query("ALTER TABLE spip_rubriques ADD maj TIMESTAMP"); |
||
| 46 | sql_query("ALTER TABLE spip_rubriques ADD export VARCHAR(10) DEFAULT 'oui', ADD id_import BIGINT DEFAULT '0'"); |
||
| 47 | |||
| 48 | sql_query("ALTER TABLE spip_breves ADD maj TIMESTAMP"); |
||
| 49 | sql_query("ALTER TABLE spip_breves DROP INDEX id_breve"); |
||
| 50 | sql_query("ALTER TABLE spip_breves DROP INDEX id_breve_2"); |
||
| 51 | sql_query("ALTER TABLE spip_breves ADD INDEX id_rubrique (id_rubrique)"); |
||
| 52 | |||
| 53 | sql_query("ALTER TABLE spip_forum ADD ip VARCHAR(16)"); |
||
| 54 | sql_query("ALTER TABLE spip_forum ADD maj TIMESTAMP"); |
||
| 55 | sql_query("ALTER TABLE spip_forum DROP INDEX id_forum"); |
||
| 56 | sql_query("ALTER TABLE spip_forum ADD INDEX id_parent (id_parent), ADD INDEX id_rubrique (id_rubrique), ADD INDEX id_article(id_article), ADD INDEX id_breve(id_breve)"); |
||
| 57 | maj_version(0.98); |
||
| 58 | } |
||
| 59 | |||
| 60 | if (upgrade_vers(0.99, $version_installee, $version_cible)) { |
||
| 61 | |||
| 62 | $result = sql_query("SELECT DISTINCT id_article FROM spip_forum WHERE id_article!=0 AND id_parent=0"); |
||
| 63 | |||
| 64 | View Code Duplication | while ($row = sql_fetch($result)) { |
|
| 65 | unset($forums_article); |
||
| 66 | $id_article = $row['id_article']; |
||
| 67 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_article=$id_article"); |
||
| 68 | for (; ;) { |
||
| 69 | unset($forums); |
||
| 70 | while ($row2 = sql_fetch($result2)) { |
||
| 71 | $forums[] = $row2['id_forum']; |
||
| 72 | } |
||
| 73 | if (!$forums) { |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | $forums = join(',', $forums); |
||
| 77 | $forums_article[] = $forums; |
||
| 78 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_parent IN ($forums)"); |
||
| 79 | } |
||
| 80 | $forums_article = join(',', $forums_article); |
||
| 81 | sql_query("UPDATE spip_forum SET id_article=$id_article WHERE id_forum IN ($forums_article)"); |
||
| 82 | } |
||
| 83 | |||
| 84 | $result = sql_query("SELECT DISTINCT id_breve FROM spip_forum WHERE id_breve!=0 AND id_parent=0"); |
||
| 85 | |||
| 86 | View Code Duplication | while ($row = sql_fetch($result)) { |
|
| 87 | unset($forums_breve); |
||
| 88 | $id_breve = $row['id_breve']; |
||
| 89 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_breve=$id_breve"); |
||
| 90 | for (; ;) { |
||
| 91 | unset($forums); |
||
| 92 | while ($row2 = sql_fetch($result2)) { |
||
| 93 | $forums[] = $row2['id_forum']; |
||
| 94 | } |
||
| 95 | if (!$forums) { |
||
| 96 | break; |
||
| 97 | } |
||
| 98 | $forums = join(',', $forums); |
||
| 99 | $forums_breve[] = $forums; |
||
| 100 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_parent IN ($forums)"); |
||
| 101 | } |
||
| 102 | $forums_breve = join(',', $forums_breve); |
||
| 103 | sql_query("UPDATE spip_forum SET id_breve=$id_breve WHERE id_forum IN ($forums_breve)"); |
||
| 104 | } |
||
| 105 | |||
| 106 | $result = sql_query("SELECT DISTINCT id_rubrique FROM spip_forum WHERE id_rubrique!=0 AND id_parent=0"); |
||
| 107 | |||
| 108 | View Code Duplication | while ($row = sql_fetch($result)) { |
|
| 109 | unset($forums_rubrique); |
||
| 110 | $id_rubrique = $row['id_rubrique']; |
||
| 111 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_rubrique=$id_rubrique"); |
||
| 112 | for (; ;) { |
||
| 113 | |||
| 114 | unset($forums); |
||
| 115 | while ($row2 = sql_fetch($result2)) { |
||
| 116 | $forums[] = $row2['id_forum']; |
||
| 117 | } |
||
| 118 | if (!$forums) { |
||
| 119 | break; |
||
| 120 | } |
||
| 121 | $forums = join(',', $forums); |
||
| 122 | $forums_rubrique[] = $forums; |
||
| 123 | $result2 = sql_query("SELECT id_forum FROM spip_forum WHERE id_parent IN ($forums)"); |
||
| 124 | } |
||
| 125 | $forums_rubrique = join(',', $forums_rubrique); |
||
| 126 | sql_query("UPDATE spip_forum SET id_rubrique=$id_rubrique WHERE id_forum IN ($forums_rubrique)"); |
||
| 127 | |||
| 128 | } |
||
| 129 | maj_version(0.99); |
||
| 130 | } |
||
| 131 | |||
| 132 | if (upgrade_vers(0.997, $version_installee, $version_cible)) { |
||
| 133 | sql_query("DROP TABLE spip_index"); |
||
| 134 | maj_version(0.997); |
||
| 135 | } |
||
| 136 | |||
| 137 | View Code Duplication | if (upgrade_vers(0.999, $version_installee, $version_cible)) { |
|
| 138 | |||
| 139 | sql_query("ALTER TABLE spip_auteurs CHANGE pass pass tinyblob NOT NULL"); |
||
| 140 | sql_query("ALTER TABLE spip_auteurs ADD htpass tinyblob NOT NULL"); |
||
| 141 | $result = sql_query("SELECT id_auteur, pass FROM spip_auteurs WHERE pass!=''"); |
||
| 142 | |||
| 143 | while ($r = sql_fetch($result)) { |
||
| 144 | $htpass = generer_htpass($r['pass']); |
||
| 145 | $pass = md5($pass); |
||
| 146 | sql_query("UPDATE spip_auteurs SET pass='$pass', htpass='$htpass' WHERE id_auteur=" . $r['id_auteur']); |
||
| 147 | } |
||
| 148 | maj_version(0.999); |
||
| 149 | } |
||
| 150 | } |
||
| 151 |
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.