Test Failed
Push — trunk ( db071f...8d464a )
by SuperNova.WS
06:33
created

update.php ➔ propagade_player_options()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 update.php
4
5
 Automated DB upgrade system
6
7
 @package supernova
8
 @version 26
9
10
 25 - copyright (c) 2009-2011 Gorlum for http://supernova.ws
11
   [!] Now it's all about transactions...
12
   [~] Converted doquery to internal wrapper with logging ability
13
 24 - copyright (c) 2009-2011 Gorlum for http://supernova.ws
14
   [+] Converted pre v18 entries to use later implemented functions
15
 v18-v23 - copyright (c) 2009-2010 Gorlum for http://supernova.ws
16
   [!] DB code updates
17
 17 - copyright (c) 2009-2010 Gorlum for http://supernova.ws
18
   [~] PCG1 compliant
19
20
 v01-v16 copyright (c) 2009-2010 Gorlum for http://supernova.ws
21
   [!] DB code updates
22
*/
23
24
if(!defined('INIT')) {
25
//  include_once('init.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
  die('Unauthorized access');
27
}
28
29
define('IN_UPDATE', true);
30
31
require('includes/upd_helpers.php');
32
33
global $sn_cache, $new_version, $config, $debug, $sys_log_disabled, $upd_log, $update_tables, $update_indexes, $update_indexes_full, $update_foreigns;
34
35
$config->reset();
36
$config->db_loadAll();
37
$config->db_prefix = classSupernova::$db->db_prefix; // Оставить пока для совместимости
38
$config->cache_prefix = classSupernova::$cache_prefix;
39
$config->debug = 0;
40
41
42
//$config->db_loadItem('db_version');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
if($config->db_version == DB_VERSION) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
44
} elseif($config->db_version > DB_VERSION) {
45
  $config->db_saveItem('var_db_update_end', SN_TIME_NOW);
46
  die(
47
    'Internal error! Auotupdater detects DB version greater then can be handled!<br />
48
    Possible you have out-of-date SuperNova version<br />
49
    Please upgrade your server from <a href="http://github.com/supernova-ws/SuperNova">GIT repository</a>'
50
  );
51
}
52
53
$upd_log = '';
54
$new_version = floatval($config->db_version);
55
$minVersion = 40;
56
if($new_version < $minVersion) {
57
  die("This version does not supports upgrades from SN below v{$minVersion}. Please, use SN v42 to upgrade old database.<br />
58
Эта версия игры не поддерживает обновление движка версий ниже v{$minVersion}. Пожалуйста, используйте SN v42 для апгрейда со старых версий игры.");
59
}
60
61
upd_check_key('upd_lock_time', 300, !isset($config->upd_lock_time));
62
63
set_time_limit($config->upd_lock_time + 10);
64
65
upd_log_message('Update started. Disabling server');
66
67
$old_server_status = $config->db_loadItem('game_disable');
68
$config->db_saveItem('game_disable', GAME_DISABLE_UPDATE);
69
70
upd_log_message('Server disabled. Loading table info...');
71
$update_tables  = array();
72
$update_indexes = array();
73
$query = upd_do_query('SHOW TABLES;', true);
74
while($row = db_fetch_row($query)) {
75
  upd_load_table_info($row[0]);
76
}
77
upd_log_message('Table info loaded. Now looking DB for upgrades...');
78
79
upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true);
80
81
82
ini_set('memory_limit', '1024M');
83
84
switch($new_version) {
85
  case 40:
86
    upd_log_version_update();
87
88
    if(empty($update_tables['festival'])) {
89
      upd_create_table('festival', " (
90
          `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
91
          `start` datetime NOT NULL COMMENT 'Festival start datetime',
92
          `finish` datetime NOT NULL COMMENT 'Festival end datetime',
93
          `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Название акции/ивента',
94
          PRIMARY KEY (`id`),
95
          KEY `I_festival_date_range` (`start`,`finish`,`id`) USING BTREE
96
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
97
      );
98
99
      upd_create_table('festival_highspot', " (
100
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
101
          `festival_id` smallint(5) unsigned DEFAULT NULL,
102
          `class` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Highspot class',
103
          `start` datetime NOT NULL COMMENT 'Highspot start datetime',
104
          `finish` datetime NOT NULL COMMENT 'Highspot end datetime',
105
          `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
106
          PRIMARY KEY (`id`),
107
          KEY `I_highspot_order` (`start`,`finish`,`id`),
108
          KEY `I_highspot_festival_id` (`festival_id`,`start`,`finish`,`id`) USING BTREE,
109
          CONSTRAINT `FK_highspot_festival_id` FOREIGN KEY (`festival_id`) REFERENCES `{{festival}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
110
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
111
      );
112
113
      upd_create_table('festival_highspot_activity', " (
114
          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
115
          `highspot_id` int(10) unsigned DEFAULT NULL,
116
          `class` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Класс события - ID модуля события',
117
          `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'Тип активити: 1 - триггер, 2 - хук',
118
          `start` datetime NOT NULL COMMENT 'Запланированное время запуска',
119
          `finish` datetime DEFAULT NULL COMMENT 'Реальное время запуска',
120
          `params` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'Параметры активити в виде сериализованного архива',
121
          PRIMARY KEY (`id`),
122
          KEY `I_festival_activity_order` (`start`,`finish`,`id`) USING BTREE,
123
          KEY `I_festival_activity_highspot_id` (`highspot_id`,`start`,`finish`,`id`) USING BTREE,
124
          CONSTRAINT `FK_festival_activity_highspot_id` FOREIGN KEY (`highspot_id`) REFERENCES `{{festival_highspot}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
125
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
126
      );
127
    }
128
129
    if(empty($update_tables['festival_unit'])) {
130
      upd_create_table('festival_unit', " (
131
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
132
          `highspot_id` int(10) unsigned DEFAULT NULL,
133
          `player_id` bigint(20) unsigned DEFAULT NULL,
134
          `unit_id` bigint(20) NOT NULL DEFAULT '0',
135
          `unit_level` bigint(20) unsigned NOT NULL DEFAULT '0',
136
          PRIMARY KEY (`id`),
137
          KEY `I_festival_unit_player_id` (`player_id`,`highspot_id`) USING BTREE,
138
          KEY `I_festival_unit_highspot_id` (`highspot_id`,`unit_id`,`player_id`) USING BTREE,
139
          CONSTRAINT `FK_festival_unit_hispot` FOREIGN KEY (`highspot_id`) REFERENCES `{{festival_highspot}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
140
          CONSTRAINT `FK_festival_unit_player` FOREIGN KEY (`player_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
141
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
142
      );
143
    }
144
145
    // 2015-12-21 06:06:09 41a0.12
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
146
    if(empty($update_tables['festival_unit_log'])) {
147
      upd_create_table('festival_unit_log', " (
148
          `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
149
          `highspot_id` int(10) unsigned DEFAULT NULL,
150
          `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
151
          `player_name` varchar(32) NOT NULL DEFAULT '',
152
          `unit_id` bigint(20) unsigned NOT NULL DEFAULT '0',
153
          `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
154
          `unit_level` int(11) NOT NULL DEFAULT '0',
155
          PRIMARY KEY (`id`),
156
          KEY `I_festival_unit_log_player_id` (`player_id`,`highspot_id`,`id`) USING BTREE,
157
          KEY `I_festival_unit_log_highspot_id` (`highspot_id`,`unit_id`,`player_id`) USING BTREE,
158
          CONSTRAINT `FK_festival_unit_log_hispot` FOREIGN KEY (`highspot_id`) REFERENCES `{{festival_highspot}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
159
          CONSTRAINT `FK_festival_unit_log_player` FOREIGN KEY (`player_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
160
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
161
      );
162
    }
163
164
    // 2015-12-22 00:00:32 41a0.17
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
165
    upd_alter_table('festival_unit_log', "ADD COLUMN `unit_image` varchar(255) NOT NULL DEFAULT ''", empty($update_tables['festival_unit_log']['unit_image']));
0 ignored issues
show
Documentation introduced by
'ADD COLUMN `unit_image`... NOT NULL DEFAULT \'\'' is of type string, but the function expects a array<integer,string>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
166
167
    // 2016-01-15 10:57:17 41a1.4
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
168
    upd_alter_table(
169
      'security_browser',
170
      "MODIFY COLUMN `browser_user_agent` VARCHAR(250) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''",
0 ignored issues
show
Documentation introduced by
'MODIFY COLUMN `browser_... NOT NULL DEFAULT \'\'' is of type string, but the function expects a array<integer,string>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
171
      $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
172
    );
173
174
    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
175
      upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
0 ignored issues
show
Documentation introduced by
'DROP KEY `I_browser_user_agent`' is of type string, but the function expects a array<integer,string>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
176
      upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
0 ignored issues
show
Documentation introduced by
'ADD KEY `I_browser_user...ser_agent`) USING HASH' is of type string, but the function expects a array<integer,string>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
177
    }
178
179
    // 2016-12-03 20:36:46 41a61.0
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
180
    if(empty($update_tables['auth_vkontakte_account'])) {
181
      upd_create_table('auth_vkontakte_account', " (
182
          `user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
183
          `access_token` varchar(250) NOT NULL DEFAULT '',
184
          `expires_in` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
185
          `email` varchar(250) NOT NULL DEFAULT '',
186
187
          `first_name` varchar(250) NOT NULL DEFAULT '',
188
          `last_name` varchar(250) NOT NULL DEFAULT '',
189
190
          `account_id` bigint(20) unsigned NULL COMMENT 'Account ID',
191
192
          PRIMARY KEY (`user_id`),
193
          CONSTRAINT `FK_vkontakte_account_id` FOREIGN KEY (`account_id`) REFERENCES `{{account}}` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE
194
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
195
      );
196
    }
197
198
    upd_do_query('COMMIT;', true);
199
200
    // 2017-02-03 16:10:49 41b1
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
201
    $new_version = 41;
202
203
  case 41:
204
    upd_log_version_update();
205
    // 2017-02-07 09:43:45 42a0
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
206
    upd_check_key('game_news_overview_show', 2 * 7 * 24 * 60 * 60, !isset($config->game_news_overview_show));
207
208
    // 2017-02-13 13:44:18 42a17
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
209
    upd_check_key('tutorial_first_item', 1, !isset($config->tutorial_first_item));
210
211
    // 2017-02-14 17:13:45 42a20.11
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
212
    // TODO - REMOVE DROP TABLE AND CONDITION!
213
    if (!isset($update_indexes['text']['I_text_next_alt'])) {
214
      upd_drop_table('text');
215
      upd_create_table('text',
216
        "
217
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218
        `parent` bigint(20) unsigned DEFAULT NULL COMMENT 'Parent record. NULL - no parent',
219
        `context` bigint(20) unsigned DEFAULT NULL COMMENT 'Tutorial context. NULL - main screen',
220
        `prev` bigint(20) unsigned DEFAULT NULL COMMENT 'Previous text part. NULL - first part',
221
        `next` bigint(20) unsigned DEFAULT NULL COMMENT 'Next text part. NULL - final part',
222
        `next_alt` bigint(20) unsigned DEFAULT NULL COMMENT 'Alternative next text part. NULL - no alternative',
223
        `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Text title',
224
        `content` text COLLATE utf8_unicode_ci COMMENT 'Content - 64k fits to all!',
225
        PRIMARY KEY (`id`),
226
        KEY `I_text_parent` (`parent`),
227
        KEY `I_text_prev` (`prev`),
228
        KEY `I_text_next` (`next`),
229
        KEY `I_text_next_alt` (`next_alt`),
230
        CONSTRAINT `FK_text_parent` FOREIGN KEY (`parent`) REFERENCES `{{text}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
231
        CONSTRAINT `FK_text_prev` FOREIGN KEY (`prev`) REFERENCES `{{text}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
232
        CONSTRAINT `FK_text_next` FOREIGN KEY (`next`) REFERENCES `{{text}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
233
        CONSTRAINT `FK_text_next_alt` FOREIGN KEY (`next_alt`) REFERENCES `{{text}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
234
        ",
235
        'ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
236
      );
237
    }
238
239
    // 2017-02-22 01:46:23 42a23.6
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
240
    // RPG_MARKET = 6, RPG_MARKET_EXCHANGE = 35
241
    upd_do_query("UPDATE `{{log_dark_matter}}` SET `log_dark_matter_reason` = " . 35 . " WHERE `log_dark_matter_reason` = " . 6);
242
    upd_do_query("UPDATE `{{log_metamatter}}` SET `reason` = " . 35 . " WHERE `reason` = " . 6);
243
244
    // 2017-03-06 00:43:16 42a26.4
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
245
    if (empty($update_tables['festival_gifts'])) {
246
      upd_create_table('festival_gifts',
247
        "
248
        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
249
        `highspot_id` int(10) unsigned DEFAULT NULL,
250
        `from` bigint(20) unsigned DEFAULT NULL,
251
        `to` bigint(20) unsigned DEFAULT NULL,
252
        `amount` bigint(20) unsigned NOT NULL,
253
        PRIMARY KEY (`id`),
254
        KEY `I_highspot_id` (`highspot_id`,`from`,`to`) USING BTREE,
255
        KEY `I_to_from` (`highspot_id`,`to`,`from`) USING BTREE
256
        ",
257
        'ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
258
      );
259
    }
260
261
    // 2017-03-11 20:09:51 42a26.15
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
262
    if(empty($update_tables['users']['skin'])) {
263
      upd_alter_table(
264
        'users',
265
        array(
266
          "ADD COLUMN `template` VARCHAR(64) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'OpenGame' AFTER `que_processed`",
267
          "ADD COLUMN `skin` VARCHAR(64) CHARSET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'EpicBlue' AFTER `template`",
268
        ),
269
        empty($update_tables['users']['skin'])
270
      );
271
272
      $query = upd_do_query("SELECT `id`, `dpath` FROM `{{users}}` FOR UPDATE");
273
      while ($row = db_fetch($query)) {
274
        $skinName = '';
275
        if (!$row['dpath']) {
276
          $skinName = 'EpicBlue';
277
        } elseif (substr($row['dpath'], 0, 6) == 'skins/') {
278
          $skinName = substr($row['dpath'], 6, -1);
279
        } else {
280
          $skinName = $row['dpath'];
281
        }
282
        if ($skinName) {
283
          $skinName = db_escape($skinName);
284
          upd_do_query("UPDATE `{{users}}` SET `skin` = '{$skinName}' WHERE `id` = {$row['id']};");
285
        }
286
      }
287
    }
288
289
    upd_alter_table(
290
      'users',
291
      array(
292
        "DROP COLUMN `dpath`",
293
      ),
294
      !empty($update_tables['users']['dpath'])
295
    );
296
297
    // 2017-06-12 13:47:36 42c1
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
298
    upd_do_query('COMMIT;', true);
299
    $new_version = 42;
300
301
  case 42:
302
    upd_do_query('COMMIT;', true);
303
304
  // #ctv
305
306
//    $new_version = 43;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
307
308
}
309
upd_log_message('Upgrade complete.');
310
311
upd_do_query('SET FOREIGN_KEY_CHECKS=1;', true);
312
313
classSupernova::$cache->unset_by_prefix('lng_');
314
315
if($new_version) {
316
  $config->db_saveItem('db_version', $new_version);
317
  upd_log_message("<font color=green>DB version is now {$new_version}</font>");
318
} else {
319
  upd_log_message("DB version didn't changed from {$config->db_version}");
320
}
321
322
$config->db_loadAll();
323
/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
324
if($user['authlevel'] >= 3) {
325
  print(str_replace("\r\n", '<br>', $upd_log));
326
}
327
*/
328
classSupernova::$db->schema()->clear();
329
330
upd_log_message('Restoring server status');
331
$config->db_saveItem('game_disable', $old_server_status);
332