1 | <?php |
||||
2 | /** |
||||
3 | * Created by Gorlum 24.09.2017 18:09 |
||||
4 | */ |
||||
5 | |||||
6 | use DBAL\db_mysql; |
||||
7 | use Fleet\DbFleetStatic; |
||||
8 | use Planet\DBStaticPlanet; |
||||
9 | use Que\DBStaticQue; |
||||
10 | use Unit\DBStaticUnit; |
||||
11 | |||||
12 | /** |
||||
13 | * Class StatCalculator |
||||
14 | * |
||||
15 | * Updates player's stats |
||||
16 | */ |
||||
17 | class StatCalculator { |
||||
18 | |||||
19 | /** |
||||
20 | * @var int |
||||
21 | */ |
||||
22 | public static $memoryStart = 0; |
||||
23 | /** |
||||
24 | * @var float |
||||
25 | */ |
||||
26 | public static $timeLastOperation = 0.0; |
||||
27 | |||||
28 | public static function sta_set_time_limit($sta_update_msg = 'updating something', $next_step = true) { |
||||
29 | global $config, $debug, $sta_update_step; |
||||
30 | |||||
31 | $value = $config->stats_minimal_interval ? $config->stats_minimal_interval : STATS_RUN_INTERVAL_MINIMUM; |
||||
32 | set_time_limit($value); |
||||
33 | $config->pass()->var_stat_update_end = time() + $value; |
||||
34 | |||||
35 | $sta_update_msg = SN::$db->db_escape($sta_update_msg); |
||||
36 | |||||
37 | if ($next_step) { |
||||
38 | $sta_update_step++; |
||||
39 | } |
||||
40 | |||||
41 | $nowMicro = microtime(true); |
||||
42 | $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.\r\nMemory usage: " |
||||
43 | . number_format(memory_get_usage(true) - static::$memoryStart) |
||||
44 | . "\r\nPrevious operation time: " . number_format($nowMicro - static::$timeLastOperation, 5); |
||||
45 | |||||
46 | $config->pass()->var_stat_update_msg = $sta_update_msg; |
||||
47 | if ($next_step) { |
||||
48 | static::$timeLastOperation = $nowMicro; |
||||
0 ignored issues
–
show
|
|||||
49 | $debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
||||
50 | } |
||||
51 | } |
||||
52 | |||||
53 | public static function sys_stat_calculate_flush(&$data, $force = false) { |
||||
54 | if (count($data) < 25 && !$force) { |
||||
55 | return; |
||||
56 | } |
||||
57 | |||||
58 | if (!empty($data)) { |
||||
59 | doquery('REPLACE INTO `{{statpoints}}` |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
60 | (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`, |
||||
61 | `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`, |
||||
62 | `total_count`, `stat_date`) VALUES ' . implode(',', $data) |
||||
63 | ); |
||||
64 | } |
||||
65 | |||||
66 | $data = array(); |
||||
67 | } |
||||
68 | |||||
69 | |||||
70 | public static function sys_stat_calculate() { |
||||
71 | global $config, $sta_update_step; |
||||
72 | |||||
73 | ini_set('memory_limit', $config->stats_php_memory ? $config->stats_php_memory : '1G'); |
||||
74 | |||||
75 | static::$memoryStart = memory_get_usage(true); |
||||
76 | static::$timeLastOperation = microtime(true); |
||||
0 ignored issues
–
show
It seems like
microtime(true) can also be of type string . However, the property $timeLastOperation is declared as type double . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||||
77 | |||||
78 | $user_skip_list = sys_stat_get_user_skip_list(); |
||||
79 | |||||
80 | // $sn_groups_resources_loot = sn_get_groups('resources_loot'); |
||||
81 | $rate[RES_METAL] = $config->rpg_exchange_metal; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
82 | $rate[RES_CRYSTAL] = $config->rpg_exchange_crystal / $config->rpg_exchange_metal; |
||||
83 | $rate[RES_DEUTERIUM] = $config->rpg_exchange_deuterium / $config->rpg_exchange_metal; |
||||
84 | $rate[RES_DARK_MATTER] = $config->rpg_exchange_darkMatter / $config->rpg_exchange_metal; |
||||
85 | |||||
86 | $sta_update_step = -1; |
||||
87 | |||||
88 | static::sta_set_time_limit('starting update'); |
||||
89 | $counts = $points = $unit_cost_cache = $user_allies = array(); |
||||
90 | |||||
91 | |||||
92 | static::sta_set_time_limit('calculating players stats'); |
||||
93 | |||||
94 | db_mysql::db_transaction_start(); |
||||
95 | $i = 0; |
||||
96 | // Блокируем всех пользователей |
||||
97 | db_mysql::db_lock_tables('users'); |
||||
98 | $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id'); |
||||
0 ignored issues
–
show
The function
db_user_list() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
99 | $row_num = count($user_list); |
||||
100 | // while($player = db_fetch($query)) |
||||
101 | foreach ($user_list as $player) { |
||||
102 | if ($i++ % 100 == 0) { |
||||
103 | static::sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false); |
||||
104 | } |
||||
105 | if (array_key_exists($user_id = $player['id'], $user_skip_list)) { |
||||
106 | continue; |
||||
107 | } |
||||
108 | |||||
109 | $resources = |
||||
110 | $player['metal'] * $rate[RES_METAL] |
||||
111 | + $player['crystal'] * $rate[RES_CRYSTAL] |
||||
112 | + $player['deuterium'] * $rate[RES_DEUTERIUM] |
||||
113 | + $player['dark_matter'] * $rate[RES_DARK_MATTER]; |
||||
114 | ; |
||||
115 | $counts[$user_id][UNIT_RESOURCES] += $resources; |
||||
116 | // $points[$user_id][UNIT_RESOURCES] += $resources; |
||||
117 | |||||
118 | // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что |
||||
119 | if (!isset($user_skip_list[$user_id])) { |
||||
120 | $user_allies[$user_id] = $player['ally_id']; |
||||
121 | } |
||||
122 | } |
||||
123 | unset($user_list); |
||||
124 | DBStaticUnit::cache_clear(); |
||||
125 | |||||
126 | static::sta_set_time_limit('calculating planets stats'); |
||||
127 | $i = 0; |
||||
128 | $query = DBStaticPlanet::db_planet_list_resources_by_owner(); |
||||
129 | $row_num = SN::$db->db_num_rows($query); |
||||
130 | while ($planet = db_fetch($query)) { |
||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
131 | if ($i++ % 100 == 0) { |
||||
132 | static::sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false); |
||||
133 | } |
||||
134 | if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
||||
135 | continue; |
||||
136 | } |
||||
137 | |||||
138 | $resources = |
||||
139 | $planet['metal'] * $rate[RES_METAL] + |
||||
140 | $planet['crystal'] * $rate[RES_CRYSTAL] + |
||||
141 | $planet['deuterium'] * $rate[RES_DEUTERIUM]; |
||||
142 | $counts[$user_id][UNIT_RESOURCES] += $resources; |
||||
143 | } |
||||
144 | |||||
145 | // Calculation of Fleet-In-Flight |
||||
146 | static::sta_set_time_limit('calculating flying fleets stats'); |
||||
147 | $i = 0; |
||||
148 | $query = DbFleetStatic::db_fleet_list_query_all_stat(); |
||||
149 | $row_num = SN::$db->db_num_rows($query); |
||||
150 | while ($fleet_row = db_fetch($query)) { |
||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
151 | if ($i++ % 100 == 0) { |
||||
152 | static::sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false); |
||||
153 | } |
||||
154 | if (array_key_exists($user_id = $fleet_row['fleet_owner'], $user_skip_list)) { |
||||
155 | continue; |
||||
156 | } |
||||
157 | |||||
158 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
||||
159 | foreach ($fleet as $unit_id => $unit_amount) { |
||||
160 | $counts[$user_id][UNIT_SHIPS] += $unit_amount; |
||||
161 | |||||
162 | if (!isset($unit_cost_cache[$unit_id][0])) { |
||||
163 | $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST); |
||||
164 | } |
||||
165 | $unit_cost_data = &$unit_cost_cache[$unit_id][0]; |
||||
166 | $points[$user_id][UNIT_SHIPS] += ( |
||||
167 | $unit_cost_data[RES_METAL] * $rate[RES_METAL] + |
||||
168 | $unit_cost_data[RES_CRYSTAL] * $rate[RES_CRYSTAL] + |
||||
169 | $unit_cost_data[RES_DEUTERIUM] * $rate[RES_DEUTERIUM] |
||||
170 | ) * $unit_amount; |
||||
171 | } |
||||
172 | $resources = |
||||
173 | $fleet_row['fleet_resource_metal'] * $rate[RES_METAL] + |
||||
174 | $fleet_row['fleet_resource_crystal'] * $rate[RES_CRYSTAL] + |
||||
175 | $fleet_row['fleet_resource_deuterium'] * $rate[RES_DEUTERIUM]; |
||||
176 | |||||
177 | $counts[$user_id][UNIT_RESOURCES] += $resources; |
||||
178 | } |
||||
179 | |||||
180 | static::sta_set_time_limit('calculating ques stats'); |
||||
181 | $i = 0; |
||||
182 | $query = DBStaticQue::db_que_list_stat(); |
||||
183 | $row_num = SN::$db->db_num_rows($query); |
||||
184 | while ($que_item = db_fetch($query)) { |
||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
185 | if ($i++ % 100 == 0) { |
||||
186 | static::sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false); |
||||
187 | } |
||||
188 | if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
||||
189 | continue; |
||||
190 | } |
||||
191 | $que_unit_amount = $que_item['que_unit_amount']; |
||||
192 | $que_item = sys_unit_str2arr($que_item['que_unit_price']); |
||||
193 | $resources = ( |
||||
194 | $que_item[RES_METAL] * $rate[RES_METAL] + |
||||
195 | $que_item[RES_CRYSTAL] * $rate[RES_CRYSTAL] + |
||||
196 | $que_item[RES_DEUTERIUM] * $rate[RES_DEUTERIUM] |
||||
197 | ) * $que_unit_amount; |
||||
198 | $counts[$user_id][UNIT_RESOURCES] += $resources; |
||||
199 | } |
||||
200 | |||||
201 | static::sta_set_time_limit('calculating unit stats'); |
||||
202 | $i = 0; |
||||
203 | $query = DBStaticUnit::db_unit_list_stat_calculate(); |
||||
204 | $row_num = SN::$db->db_num_rows($query); |
||||
205 | while ($unit = db_fetch($query)) { |
||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
206 | if ($i++ % 100 == 0) { |
||||
207 | static::sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false); |
||||
208 | } |
||||
209 | if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
||||
210 | continue; |
||||
211 | } |
||||
212 | |||||
213 | $counts[$user_id][$unit['unit_type']] += $unit['unit_level'] * $unit['unit_amount']; |
||||
214 | $total_cost = eco_get_total_cost($unit['unit_snid'], $unit['unit_level']); |
||||
215 | $points[$user_id][$unit['unit_type']] += (isset($total_cost['total']) ? $total_cost['total'] : 0) * $unit['unit_amount']; |
||||
216 | } |
||||
217 | |||||
218 | static::sta_set_time_limit('archiving old statistic'); |
||||
219 | // Statistic rotation |
||||
220 | // doquery("DELETE FROM {{statpoints}} WHERE `stat_code` >= 14;"); |
||||
221 | doquery("DELETE FROM `{{statpoints}}` WHERE `stat_date` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL {$config->stats_history_days} DAY));"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
222 | doquery("UPDATE `{{statpoints}}` SET `stat_code` = `stat_code` + 1;"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
223 | |||||
224 | static::sta_set_time_limit('posting new user stats to DB'); |
||||
225 | $data = array(); |
||||
226 | foreach ($user_allies as $user_id => $ally_id) { |
||||
227 | // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000 |
||||
228 | $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000; |
||||
229 | $points[$user_id] = array_map('floor', $points[$user_id]); |
||||
230 | $counts[$user_id] = array_map('floor', $counts[$user_id]); |
||||
231 | |||||
232 | $ally_id = $ally_id ? $ally_id : 'NULL'; |
||||
233 | $user_defence_points = 0 + $points[$user_id][UNIT_DEFENCE] + $points[$user_id][UNIT_DEF_MISSILES]; |
||||
234 | $user_defence_counts = 0 + $counts[$user_id][UNIT_DEFENCE] + $counts[$user_id][UNIT_DEF_MISSILES]; |
||||
235 | $user_points = array_sum($points[$user_id]); |
||||
236 | $user_counts = array_sum($counts[$user_id]); |
||||
237 | |||||
238 | !isset($points[$user_id][UNIT_TECHNOLOGIES]) ? $points[$user_id][UNIT_TECHNOLOGIES] = 0 : false; |
||||
239 | !isset($counts[$user_id][UNIT_TECHNOLOGIES]) ? $counts[$user_id][UNIT_TECHNOLOGIES] = 0 : false; |
||||
240 | !isset($points[$user_id][UNIT_STRUCTURES]) ? $points[$user_id][UNIT_STRUCTURES] = 0 : false; |
||||
241 | !isset($counts[$user_id][UNIT_STRUCTURES]) ? $counts[$user_id][UNIT_STRUCTURES] = 0 : false; |
||||
242 | !isset($points[$user_id][UNIT_SHIPS]) ? $points[$user_id][UNIT_SHIPS] = 0 : false; |
||||
243 | !isset($counts[$user_id][UNIT_SHIPS]) ? $counts[$user_id][UNIT_SHIPS] = 0 : false; |
||||
244 | !isset($points[$user_id][UNIT_RESOURCES]) ? $points[$user_id][UNIT_RESOURCES] = 0 : false; |
||||
245 | !isset($counts[$user_id][UNIT_RESOURCES]) ? $counts[$user_id][UNIT_RESOURCES] = 0 : false; |
||||
246 | |||||
247 | $data[] = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," . |
||||
248 | "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," . |
||||
249 | "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," . |
||||
250 | "{$user_points},{$user_counts}," . SN_TIME_NOW . ")"; |
||||
251 | |||||
252 | static::sys_stat_calculate_flush($data); |
||||
253 | } |
||||
254 | static::sys_stat_calculate_flush($data, true); |
||||
255 | |||||
256 | |||||
257 | // Updating Allie's stats |
||||
258 | static::sta_set_time_limit('posting new Alliance stats to DB'); |
||||
259 | doquery( |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
260 | "INSERT INTO `{{statpoints}}` |
||||
261 | (`tech_points`, `tech_count`, `build_points`, `build_count`, `defs_points`, `defs_count`, |
||||
262 | `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`, `total_count`, |
||||
263 | `stat_date`, `id_owner`, `id_ally`, `stat_type`, `stat_code`, |
||||
264 | `tech_old_rank`, `build_old_rank`, `defs_old_rank`, `fleet_old_rank`, `res_old_rank`, `total_old_rank` |
||||
265 | ) |
||||
266 | SELECT |
||||
267 | SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`, |
||||
268 | SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`, |
||||
269 | SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`, |
||||
270 | " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1, |
||||
271 | a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank |
||||
272 | FROM `{{statpoints}}` AS u |
||||
273 | JOIN `{{alliance}}` AS al ON al.id = u.id_ally |
||||
274 | LEFT JOIN `{{statpoints}}` AS aus ON aus.id_owner = al.ally_user_id AND aus.stat_type = 1 AND aus.stat_code = 1 |
||||
275 | LEFT JOIN `{{statpoints}}` AS a ON a.id_ally = u.id_ally AND a.stat_code = 2 AND a.stat_type = 2 |
||||
276 | WHERE u.`stat_type` = 1 AND u.stat_code = 1 AND u.id_ally<>0 |
||||
277 | GROUP BY u.`id_ally`" |
||||
278 | ); |
||||
279 | |||||
280 | // Удаляем больше не нужные записи о достижении игрока-альянса |
||||
281 | db_stat_list_delete_ally_player(); |
||||
282 | |||||
283 | // Some variables we need to update ranks |
||||
284 | $qryResetRowNum = 'SET @rownum=0;'; |
||||
285 | $qryFormat = 'UPDATE `{{statpoints}}` SET `%1$s_rank` = (SELECT @rownum:=@rownum+1) WHERE `stat_type` = "%2$d" AND `stat_code` = 1 ORDER BY `%1$s_points` DESC, `id_owner` ASC, `id_ally` ASC;'; |
||||
286 | |||||
287 | $rankNames = array('tech', 'build', 'defs', 'fleet', 'res', 'total'); |
||||
288 | |||||
289 | // Updating player's ranks |
||||
290 | static::sta_set_time_limit("updating ranks for players"); |
||||
291 | foreach ($rankNames as $rankName) { |
||||
292 | static::sta_set_time_limit("updating player rank '{$rankName}'", false); |
||||
293 | doquery($qryResetRowNum); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
294 | doquery(sprintf($qryFormat, $rankName, 1)); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
295 | } |
||||
296 | |||||
297 | static::sta_set_time_limit("updating ranks for Alliances"); |
||||
298 | // --- Updating Allie's ranks |
||||
299 | foreach ($rankNames as $rankName) { |
||||
0 ignored issues
–
show
|
|||||
300 | static::sta_set_time_limit("updating Alliances rank '{$rankName}'", false); |
||||
301 | doquery($qryResetRowNum); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
302 | doquery(sprintf($qryFormat, $rankName, 2)); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
303 | } |
||||
304 | |||||
305 | static::sta_set_time_limit('setting previous user stats from archive'); |
||||
306 | doquery( |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
307 | "UPDATE `{{statpoints}}` AS new |
||||
308 | LEFT JOIN `{{statpoints}}` AS old ON old.id_owner = new.id_owner AND old.stat_code = 2 AND old.stat_type = new.stat_type |
||||
309 | SET |
||||
310 | new.tech_old_rank = old.tech_rank, |
||||
311 | new.build_old_rank = old.build_rank, |
||||
312 | new.defs_old_rank = old.defs_rank , |
||||
313 | new.fleet_old_rank = old.fleet_rank, |
||||
314 | new.res_old_rank = old.res_rank, |
||||
315 | new.total_old_rank = old.total_rank |
||||
316 | WHERE |
||||
317 | new.stat_type = 1 AND new.stat_code = 1;"); |
||||
318 | |||||
319 | static::sta_set_time_limit('setting previous allies stats from archive'); |
||||
320 | doquery( |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
321 | "UPDATE `{{statpoints}}` AS new |
||||
322 | LEFT JOIN `{{statpoints}}` AS old ON old.id_ally = new.id_ally AND old.stat_code = 2 AND old.stat_type = new.stat_type |
||||
323 | SET |
||||
324 | new.tech_old_rank = old.tech_rank, |
||||
325 | new.build_old_rank = old.build_rank, |
||||
326 | new.defs_old_rank = old.defs_rank , |
||||
327 | new.fleet_old_rank = old.fleet_rank, |
||||
328 | new.res_old_rank = old.res_rank, |
||||
329 | new.total_old_rank = old.total_rank |
||||
330 | WHERE |
||||
331 | new.stat_type = 2 AND new.stat_code = 1;"); |
||||
332 | |||||
333 | static::sta_set_time_limit('updating players current rank and points'); |
||||
334 | doquery("UPDATE `{{users}}` AS u JOIN `{{statpoints}}` AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points WHERE user_as_ally IS NULL;"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
335 | |||||
336 | static::sta_set_time_limit('updating Allys current rank and points'); |
||||
337 | doquery("UPDATE `{{alliance}}` AS a JOIN `{{statpoints}}` AS sp ON sp.id_ally = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
338 | |||||
339 | // Counting real user count and updating values |
||||
340 | dbUpdateUsersCount(db_user_count()); |
||||
341 | |||||
342 | db_mysql::db_transaction_commit(); |
||||
343 | } |
||||
344 | |||||
345 | } |
||||
346 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.