@@ -54,13 +54,17 @@ discard block |
||
54 | 54 | ); |
55 | 55 | |
56 | 56 | if (empty($subtasks)) { |
57 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
57 | + if (LOG_TASKS=== true) { |
|
58 | + $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
59 | + } |
|
58 | 60 | return; |
59 | 61 | } |
60 | 62 | |
61 | 63 | // Process each subtask |
62 | 64 | foreach ($subtasks as $subtask) { |
63 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
65 | + if (LOG_TASKS=== true) { |
|
66 | + $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
67 | + } |
|
64 | 68 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
65 | 69 | } |
66 | 70 | |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | $subtask['increment_id'] |
98 | 102 | ); |
99 | 103 | |
100 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
104 | + if (LOG_TASKS=== true) { |
|
105 | + $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
106 | + } |
|
101 | 107 | switch ($taskData['step'] ?? '') { |
102 | 108 | case 'step0': |
103 | 109 | $this->generateNewUserStep0($arguments); |
@@ -50,24 +50,24 @@ discard block |
||
50 | 50 | private function generateUserKeys($arguments) { |
51 | 51 | // Get all subtasks related to this task |
52 | 52 | $subtasks = DB::query( |
53 | - 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
53 | + 'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
54 | 54 | $this->taskId |
55 | 55 | ); |
56 | 56 | |
57 | 57 | if (empty($subtasks)) { |
58 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
58 | + if (LOG_TASKS === true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Process each subtask |
63 | 63 | foreach ($subtasks as $subtask) { |
64 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
64 | + if (LOG_TASKS === true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
65 | 65 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Are all subtasks completed? |
69 | 69 | $remainingSubtasks = DB::queryFirstField( |
70 | - 'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0', |
|
70 | + 'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0', |
|
71 | 71 | $this->taskId |
72 | 72 | ); |
73 | 73 | if ($remainingSubtasks == 0) { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $subtask['increment_id'] |
99 | 99 | ); |
100 | 100 | |
101 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
101 | + if (LOG_TASKS === true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
102 | 102 | switch ($taskData['step'] ?? '') { |
103 | 103 | case 'step0': |
104 | 104 | $this->generateNewUserStep0($arguments); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $subtask['increment_id'] |
153 | 153 | ); |
154 | 154 | |
155 | - $this->logger->log("Subtask {$subtask['increment_id']} failure: " . $e->getMessage(), 'ERROR'); |
|
155 | + $this->logger->log("Subtask {$subtask['increment_id']} failure: ".$e->getMessage(), 'ERROR'); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | // Loop on items |
187 | 187 | $rows = DB::query( |
188 | 188 | 'SELECT id, pw, perso |
189 | - FROM ' . prefixTable('items') . ' |
|
189 | + FROM ' . prefixTable('items').' |
|
190 | 190 | WHERE perso = %i |
191 | 191 | ORDER BY id ASC |
192 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'], |
|
192 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'], |
|
193 | 193 | ($arguments['only_personal_items'] ?? 0) === 1 ? 1 : 0 |
194 | 194 | ); |
195 | 195 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | // Get itemKey from current user |
198 | 198 | $currentUserKey = DB::queryFirstRow( |
199 | 199 | 'SELECT share_key, increment_id |
200 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
200 | + FROM ' . prefixTable('sharekeys_items').' |
|
201 | 201 | WHERE object_id = %i AND user_id = %i', |
202 | 202 | $record['id'], |
203 | 203 | (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id'] |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | $currentUserKey = DB::queryFirstRow( |
226 | 226 | 'SELECT increment_id |
227 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
227 | + FROM ' . prefixTable('sharekeys_items').' |
|
228 | 228 | WHERE object_id = %i AND user_id = %i', |
229 | 229 | $record['id'], |
230 | 230 | $arguments['new_user_id'] |
@@ -274,16 +274,16 @@ discard block |
||
274 | 274 | // Loop on logs |
275 | 275 | $rows = DB::query( |
276 | 276 | 'SELECT increment_id |
277 | - FROM ' . prefixTable('log_items') . ' |
|
277 | + FROM ' . prefixTable('log_items').' |
|
278 | 278 | WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes" |
279 | 279 | ORDER BY increment_id ASC |
280 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'] |
|
280 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'] |
|
281 | 281 | ); |
282 | 282 | foreach ($rows as $record) { |
283 | 283 | // Get itemKey from current user |
284 | 284 | $currentUserKey = DB::queryFirstRow( |
285 | 285 | 'SELECT share_key |
286 | - FROM ' . prefixTable('sharekeys_logs') . ' |
|
286 | + FROM ' . prefixTable('sharekeys_logs').' |
|
287 | 287 | WHERE object_id = %i AND user_id = %i', |
288 | 288 | $record['increment_id'], |
289 | 289 | $arguments['owner_id'] |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
316 | 316 | $currentUserKey = DB::queryFirstRow( |
317 | 317 | 'SELECT increment_id |
318 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
318 | + FROM ' . prefixTable('sharekeys_items').' |
|
319 | 319 | WHERE object_id = %i AND user_id = %i', |
320 | 320 | $record['id'], |
321 | 321 | $arguments['new_user_id'] |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | // Loop on fields |
357 | 357 | $rows = DB::query( |
358 | 358 | 'SELECT id |
359 | - FROM ' . prefixTable('categories_items') . ' |
|
359 | + FROM ' . prefixTable('categories_items').' |
|
360 | 360 | WHERE encryption_type = "teampass_aes" |
361 | 361 | ORDER BY id ASC |
362 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'] |
|
362 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'] |
|
363 | 363 | ); |
364 | 364 | foreach ($rows as $record) { |
365 | 365 | // Get itemKey from current user |
366 | 366 | $currentUserKey = DB::queryFirstRow( |
367 | 367 | 'SELECT share_key |
368 | - FROM ' . prefixTable('sharekeys_fields') . ' |
|
368 | + FROM ' . prefixTable('sharekeys_fields').' |
|
369 | 369 | WHERE object_id = %i AND user_id = %i', |
370 | 370 | $record['id'], |
371 | 371 | $arguments['owner_id'] |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
394 | 394 | $currentUserKey = DB::queryFirstRow( |
395 | 395 | 'SELECT increment_id |
396 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
396 | + FROM ' . prefixTable('sharekeys_items').' |
|
397 | 397 | WHERE object_id = %i AND user_id = %i', |
398 | 398 | $record['id'], |
399 | 399 | $arguments['new_user_id'] |
@@ -435,15 +435,15 @@ discard block |
||
435 | 435 | // Loop on suggestions |
436 | 436 | $rows = DB::query( |
437 | 437 | 'SELECT id |
438 | - FROM ' . prefixTable('suggestion') . ' |
|
438 | + FROM ' . prefixTable('suggestion').' |
|
439 | 439 | ORDER BY id ASC |
440 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'] |
|
440 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'] |
|
441 | 441 | ); |
442 | 442 | foreach ($rows as $record) { |
443 | 443 | // Get itemKey from current user |
444 | 444 | $currentUserKey = DB::queryFirstRow( |
445 | 445 | 'SELECT share_key |
446 | - FROM ' . prefixTable('sharekeys_suggestions') . ' |
|
446 | + FROM ' . prefixTable('sharekeys_suggestions').' |
|
447 | 447 | WHERE object_id = %i AND user_id = %i', |
448 | 448 | $record['id'], |
449 | 449 | $arguments['owner_id'] |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) { |
476 | 476 | $currentUserKey = DB::queryFirstRow( |
477 | 477 | 'SELECT increment_id |
478 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
478 | + FROM ' . prefixTable('sharekeys_items').' |
|
479 | 479 | WHERE object_id = %i AND user_id = %i', |
480 | 480 | $record['id'], |
481 | 481 | $arguments['new_user_id'] |
@@ -516,16 +516,16 @@ discard block |
||
516 | 516 | // Loop on files |
517 | 517 | $rows = DB::query( |
518 | 518 | 'SELECT f.id AS id, i.perso AS perso |
519 | - FROM ' . prefixTable('files') . ' AS f |
|
520 | - INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item |
|
521 | - WHERE f.status = "' . TP_ENCRYPTION_NAME . '" |
|
522 | - LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'] |
|
519 | + FROM ' . prefixTable('files').' AS f |
|
520 | + INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item |
|
521 | + WHERE f.status = "' . TP_ENCRYPTION_NAME.'" |
|
522 | + LIMIT ' . $taskData['index'].', '.$taskData['nb'] |
|
523 | 523 | ); //aes_encryption |
524 | 524 | foreach ($rows as $record) { |
525 | 525 | // Get itemKey from current user |
526 | 526 | $currentUserKey = DB::queryFirstRow( |
527 | 527 | 'SELECT share_key, increment_id |
528 | - FROM ' . prefixTable('sharekeys_files') . ' |
|
528 | + FROM ' . prefixTable('sharekeys_files').' |
|
529 | 529 | WHERE object_id = %i AND user_id = %i', |
530 | 530 | $record['id'], |
531 | 531 | (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id'] |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | $currentUserKey = DB::queryFirstRow( |
555 | 555 | 'SELECT increment_id |
556 | - FROM ' . prefixTable('sharekeys_files') . ' |
|
556 | + FROM ' . prefixTable('sharekeys_files').' |
|
557 | 557 | WHERE object_id = %i AND user_id = %i', |
558 | 558 | $record['id'], |
559 | 559 | $arguments['new_user_id'] |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | // get user info |
616 | 616 | $userInfo = DB::queryFirstRow( |
617 | 617 | 'SELECT email, login, auth_type, special, lastname, name |
618 | - FROM ' . prefixTable('users') . ' |
|
618 | + FROM ' . prefixTable('users').' |
|
619 | 619 | WHERE id = %i', |
620 | 620 | $arguments['new_user_id'] |
621 | 621 | ); |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS), |
631 | 631 | // @scrutinizer ignore-type |
632 | 632 | empty($arguments['email_body']) === false ? $arguments['email_body'] : $lang->get('email_body_user_config_1'), |
633 | - 'TEAMPASS - ' . $lang->get('login_credentials'), |
|
633 | + 'TEAMPASS - '.$lang->get('login_credentials'), |
|
634 | 634 | (array) filter_var_array( |
635 | 635 | [ |
636 | - '#code#' => cryption($arguments['new_user_code'], '','decrypt', $this->settings)['string'], |
|
636 | + '#code#' => cryption($arguments['new_user_code'], '', 'decrypt', $this->settings)['string'], |
|
637 | 637 | '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '', |
638 | 638 | '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '', |
639 | 639 | ], |
@@ -669,13 +669,13 @@ discard block |
||
669 | 669 | private function getOwnerInfos(int $owner_id, string $owner_pwd) { |
670 | 670 | $userInfo = DB::queryFirstRow( |
671 | 671 | 'SELECT pw, public_key, private_key, login, name |
672 | - FROM ' . prefixTable('users') . ' |
|
672 | + FROM ' . prefixTable('users').' |
|
673 | 673 | WHERE id = %i', |
674 | 674 | $owner_id |
675 | 675 | ); |
676 | 676 | |
677 | 677 | // decrypt owner password |
678 | - $pwd = cryption($owner_pwd, '','decrypt', $this->settings)['string']; |
|
678 | + $pwd = cryption($owner_pwd, '', 'decrypt', $this->settings)['string']; |
|
679 | 679 | // decrypt private key and send back |
680 | 680 | return [ |
681 | 681 | 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']), |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | trait ItemHandlerTrait { |
30 | 30 | |
31 | 31 | private function generateUserPasswordKeys($arguments) { |
32 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
32 | + if (LOG_TASKS === true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
33 | 33 | // Generate keys for user passwords |
34 | 34 | storeUsersShareKey( |
35 | 35 | prefixTable('sharekeys_items'), |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * @param array $taskData |
50 | 50 | */ |
51 | 51 | private function generateUserFileKeys($taskData) { |
52 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
53 | - foreach($taskData['files_keys'] as $file) { |
|
52 | + if (LOG_TASKS === true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
53 | + foreach ($taskData['files_keys'] as $file) { |
|
54 | 54 | storeUsersShareKey( |
55 | 55 | prefixTable('sharekeys_files'), |
56 | 56 | 0, |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @param array $arguments |
71 | 71 | */ |
72 | 72 | private function generateUserFieldKeys($arguments) { |
73 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
74 | - foreach($arguments['fields_keys'] as $field) { |
|
75 | - $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG'); |
|
73 | + if (LOG_TASKS === true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
74 | + foreach ($arguments['fields_keys'] as $field) { |
|
75 | + $this->logger->log('Processing generateUserFieldKeys for: '.$field['object_id'], 'DEBUG'); |
|
76 | 76 | storeUsersShareKey( |
77 | 77 | prefixTable('sharekeys_fields'), |
78 | 78 | 0, |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | trait ItemHandlerTrait { |
30 | 30 | |
31 | 31 | private function generateUserPasswordKeys($arguments) { |
32 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
32 | + if (LOG_TASKS=== true) { |
|
33 | + $this->logger->log('Processing generateUserPasswordKeys : '.print_r($arguments, true), 'DEBUG'); |
|
34 | + } |
|
33 | 35 | // Generate keys for user passwords |
34 | 36 | storeUsersShareKey( |
35 | 37 | prefixTable('sharekeys_items'), |
@@ -49,7 +51,9 @@ discard block |
||
49 | 51 | * @param array $taskData |
50 | 52 | */ |
51 | 53 | private function generateUserFileKeys($taskData) { |
52 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
54 | + if (LOG_TASKS=== true) { |
|
55 | + $this->logger->log('Processing generateUserFileKeys : '.print_r($taskData, true), 'DEBUG'); |
|
56 | + } |
|
53 | 57 | foreach($taskData['files_keys'] as $file) { |
54 | 58 | storeUsersShareKey( |
55 | 59 | prefixTable('sharekeys_files'), |
@@ -70,7 +74,9 @@ discard block |
||
70 | 74 | * @param array $arguments |
71 | 75 | */ |
72 | 76 | private function generateUserFieldKeys($arguments) { |
73 | - if (LOG_TASKS=== true) $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
77 | + if (LOG_TASKS=== true) { |
|
78 | + $this->logger->log('Processing generateUserFieldKeys : '.print_r($arguments, true), 'DEBUG'); |
|
79 | + } |
|
74 | 80 | foreach($arguments['fields_keys'] as $field) { |
75 | 81 | $this->logger->log('Processing generateUserFieldKeys for: ' . $field['object_id'], 'DEBUG'); |
76 | 82 | storeUsersShareKey( |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | function purgeTemporaryFiles(): void |
72 | 72 | { |
73 | 73 | // Load expected files |
74 | - require_once __DIR__. '/../sources/main.functions.php'; |
|
74 | + require_once __DIR__.'/../sources/main.functions.php'; |
|
75 | 75 | $SETTINGS = $SETTINGS ?? []; |
76 | 76 | |
77 | 77 | // $SETTINGS is set then read folder |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | //delete file FILES |
82 | 82 | while (false !== ($f = readdir($dir))) { |
83 | 83 | if ($f !== '.' && $f !== '..' && $f !== '.htaccess') { |
84 | - $filePath = $SETTINGS['path_to_files_folder'] . '/' . $f; |
|
84 | + $filePath = $SETTINGS['path_to_files_folder'].'/'.$f; |
|
85 | 85 | if (file_exists($filePath) && ((time() - filectime($filePath)) > 604800)) { |
86 | 86 | fileDelete($filePath, $SETTINGS); |
87 | 87 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | while (false !== ($f = readdir($dir))) { |
103 | 103 | if ($f !== '.' && $f !== '..') { |
104 | 104 | if (strpos($f, '_delete.') > 0) { |
105 | - fileDelete($SETTINGS['path_to_upload_folder'] . '/' . $f, $SETTINGS); |
|
105 | + fileDelete($SETTINGS['path_to_upload_folder'].'/'.$f, $SETTINGS); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | //get through all users with enabled personnal folder. |
81 | 81 | $users = DB::query( |
82 | 82 | 'SELECT id, login, email |
83 | - FROM ' . prefixTable('users') . ' |
|
83 | + FROM ' . prefixTable('users').' |
|
84 | 84 | WHERE id NOT IN ('.OTV_USER_ID.', '.TP_USER_ID.', '.SSH_USER_ID.', '.API_USER_ID.') |
85 | 85 | AND personal_folder = 1 |
86 | 86 | ORDER BY login ASC' |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | //if folder doesn't exist then create it |
90 | 90 | $data = DB::queryFirstRow( |
91 | 91 | 'SELECT id |
92 | - FROM ' . prefixTable('nested_tree') . ' |
|
92 | + FROM ' . prefixTable('nested_tree').' |
|
93 | 93 | WHERE title = %s AND parent_id = %i', |
94 | 94 | $user['id'], |
95 | 95 | 0 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // get count of Items in this folder |
73 | 73 | $get = DB::queryFirstRow( |
74 | 74 | 'SELECT count(*) as num_results |
75 | - FROM ' . prefixTable('items') . ' |
|
75 | + FROM ' . prefixTable('items').' |
|
76 | 76 | WHERE inactif = %i AND id_tree = %i', |
77 | 77 | 0, |
78 | 78 | $child->id |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | $ret[$child->id]['id'] = $child->id; |
82 | 82 | |
83 | 83 | // get number of subfolders |
84 | - $nodeDescendants =$tree->getDescendants($child->id, false, false, true); |
|
84 | + $nodeDescendants = $tree->getDescendants($child->id, false, false, true); |
|
85 | 85 | $ret[$child->id]['subfoldersCount'] = count($nodeDescendants); |
86 | 86 | |
87 | 87 | // get items number in subfolders |
88 | 88 | if (count($nodeDescendants) > 0) { |
89 | 89 | $get = DB::queryFirstRow( |
90 | 90 | 'SELECT count(*) as num_results |
91 | - FROM ' . prefixTable('items') . ' |
|
91 | + FROM ' . prefixTable('items').' |
|
92 | 92 | WHERE inactif = %i AND id_tree IN (%l)', |
93 | 93 | 0, |
94 | 94 | implode(',', $nodeDescendants) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // Get item key |
140 | 140 | $itemKey = DB::queryFirstRow( |
141 | 141 | 'SELECT share_key |
142 | - FROM ' . prefixTable('sharekeys_items') . ' |
|
142 | + FROM ' . prefixTable('sharekeys_items').' |
|
143 | 143 | WHERE user_id = %i AND object_id = %i', |
144 | 144 | TP_USER_ID, |
145 | 145 | $item['itemId'] |
@@ -73,64 +73,64 @@ |
||
73 | 73 | { |
74 | 74 | // Delete all item keys for which no user exist |
75 | 75 | DB::query( |
76 | - 'DELETE k FROM ' . prefixTable('sharekeys_items') . ' k |
|
77 | - LEFT JOIN ' . prefixTable('users') . ' u ON k.user_id = u.id |
|
76 | + 'DELETE k FROM '.prefixTable('sharekeys_items').' k |
|
77 | + LEFT JOIN ' . prefixTable('users').' u ON k.user_id = u.id |
|
78 | 78 | WHERE u.id IS NULL OR u.deleted_at IS NOT NULL' |
79 | 79 | ); |
80 | 80 | |
81 | 81 | // Delete all files keys for which no user exist |
82 | 82 | DB::query( |
83 | - 'DELETE k FROM ' . prefixTable('sharekeys_files') . ' k |
|
84 | - LEFT JOIN ' . prefixTable('users') . ' u ON k.user_id = u.id |
|
83 | + 'DELETE k FROM '.prefixTable('sharekeys_files').' k |
|
84 | + LEFT JOIN ' . prefixTable('users').' u ON k.user_id = u.id |
|
85 | 85 | WHERE u.id IS NULL OR u.deleted_at IS NOT NULL' |
86 | 86 | ); |
87 | 87 | |
88 | 88 | // Delete all fields keys for which no user exist |
89 | 89 | DB::query( |
90 | - 'DELETE k FROM ' . prefixTable('sharekeys_fields') . ' k |
|
91 | - LEFT JOIN ' . prefixTable('users') . ' u ON k.user_id = u.id |
|
90 | + 'DELETE k FROM '.prefixTable('sharekeys_fields').' k |
|
91 | + LEFT JOIN ' . prefixTable('users').' u ON k.user_id = u.id |
|
92 | 92 | WHERE u.id IS NULL OR u.deleted_at IS NOT NULL' |
93 | 93 | ); |
94 | 94 | |
95 | 95 | // Delete all item logs for which no user exist |
96 | 96 | DB::query( |
97 | - 'DELETE l FROM ' . prefixTable('log_items') . ' l |
|
98 | - LEFT JOIN ' . prefixTable('users') . ' u ON l.id_user = u.id |
|
97 | + 'DELETE l FROM '.prefixTable('log_items').' l |
|
98 | + LEFT JOIN ' . prefixTable('users').' u ON l.id_user = u.id |
|
99 | 99 | WHERE u.id IS NULL OR u.deleted_at IS NOT NULL' |
100 | 100 | ); |
101 | 101 | |
102 | 102 | // Delete all system logs for which no user exist |
103 | 103 | DB::query( |
104 | - 'DELETE l FROM ' . prefixTable('log_system') . ' l |
|
105 | - LEFT JOIN ' . prefixTable('users') . ' u ON l.qui = u.id |
|
104 | + 'DELETE l FROM '.prefixTable('log_system').' l |
|
105 | + LEFT JOIN ' . prefixTable('users').' u ON l.qui = u.id |
|
106 | 106 | WHERE u.id IS NULL OR u.deleted_at IS NOT NULL' |
107 | 107 | ); |
108 | 108 | |
109 | 109 | // Delete all item keys for which no object exist |
110 | 110 | DB::query( |
111 | - 'DELETE k FROM ' . prefixTable('sharekeys_items') . ' k |
|
112 | - LEFT JOIN ' . prefixTable('items') . ' i ON k.object_id = i.id |
|
111 | + 'DELETE k FROM '.prefixTable('sharekeys_items').' k |
|
112 | + LEFT JOIN ' . prefixTable('items').' i ON k.object_id = i.id |
|
113 | 113 | WHERE i.id IS NULL' |
114 | 114 | ); |
115 | 115 | |
116 | 116 | // Delete all files keys for which no object exist |
117 | 117 | DB::query( |
118 | - 'DELETE k FROM ' . prefixTable('sharekeys_files') . ' k |
|
119 | - LEFT JOIN ' . prefixTable('items') . ' i ON k.object_id = i.id |
|
118 | + 'DELETE k FROM '.prefixTable('sharekeys_files').' k |
|
119 | + LEFT JOIN ' . prefixTable('items').' i ON k.object_id = i.id |
|
120 | 120 | WHERE i.id IS NULL' |
121 | 121 | ); |
122 | 122 | |
123 | 123 | // Delete all fields keys for which no object exist |
124 | 124 | DB::query( |
125 | - 'DELETE k FROM ' . prefixTable('sharekeys_fields') . ' k |
|
126 | - LEFT JOIN ' . prefixTable('items') . ' i ON k.object_id = i.id |
|
125 | + 'DELETE k FROM '.prefixTable('sharekeys_fields').' k |
|
126 | + LEFT JOIN ' . prefixTable('items').' i ON k.object_id = i.id |
|
127 | 127 | WHERE i.id IS NULL' |
128 | 128 | ); |
129 | 129 | |
130 | 130 | // Delete all item logs for which no object exist |
131 | 131 | DB::query( |
132 | - 'DELETE l FROM ' . prefixTable('log_items') . ' l |
|
133 | - LEFT JOIN ' . prefixTable('items') . ' i ON l.id_item = i.id |
|
132 | + 'DELETE l FROM '.prefixTable('log_items').' l |
|
133 | + LEFT JOIN ' . prefixTable('items').' i ON l.id_item = i.id |
|
134 | 134 | WHERE i.id IS NULL' |
135 | 135 | ); |
136 | 136 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ) { |
77 | 77 | // Not allowed page |
78 | 78 | $session->set('system-error_code', ERR_NOT_ALLOWED); |
79 | - include $SETTINGS['cpassman_dir'] . '/error.php'; |
|
79 | + include $SETTINGS['cpassman_dir'].'/error.php'; |
|
80 | 80 | exit; |
81 | 81 | } |
82 | 82 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | // Output |
170 | 170 | $sOutput = '{'; |
171 | - $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
171 | + $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
172 | 172 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
173 | 173 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
174 | 174 | $sOutput .= '"aaData": '; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Output |
243 | 243 | $sOutput = '{'; |
244 | - $sOutput .= '"sEcho": '. $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
244 | + $sOutput .= '"sEcho": '.$request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
245 | 245 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
246 | 246 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
247 | 247 | $sOutput .= '"aaData": '; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | // Output |
316 | 316 | $sOutput = '{'; |
317 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
317 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
318 | 318 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
319 | 319 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
320 | 320 | $sOutput .= '"aaData": '; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | // Output |
389 | 389 | $sOutput = '{'; |
390 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
390 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
391 | 391 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
392 | 392 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
393 | 393 | $sOutput .= '"aaData": [ '; |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | // Output |
492 | 492 | $sOutput = '{'; |
493 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
493 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
494 | 494 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
495 | 495 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
496 | 496 | $sOutput .= '"aaData": [ '; |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $iTotal = 0; |
573 | 573 | } |
574 | 574 | $sOutput = '{'; |
575 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
575 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
576 | 576 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
577 | 577 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
578 | 578 | $sOutput .= '"aaData": '; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | // Output |
650 | 650 | $sOutput = '{'; |
651 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
651 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
652 | 652 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
653 | 653 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
654 | 654 | $sOutput .= '"aaData": '; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | |
718 | 718 | // Output |
719 | 719 | $sOutput = '{'; |
720 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
720 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
721 | 721 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
722 | 722 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
723 | 723 | $sOutput .= '"aaData": '; |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | |
791 | 791 | // Output |
792 | 792 | $sOutput = '{'; |
793 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
793 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
794 | 794 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
795 | 795 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
796 | 796 | $sOutput .= '"aaData": '; |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | FROM '.prefixTable('background_tasks').' AS p |
868 | 868 | LEFT JOIN '.prefixTable('users').' AS u ON %l |
869 | 869 | WHERE %l ORDER BY %l %l LIMIT %i, %i'; |
870 | - $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
870 | + $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
871 | 871 | |
872 | 872 | // Get the records |
873 | 873 | $rows = DB::query($sql, ...$params); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | |
876 | 876 | // Output |
877 | 877 | $sOutput = '{'; |
878 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
878 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
879 | 879 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
880 | 880 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
881 | 881 | $sOutput .= '"aaData": '; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | //col1 |
891 | 891 | $sOutput .= '"<span data-done=\"'.$record['is_in_progress'].'\" data-type=\"'.$record['process_type'].'\" data-process-id=\"'.$record['increment_id'].'\"></span>", '; |
892 | 892 | //col2 |
893 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
893 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
894 | 894 | //col3 |
895 | 895 | //$sOutput .= '"'.($record['updated_at'] === '' ? '-' : date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['updated_at'])).'", '; |
896 | 896 | $sOutput .= '"<div class=\"progress mt-2\"><div class=\"progress-bar\" style=\"width: '.$subtaskProgress.'\">'.$subtaskProgress.'</div></div>", '; |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | // col5 |
901 | 901 | if (in_array($record['process_type'], array('create_user_keys', 'item_copy')) === true) { |
902 | 902 | $data_user = DB::queryFirstRow( |
903 | - 'SELECT name, lastname FROM ' . prefixTable('users') . ' |
|
903 | + 'SELECT name, lastname FROM '.prefixTable('users').' |
|
904 | 904 | WHERE id = %i', |
905 | 905 | json_decode($record['arguments'], true)['new_user_id'] |
906 | 906 | ); |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | FROM '.prefixTable('background_tasks').' AS p |
957 | 957 | LEFT JOIN '.prefixTable('users').' AS u ON %l |
958 | 958 | WHERE %l ORDER BY %l %l LIMIT %i, %i'; |
959 | - $params = ['u.id = json_extract(p.arguments, "$[0]")',$sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
959 | + $params = ['u.id = json_extract(p.arguments, "$[0]")', $sWhere, $orderColumn, $orderDirection, $sLimitStart, $sLimitLength]; |
|
960 | 960 | |
961 | 961 | // Get the records |
962 | 962 | $rows = DB::query($sql, ...$params); |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | |
965 | 965 | // Output |
966 | 966 | $sOutput = '{'; |
967 | - $sOutput .= '"sEcho": '. (int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT) . ', '; |
|
967 | + $sOutput .= '"sEcho": '.(int) $request->query->filter('draw', FILTER_SANITIZE_NUMBER_INT).', '; |
|
968 | 968 | $sOutput .= '"iTotalRecords": '.$iTotal.', '; |
969 | 969 | $sOutput .= '"iTotalDisplayRecords": '.$iTotal.', '; |
970 | 970 | $sOutput .= '"aaData": '; |
@@ -980,13 +980,12 @@ discard block |
||
980 | 980 | //col1 |
981 | 981 | $sOutput .= '"'.(is_null($record['error_message']) ? '' : addslashes($record['error_message'])).'", '; |
982 | 982 | //col2 |
983 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
983 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '; |
|
984 | 984 | //col3 |
985 | 985 | $sOutput .= is_null($record['started_at']) === false ? |
986 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['started_at']).'", ') : |
|
987 | - ('"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
986 | + ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['started_at']).'", ') : ('"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['created_at']).'", '); |
|
988 | 987 | //col4 |
989 | - $sOutput .= '"'.date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
988 | + $sOutput .= '"'.date($SETTINGS['date_format'].' '.$SETTINGS['time_format'], (int) $record['finished_at']).'", '; |
|
990 | 989 | // col7 |
991 | 990 | $sOutput .= '"'.gmdate('H:i:s', (int) $record['finished_at'] - (is_null($record['started_at']) === false ? (int) $record['started_at'] : (int) $record['created_at'])).'",'; |
992 | 991 | //col5 |
@@ -1009,11 +1008,10 @@ discard block |
||
1009 | 1008 | // col6 |
1010 | 1009 | $arguments = json_decode($record['arguments'], true); |
1011 | 1010 | $newUserId = array_key_exists('new_user_id', $arguments) ? |
1012 | - $arguments['new_user_id'] : |
|
1013 | - (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null); |
|
1011 | + $arguments['new_user_id'] : (array_key_exists('user_id', $arguments) ? $arguments['user_id'] : null); |
|
1014 | 1012 | if ($record['process_type'] === 'create_user_keys' && is_null($newUserId) === false && empty($newUserId) === false) { |
1015 | 1013 | $data_user = DB::queryFirstRow( |
1016 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
1014 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
1017 | 1015 | WHERE id = %i', |
1018 | 1016 | $newUserId |
1019 | 1017 | ); |
@@ -1029,7 +1027,7 @@ discard block |
||
1029 | 1027 | } elseif ($record['process_type'] === 'user_build_cache_tree') { |
1030 | 1028 | $user = json_decode($record['arguments'], true)['user_id']; |
1031 | 1029 | $data_user = DB::queryFirstRow( |
1032 | - 'SELECT name, lastname, login FROM ' . prefixTable('users') . ' |
|
1030 | + 'SELECT name, lastname, login FROM '.prefixTable('users').' |
|
1033 | 1031 | WHERE id = %i', |
1034 | 1032 | $user |
1035 | 1033 | ); |
@@ -1063,7 +1061,7 @@ discard block |
||
1063 | 1061 | { |
1064 | 1062 | $subtasks = DB::query( |
1065 | 1063 | 'SELECT * |
1066 | - FROM ' . prefixTable('background_subtasks') . ' |
|
1064 | + FROM ' . prefixTable('background_subtasks').' |
|
1067 | 1065 | WHERE task_id = %i', |
1068 | 1066 | $id |
1069 | 1067 | ); |
@@ -1079,5 +1077,5 @@ discard block |
||
1079 | 1077 | $i++; |
1080 | 1078 | } |
1081 | 1079 | |
1082 | - return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0) .'%'; |
|
1080 | + return ($finished_nb !== 0 ? pourcentage($finished_nb, $nb, 100) : 0).'%'; |
|
1083 | 1081 | } |
1084 | 1082 | \ No newline at end of file |
@@ -47,8 +47,8 @@ |
||
47 | 47 | */ |
48 | 48 | public function log(string $message, string $level = 'INFO') { |
49 | 49 | if (!empty($this->settings['enable_tasks_log'])) { |
50 | - $formattedMessage = date($this->settings['date_format'] . ' ' . $this->settings['time_format']) . |
|
51 | - " - [$level] $message" . PHP_EOL; |
|
50 | + $formattedMessage = date($this->settings['date_format'].' '.$this->settings['time_format']). |
|
51 | + " - [$level] $message".PHP_EOL; |
|
52 | 52 | |
53 | 53 | if (!empty($this->logFile)) { |
54 | 54 | // WWrite to the specified log file |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | require_once __DIR__.'/traits/ItemHandlerTrait.php'; |
33 | 33 | require_once __DIR__.'/traits/UserHandlerTrait.php'; |
34 | 34 | require_once __DIR__.'/traits/EmailTrait.php'; |
35 | -require_once __DIR__ . '/taskLogger.php'; |
|
35 | +require_once __DIR__.'/taskLogger.php'; |
|
36 | 36 | |
37 | 37 | class TaskWorker { |
38 | 38 | use ItemHandlerTrait; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function execute() { |
66 | 66 | try { |
67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
67 | + if (LOG_TASKS === true) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG'); |
|
68 | 68 | // Dispatch selon le type de processus |
69 | 69 | switch ($this->processType) { |
70 | 70 | case 'item_copy': |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $arguments = ''; |
137 | 137 | } |
138 | 138 | |
139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
139 | + if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
140 | 140 | |
141 | 141 | // Add 'arguments' only if not empty |
142 | 142 | if (!empty($arguments)) { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'increment_id = %i', |
151 | 151 | $this->taskId |
152 | 152 | ); |
153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
153 | + if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'increment_id = %i', |
174 | 174 | $this->taskId |
175 | 175 | ); |
176 | - $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR'); |
|
176 | + $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | * @return void |
186 | 186 | */ |
187 | 187 | private function processSubTasks($arguments) { |
188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
188 | + if (LOG_TASKS === true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
189 | 189 | // Get all subtasks related to this task |
190 | 190 | $subtasks = DB::query( |
191 | - 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
191 | + 'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
|
192 | 192 | $this->taskId |
193 | 193 | ); |
194 | 194 | |
195 | 195 | // Check if there are any subtasks to process |
196 | 196 | if (empty($subtasks)) { |
197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
197 | + if (LOG_TASKS === true) $this->logger->log('No subtask was found for task: '.$this->taskId, 'DEBUG'); |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | // Get the subtask data |
205 | 205 | $subtaskData = json_decode($subtask['task'], true); |
206 | 206 | |
207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
207 | + if (LOG_TASKS === true) $this->logger->log('Processing subtask: '.$subtaskData['step'], 'DEBUG'); |
|
208 | 208 | |
209 | 209 | // Process the subtask based on its type |
210 | 210 | switch ($subtaskData['step'] ?? '') { |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | $subtask['increment_id'] |
249 | 249 | ); |
250 | 250 | |
251 | - $this->logger->log('processSubTasks : ' . $e->getMessage(), 'ERROR'); |
|
251 | + $this->logger->log('processSubTasks : '.$e->getMessage(), 'ERROR'); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Are all subtasks completed? |
256 | 256 | $remainingSubtasks = DB::queryFirstField( |
257 | - 'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0', |
|
257 | + 'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0', |
|
258 | 258 | $this->taskId |
259 | 259 | ); |
260 | 260 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | error_log("Usage: php background_tasks___worker.php <task_id> <process_type> [<task_data>]"); |
271 | 271 | exit(1); |
272 | 272 | } |
273 | -$taskId = (int)$argv[1]; |
|
273 | +$taskId = (int) $argv[1]; |
|
274 | 274 | $processType = $argv[2]; |
275 | 275 | $taskData = $argv[3] ?? null; |
276 | 276 | if ($taskData) { |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function execute() { |
66 | 66 | try { |
67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
67 | + if (LOG_TASKS=== true) { |
|
68 | + $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
69 | + } |
|
68 | 70 | // Dispatch selon le type de processus |
69 | 71 | switch ($this->processType) { |
70 | 72 | case 'item_copy': |
@@ -136,7 +138,9 @@ discard block |
||
136 | 138 | $arguments = ''; |
137 | 139 | } |
138 | 140 | |
139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
141 | + if (LOG_TASKS=== true) { |
|
142 | + $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
143 | + } |
|
140 | 144 | |
141 | 145 | // Add 'arguments' only if not empty |
142 | 146 | if (!empty($arguments)) { |
@@ -150,7 +154,9 @@ discard block |
||
150 | 154 | 'increment_id = %i', |
151 | 155 | $this->taskId |
152 | 156 | ); |
153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
157 | + if (LOG_TASKS=== true) { |
|
158 | + $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
159 | + } |
|
154 | 160 | } |
155 | 161 | |
156 | 162 | /** |
@@ -185,7 +191,9 @@ discard block |
||
185 | 191 | * @return void |
186 | 192 | */ |
187 | 193 | private function processSubTasks($arguments) { |
188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
194 | + if (LOG_TASKS=== true) { |
|
195 | + $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
196 | + } |
|
189 | 197 | // Get all subtasks related to this task |
190 | 198 | $subtasks = DB::query( |
191 | 199 | 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
@@ -194,7 +202,9 @@ discard block |
||
194 | 202 | |
195 | 203 | // Check if there are any subtasks to process |
196 | 204 | if (empty($subtasks)) { |
197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
205 | + if (LOG_TASKS=== true) { |
|
206 | + $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
207 | + } |
|
198 | 208 | return; |
199 | 209 | } |
200 | 210 | |
@@ -204,7 +214,9 @@ discard block |
||
204 | 214 | // Get the subtask data |
205 | 215 | $subtaskData = json_decode($subtask['task'], true); |
206 | 216 | |
207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
217 | + if (LOG_TASKS=== true) { |
|
218 | + $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
219 | + } |
|
208 | 220 | |
209 | 221 | // Process the subtask based on its type |
210 | 222 | switch ($subtaskData['step'] ?? '') { |