Passed
Pull Request — master (#4682)
by Nils
06:11
created
pages/import.js.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 if ($checkUserAccess->checkSession() === false || $checkUserAccess->userAccessPage('import') === false) {
73 73
     // Not allowed page
74 74
     $session->set('system-error_code', ERR_NOT_ALLOWED);
75
-    include $SETTINGS['cpassman_dir'] . '/error.php';
75
+    include $SETTINGS['cpassman_dir'].'/error.php';
76 76
     exit;
77 77
 }
78 78
 ?>
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
                                     // Isolate first item
1044 1044
                                     if (itemsList.length > 0) {
1045 1045
                                         $('#import-feedback-progress-text')
1046
-                                            .html('<i class="fa-solid fa-cog fa-spin ml-4 mr-2"></i><?php echo $lang->get('operation_progress');?> ('+((counter*100)/itemsNumber).toFixed(2)+'%) - <i id="item-title"></i>');
1046
+                                            .html('<i class="fa-solid fa-cog fa-spin ml-4 mr-2"></i><?php echo $lang->get('operation_progress'); ?> ('+((counter*100)/itemsNumber).toFixed(2)+'%) - <i id="item-title"></i>');
1047 1047
 
1048 1048
                                         // XSS Filtering :
1049 1049
                                         $('#import-feedback-progress-text').text(itemsList[0].Title);
Please login to merge, or discard this patch.
includes/language/english.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
  * @see       https://www.teampass.net
29 29
  */
30 30
 
31
- // TO REMOVE
32
- // - selected_items_to_be_imported
31
+    // TO REMOVE
32
+    // - selected_items_to_be_imported
33 33
 
34 34
 return array(
35 35
     'import_csv_keys_generation_strategy' => 'Keys generation strategy',
Please login to merge, or discard this patch.
_things/delete_background_tasks___sending_emails.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 $emailService = new EmailService();
71 71
 $rows = DB::query(
72 72
     'SELECT *
73
-    FROM ' . prefixTable('background_tasks') . '
73
+    FROM ' . prefixTable('background_tasks').'
74 74
     WHERE is_in_progress = %i AND process_type = %s
75 75
     ORDER BY increment_id ASC LIMIT 0,10',
76 76
     0,
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     
139 139
     //if ((int) $SETTINGS['enable_backlog_mail'] === 1) {
140 140
         $row = DB::queryFirstRow(
141
-            'SELECT valeur FROM ' . prefixTable('misc') . ' WHERE type = %s AND intitule = %s',
141
+            'SELECT valeur FROM '.prefixTable('misc').' WHERE type = %s AND intitule = %s',
142 142
             'cron',
143 143
             'sending_emails'
144 144
         );
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         if ((int) (time() - $row['valeur']) >= 300 || (int) $row['valeur'] === 0) {
147 147
             $rows = DB::query(
148 148
                 'SELECT *
149
-                FROM ' . prefixTable('emails') .
149
+                FROM ' . prefixTable('emails').
150 150
                 ' WHERE status != %s',
151 151
                 'sent'
152 152
             );
Please login to merge, or discard this patch.
_things/delete_background_tasks___userKeysCreation_subtaskHdl.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 DB::update(
123 123
     prefixTable('background_subtasks'),
124 124
     array(
125
-        'sub_task_in_progress' => 0,    // flag sub task is no more in prgoress
125
+        'sub_task_in_progress' => 0, // flag sub task is no more in prgoress
126 126
         'is_in_progress' => 0,
127 127
         'finished_at' => time(),
128 128
         'updated_at' => time(),
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // Check if user exists
159 159
         $userInfo = DB::queryFirstRow(
160 160
             'SELECT public_key, private_key
161
-            FROM ' . prefixTable('users') . '
161
+            FROM ' . prefixTable('users').'
162 162
             WHERE id = %i',
163 163
             $post_user_id
164 164
         );
@@ -271,13 +271,13 @@  discard block
 block discarded – undo
271 271
 {
272 272
     $userInfo = DB::queryFirstRow(
273 273
         'SELECT pw, public_key, private_key, login, name
274
-        FROM ' . prefixTable('users') . '
274
+        FROM ' . prefixTable('users').'
275 275
         WHERE id = %i',
276 276
         $owner_id
277 277
     );
278 278
     
279 279
     // decrypt owner password
280
-    $pwd = cryption($owner_pwd, '','decrypt', $SETTINGS)['string'];
280
+    $pwd = cryption($owner_pwd, '', 'decrypt', $SETTINGS)['string'];
281 281
     // decrypt private key and send back
282 282
     return [
283 283
         'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']),
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
     // Loop on items
318 318
     $rows = DB::query(
319 319
         'SELECT id, pw, perso
320
-        FROM ' . prefixTable('items') . '
320
+        FROM ' . prefixTable('items').'
321 321
         WHERE perso =  %i
322 322
         ORDER BY id ASC
323
-        LIMIT ' . $post_start . ', ' . $post_length,
323
+        LIMIT ' . $post_start.', '.$post_length,
324 324
         ($extra_arguments['only_personal_items'] ?? 0) === 1 ? 1 : 0
325 325
     );
326 326
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         // Get itemKey from current user
329 329
         $currentUserKey = DB::queryFirstRow(
330 330
             'SELECT share_key, increment_id
331
-            FROM ' . prefixTable('sharekeys_items') . '
331
+            FROM ' . prefixTable('sharekeys_items').'
332 332
             WHERE object_id = %i AND user_id = %i',
333 333
             $record['id'],
334 334
             (int) $record['perso'] === 0 ? $extra_arguments['owner_id'] : $extra_arguments['new_user_id']
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         
356 356
         $currentUserKey = DB::queryFirstRow(
357 357
             'SELECT increment_id
358
-            FROM ' . prefixTable('sharekeys_items') . '
358
+            FROM ' . prefixTable('sharekeys_items').'
359 359
             WHERE object_id = %i AND user_id = %i',
360 360
             $record['id'],
361 361
             $post_user_id
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
     // Loop on logs
430 430
     $rows = DB::query(
431 431
         'SELECT increment_id
432
-        FROM ' . prefixTable('log_items') . '
432
+        FROM ' . prefixTable('log_items').'
433 433
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
434
-        LIMIT ' . $post_start . ', ' . $post_length
434
+        LIMIT ' . $post_start.', '.$post_length
435 435
     );
436 436
     foreach ($rows as $record) {
437 437
         // Get itemKey from current user
438 438
         $currentUserKey = DB::queryFirstRow(
439 439
             'SELECT share_key
440
-            FROM ' . prefixTable('sharekeys_logs') . '
440
+            FROM ' . prefixTable('sharekeys_logs').'
441 441
             WHERE object_id = %i AND user_id = %i',
442 442
             $record['increment_id'],
443 443
             $extra_arguments['owner_id']
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
             if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
470 470
                 $currentUserKey = DB::queryFirstRow(
471 471
                     'SELECT increment_id
472
-                    FROM ' . prefixTable('sharekeys_items') . '
472
+                    FROM ' . prefixTable('sharekeys_items').'
473 473
                     WHERE object_id = %i AND user_id = %i',
474 474
                     $record['id'],
475 475
                     $post_user_id
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
     // SHould we change step?
492 492
     DB::query(
493 493
         'SELECT increment_id
494
-        FROM ' . prefixTable('log_items') . '
494
+        FROM ' . prefixTable('log_items').'
495 495
         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
496 496
     );
497 497
 
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
     // Loop on fields
532 532
     $rows = DB::query(
533 533
         'SELECT id
534
-        FROM ' . prefixTable('categories_items') . '
534
+        FROM ' . prefixTable('categories_items').'
535 535
         WHERE encryption_type = "teampass_aes"
536
-        LIMIT ' . $post_start . ', ' . $post_length
536
+        LIMIT ' . $post_start.', '.$post_length
537 537
     );
538 538
     foreach ($rows as $record) {
539 539
         // Get itemKey from current user
540 540
         $currentUserKey = DB::queryFirstRow(
541 541
             'SELECT share_key
542
-            FROM ' . prefixTable('sharekeys_fields') . '
542
+            FROM ' . prefixTable('sharekeys_fields').'
543 543
             WHERE object_id = %i AND user_id = %i',
544 544
             $record['id'],
545 545
             $extra_arguments['owner_id']
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
                 if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
568 568
                     $currentUserKey = DB::queryFirstRow(
569 569
                         'SELECT increment_id
570
-                        FROM ' . prefixTable('sharekeys_items') . '
570
+                        FROM ' . prefixTable('sharekeys_items').'
571 571
                         WHERE object_id = %i AND user_id = %i',
572 572
                         $record['id'],
573 573
                         $post_user_id
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     // SHould we change step?
591 591
     DB::query(
592 592
         'SELECT *
593
-        FROM ' . prefixTable('categories_items') . '
593
+        FROM ' . prefixTable('categories_items').'
594 594
         WHERE encryption_type = "teampass_aes"'
595 595
     );
596 596
 
@@ -630,14 +630,14 @@  discard block
 block discarded – undo
630 630
     // Loop on suggestions
631 631
     $rows = DB::query(
632 632
         'SELECT id
633
-        FROM ' . prefixTable('suggestion') . '
634
-        LIMIT ' . $post_start . ', ' . $post_length
633
+        FROM ' . prefixTable('suggestion').'
634
+        LIMIT ' . $post_start.', '.$post_length
635 635
     );
636 636
     foreach ($rows as $record) {
637 637
         // Get itemKey from current user
638 638
         $currentUserKey = DB::queryFirstRow(
639 639
             'SELECT share_key
640
-            FROM ' . prefixTable('sharekeys_suggestions') . '
640
+            FROM ' . prefixTable('sharekeys_suggestions').'
641 641
             WHERE object_id = %i AND user_id = %i',
642 642
             $record['id'],
643 643
             $extra_arguments['owner_id']
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
             if ((int) $post_user_id !== (int) $extra_arguments['owner_id']) {
670 670
                 $currentUserKey = DB::queryFirstRow(
671 671
                     'SELECT increment_id
672
-                    FROM ' . prefixTable('sharekeys_items') . '
672
+                    FROM ' . prefixTable('sharekeys_items').'
673 673
                     WHERE object_id = %i AND user_id = %i',
674 674
                     $record['id'],
675 675
                     $post_user_id
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
     // Loop on files
730 730
     $rows = DB::query(
731 731
         'SELECT f.id AS id, i.perso AS perso
732
-        FROM ' . prefixTable('files') . ' AS f
733
-        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
734
-        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"
735
-        LIMIT ' . $post_start . ', ' . $post_length
732
+        FROM ' . prefixTable('files').' AS f
733
+        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
734
+        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"
735
+        LIMIT ' . $post_start.', '.$post_length
736 736
     ); //aes_encryption
737 737
     foreach ($rows as $record) {
738 738
         // Get itemKey from current user
739 739
         $currentUserKey = DB::queryFirstRow(
740 740
             'SELECT share_key, increment_id
741
-            FROM ' . prefixTable('sharekeys_files') . '
741
+            FROM ' . prefixTable('sharekeys_files').'
742 742
             WHERE object_id = %i AND user_id = %i',
743 743
             $record['id'],
744 744
             (int) $record['perso'] === 0 ? $extra_arguments['owner_id'] : $extra_arguments['new_user_id']
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 
767 767
         $currentUserKey = DB::queryFirstRow(
768 768
             'SELECT increment_id
769
-            FROM ' . prefixTable('sharekeys_files') . '
769
+            FROM ' . prefixTable('sharekeys_files').'
770 770
             WHERE object_id = %i AND user_id = %i',
771 771
             $record['id'],
772 772
             $post_user_id
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
     // SHould we change step? Finished ?
798 798
     DB::query(
799 799
         'SELECT *
800
-        FROM ' . prefixTable('files') . '
801
-        WHERE status = "' . TP_ENCRYPTION_NAME . '"'
800
+        FROM ' . prefixTable('files').'
801
+        WHERE status = "' . TP_ENCRYPTION_NAME.'"'
802 802
     );
803 803
     $counter = DB::count();
804 804
     $next_start = (int) $post_start + (int) $post_length;
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
     // get user info
865 865
     $userInfo = DB::queryFirstRow(
866 866
         'SELECT email, login, auth_type, special, lastname, name
867
-        FROM ' . prefixTable('users') . '
867
+        FROM ' . prefixTable('users').'
868 868
         WHERE id = %i',
869 869
         $extra_arguments['new_user_id']
870 870
     );
@@ -879,10 +879,10 @@  discard block
 block discarded – undo
879 879
             filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS),
880 880
             // @scrutinizer ignore-type
881 881
             empty($extra_arguments['email_body']) === false ? $extra_arguments['email_body'] : $lang->get('email_body_user_config_1'),
882
-            'TEAMPASS - ' . $lang->get('login_credentials'),
882
+            'TEAMPASS - '.$lang->get('login_credentials'),
883 883
             (array) filter_var_array(
884 884
                 [
885
-                    '#code#' => cryption($extra_arguments['new_user_code'], '','decrypt', $SETTINGS)['string'],
885
+                    '#code#' => cryption($extra_arguments['new_user_code'], '', 'decrypt', $SETTINGS)['string'],
886 886
                     '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '',
887 887
                     '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '',
888 888
                 ],
Please login to merge, or discard this patch.
_things/delete_background_tasks___items_handler.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 DB::debugmode(false);
76 76
 $process_to_perform = DB::queryFirstRow(
77 77
     'SELECT *
78
-    FROM ' . prefixTable('background_tasks') . '
78
+    FROM ' . prefixTable('background_tasks').'
79 79
     WHERE is_in_progress = %i AND process_type IN ("item_copy", "new_item", "update_item", "item_update_create_keys")
80 80
     ORDER BY increment_id ASC',
81 81
     1
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     // search for next process to handle
94 94
     $process_to_perform = DB::queryFirstRow(
95 95
         'SELECT *
96
-        FROM ' . prefixTable('background_tasks') . '
96
+        FROM ' . prefixTable('background_tasks').'
97 97
         WHERE is_in_progress = %i AND (finished_at = "" OR finished_at IS NULL) AND process_type IN ("item_copy", "new_item", "update_item", "item_update_create_keys")
98 98
         ORDER BY increment_id ASC',
99 99
         0
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             $process_to_perform['increment_id']
112 112
         );
113 113
 
114
-        provideLog('[PROCESS][#'. $process_to_perform['increment_id'].'][START]', $SETTINGS);
114
+        provideLog('[PROCESS][#'.$process_to_perform['increment_id'].'][START]', $SETTINGS);
115 115
         handleTask(
116 116
             $process_to_perform['increment_id'],
117 117
             json_decode($process_to_perform['arguments'], true),
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         // Search if there are remaining tasks
147 147
         $process_to_perform = DB::queryFirstField(
148 148
             'SELECT 1
149
-            FROM ' . prefixTable('background_tasks') . '
149
+            FROM ' . prefixTable('background_tasks').'
150 150
             WHERE is_in_progress = %i AND process_type IN (
151 151
                 "item_copy",
152 152
                 "new_item",
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
  */
186 186
 function handleTask(int $processId, array $ProcessArguments, array $SETTINGS, int $itemId = null): bool
187 187
 {
188
-    provideLog('[PROCESS][#'. $processId.'][START]', $SETTINGS);
188
+    provideLog('[PROCESS][#'.$processId.'][START]', $SETTINGS);
189 189
     $task_to_perform = DB::queryFirstRow(
190 190
         'SELECT *
191
-        FROM ' . prefixTable('background_subtasks') . '
191
+        FROM ' . prefixTable('background_subtasks').'
192 192
         WHERE task_id = %i AND finished_at IS NULL
193 193
         ORDER BY increment_id ASC',
194 194
         $processId
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
         // if sub_task_in_progress === 1 then exit
203 203
         if ((int) $task_to_perform['sub_task_in_progress'] !== 0) {
204 204
             // Task is currently being in progress by another server process
205
-            provideLog('[TASK][#'. $task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
205
+            provideLog('[TASK][#'.$task_to_perform['increment_id'].'][WARNING] Similar task already being processes', $SETTINGS);
206 206
             return false;
207 207
         }
208 208
 
209 209
         // handle next task
210 210
         $args = json_decode($task_to_perform['task'], true);
211
-        provideLog('[TASK][#'. $task_to_perform['increment_id'].'][START]Task '.$args['step'], $SETTINGS);
211
+        provideLog('[TASK][#'.$task_to_perform['increment_id'].'][START]Task '.$args['step'], $SETTINGS);
212 212
 
213 213
         // flag as in progress
214 214
         DB::update(
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         DB::update(
251 251
             prefixTable('background_subtasks'),
252 252
             array(
253
-                'sub_task_in_progress' => 0,    // flag sub task is no more in prgoress
253
+                'sub_task_in_progress' => 0, // flag sub task is no more in prgoress
254 254
                 'task' => json_encode(["status" => "Done"]),
255 255
                 'is_in_progress' => -1,
256 256
                 'finished_at' => time(),
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         // are all tasks done?
266 266
         DB::query(
267 267
             'SELECT *
268
-            FROM ' . prefixTable('background_subtasks') . '
268
+            FROM ' . prefixTable('background_subtasks').'
269 269
             WHERE task_id = %i AND finished_at IS NULL',
270 270
             $processId
271 271
         );
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         // Loop on all files for this item
338 338
         // and encrypt them for each user
339 339
         if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
340
-        foreach($args['files_keys'] as $file) {
340
+        foreach ($args['files_keys'] as $file) {
341 341
             storeUsersShareKey(
342 342
                 prefixTable('sharekeys_items'),
343 343
                 0,
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         // Loop on all encrypted fields for this item
354 354
         // and encrypt them for each user
355 355
         if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
356
-        foreach($args['fields_keys'] as $field) {
356
+        foreach ($args['fields_keys'] as $field) {
357 357
             storeUsersShareKey(
358 358
                 prefixTable('sharekeys_fields'),
359 359
                 0,
@@ -405,6 +405,6 @@  discard block
 block discarded – undo
405 405
     DB::query(
406 406
         'DELETE FROM '.prefixTable('items_edition').'
407 407
         WHERE timestamp < %i',
408
-        ($SETTINGS['delay_item_edition'] > 0) ? time() - ($SETTINGS['delay_item_edition']*60) : time() - EDITION_LOCK_PERIOD
408
+        ($SETTINGS['delay_item_edition'] > 0) ? time() - ($SETTINGS['delay_item_edition'] * 60) : time() - EDITION_LOCK_PERIOD
409 409
     );
410 410
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,7 +83,9 @@  discard block
 block discarded – undo
83 83
 
84 84
 if (DB::count() > 0) {
85 85
     // handle tasks inside this process
86
-    if (WIP === true) error_log("Process in progress: ".$process_to_perform['increment_id']);
86
+    if (WIP === true) {
87
+        error_log("Process in progress: ".$process_to_perform['increment_id']);
88
+    }
87 89
     handleTask(
88 90
         $process_to_perform['increment_id'],
89 91
         json_decode($process_to_perform['arguments'], true),
@@ -100,7 +102,9 @@  discard block
 block discarded – undo
100 102
     );
101 103
     
102 104
     if (DB::count() > 0) {
103
-        if (WIP === true) error_log("New process ta start: ".$process_to_perform['increment_id']);
105
+        if (WIP === true) {
106
+            error_log("New process ta start: ".$process_to_perform['increment_id']);
107
+        }
104 108
         // update DB - started_at
105 109
         DB::update(
106 110
             prefixTable('background_tasks'),
@@ -153,8 +157,9 @@  discard block
 block discarded – undo
153 157
         );
154 158
 
155 159
         // No more tasks, exit
156
-        if ($process_to_perform !== 1)
157
-            break;
160
+        if ($process_to_perform !== 1) {
161
+                    break;
162
+        }
158 163
 
159 164
         // Run next task
160 165
         $process = new Symfony\Component\Process\Process([
@@ -331,7 +336,9 @@  discard block
 block discarded – undo
331 336
     if ($args['step'] === 'create_users_files_key') {
332 337
         // Loop on all files for this item
333 338
         // and encrypt them for each user
334
-        if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
339
+        if (WIP === true) {
340
+            provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
341
+        }
335 342
         foreach($args['files_keys'] as $file) {
336 343
             storeUsersShareKey(
337 344
                 prefixTable('sharekeys_items'),
@@ -347,7 +354,9 @@  discard block
 block discarded – undo
347 354
     } elseif ($args['step'] === 'create_users_fields_key') {
348 355
         // Loop on all encrypted fields for this item
349 356
         // and encrypt them for each user
350
-        if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
357
+        if (WIP === true) {
358
+            provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
359
+        }
351 360
         foreach($args['fields_keys'] as $field) {
352 361
             storeUsersShareKey(
353 362
                 prefixTable('sharekeys_fields'),
Please login to merge, or discard this patch.
_things/delete_background_tasks___userKeysCreation.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 $processToPerform = DB::queryfirstrow(
69 69
     'SELECT *
70
-    FROM ' . prefixTable('background_tasks') . '
70
+    FROM ' . prefixTable('background_tasks').'
71 71
     WHERE (finished_at IS NULL OR finished_at = "") AND process_type = %s
72 72
     ORDER BY increment_id ASC',
73 73
     'create_user_keys'
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     // Check if subtasks are still running
85 85
     // This in order to prevent the script from running multiple times on same objects
86 86
     while (DB::queryFirstField(
87
-        'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' 
87
+        'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' 
88 88
         WHERE is_in_progress = 1'
89 89
     ) > 0) {
90 90
         sleep(10); // Wait 10 seconds before continuing
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $subTaskParams = json_decode($subTask['task'], true);
118 118
 
119 119
             if (WIP === true) {
120
-                error_log('Subtask in progress: '.$subTask['increment_id']." (".$taskId.") - "./** @scrutinizer ignore-type */ print_r($subTaskParams,true));
120
+                error_log('Subtask in progress: '.$subTask['increment_id']." (".$taskId.") - "./** @scrutinizer ignore-type */ print_r($subTaskParams, true));
121 121
             }
122 122
             
123 123
             // Build all subtasks if first one
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                     // Get total number of items
127 127
                     DB::query(
128 128
                         'SELECT *
129
-                        FROM ' . prefixTable('items') . '
129
+                        FROM ' . prefixTable('items').'
130 130
                         '.(isset($taskArgumentsArray['only_personal_items']) === true && $taskArgumentsArray['only_personal_items'] === 1 ? 'WHERE perso = 1' : '')
131 131
                     );
132 132
                     createAllSubTasks($subTaskParams['step'], DB::count(), $subTaskParams['nb'], $taskId);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                     // Get total number of items
136 136
                     DB::query(
137 137
                         'SELECT *
138
-                        FROM ' . prefixTable('log_items') . '
138
+                        FROM ' . prefixTable('log_items').'
139 139
                         WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"'
140 140
                     );
141 141
                     createAllSubTasks($subTaskParams['step'], DB::count(), $subTaskParams['nb'], $taskId);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                     // Get total number of items
145 145
                     DB::query(
146 146
                         'SELECT *
147
-                        FROM ' . prefixTable('categories_items') . '
147
+                        FROM ' . prefixTable('categories_items').'
148 148
                         WHERE encryption_type = "teampass_aes"'
149 149
                     );
150 150
                     createAllSubTasks($subTaskParams['step'], DB::count(), $subTaskParams['nb'], $taskId);
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
                     // Get total number of items
162 162
                     DB::query(
163 163
                         'SELECT *
164
-                        FROM ' . prefixTable('files') . ' AS f
165
-                        INNER JOIN ' . prefixTable('items') . ' AS i ON i.id = f.id_item
166
-                        WHERE f.status = "' . TP_ENCRYPTION_NAME . '"'
164
+                        FROM ' . prefixTable('files').' AS f
165
+                        INNER JOIN ' . prefixTable('items').' AS i ON i.id = f.id_item
166
+                        WHERE f.status = "' . TP_ENCRYPTION_NAME.'"'
167 167
                     );
168 168
                     createAllSubTasks($subTaskParams['step'], DB::count(), $subTaskParams['nb'], $taskId);
169 169
                 }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     // Check if subtasks have to be created
191 191
     DB::query(
192 192
         'SELECT *
193
-        FROM ' . prefixTable('background_subtasks') . '
193
+        FROM ' . prefixTable('background_subtasks').'
194 194
         WHERE task_id = %i AND task LIKE %ss',
195 195
         $taskId,
196 196
         $action
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 function countActiveSymfonyProcesses() {
219 219
     // Count the number of active processes
220 220
     return DB::queryFirstField(
221
-        'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . 
221
+        'SELECT COUNT(*) FROM '.prefixTable('background_subtasks'). 
222 222
         ' WHERE process_id IS NOT NULL AND finished_at IS NULL'
223 223
     );
224 224
 }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 function getSubTasks($taskId) {
230 230
     $task_to_perform = DB::query(
231 231
         'SELECT *
232
-        FROM ' . prefixTable('background_subtasks') . '
232
+        FROM ' . prefixTable('background_subtasks').'
233 233
         WHERE task_id = %i AND finished_at IS NULL
234 234
         ORDER BY increment_id ASC',
235 235
         $taskId
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 function reloadSubTask($subTaskId) {
279 279
     // Retrieve subtask information from the database
280 280
     $subTask = DB::queryFirstRow(
281
-        'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE increment_id = %i', 
281
+        'SELECT * FROM '.prefixTable('background_subtasks').' WHERE increment_id = %i', 
282 282
         $subTaskId
283 283
     );
284 284
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     // Get all processes
324 324
     $subtasks = DB::query(
325 325
         'SELECT *
326
-        FROM ' . prefixTable('background_subtasks') . '
326
+        FROM ' . prefixTable('background_subtasks').'
327 327
         WHERE process_id IS NOT NULL AND finished_at IS NULL'
328 328
     );
329 329
 
Please login to merge, or discard this patch.
_things/delete_bck_tasks___supervisor.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     private function cleanStaleProcesses() {
28 28
         // Marquer les processus bloqués depuis plus de 30 minutes
29 29
         $this->db->query(
30
-            'UPDATE ' . prefixTable('background_tasks') . ' 
30
+            'UPDATE '.prefixTable('background_tasks').' 
31 31
             SET is_in_progress = -1, 
32 32
                 status = "stale"
33 33
             WHERE is_in_progress = 1 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         // Relancer les tâches marquées comme "stale"
41 41
         $staleTasks = $this->db->query(
42 42
             'SELECT increment_id, process_type, arguments 
43
-            FROM ' . prefixTable('background_tasks') . '
43
+            FROM ' . prefixTable('background_tasks').'
44 44
             WHERE status = "stale"
45 45
             LIMIT 10'  // Limiter à 10 pour éviter une surcharge
46 46
         );
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
     private function logTaskStatistics() {
63 63
         $stats = [
64 64
             'total_tasks' => $this->db->queryFirstField(
65
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks')
65
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks')
66 66
             ),
67 67
             'pending_tasks' => $this->db->queryFirstField(
68
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' WHERE is_in_progress = 0'
68
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks').' WHERE is_in_progress = 0'
69 69
             ),
70 70
             'running_tasks' => $this->db->queryFirstField(
71
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' WHERE is_in_progress = 1'
71
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks').' WHERE is_in_progress = 1'
72 72
             ),
73 73
             'completed_tasks' => $this->db->queryFirstField(
74
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' WHERE is_in_progress = -1 AND status = "completed"'
74
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks').' WHERE is_in_progress = -1 AND status = "completed"'
75 75
             ),
76 76
             'failed_tasks' => $this->db->queryFirstField(
77
-                'SELECT COUNT(*) FROM ' . prefixTable('background_tasks') . ' WHERE is_in_progress = -1 AND status = "failed"'
77
+                'SELECT COUNT(*) FROM '.prefixTable('background_tasks').' WHERE is_in_progress = -1 AND status = "failed"'
78 78
             )
79 79
         ];
80 80
 
81 81
         // Log ou stocker ces statistiques selon votre configuration
82
-        error_log('Teampass Task Statistics: ' . json_encode($stats));
82
+        error_log('Teampass Task Statistics: '.json_encode($stats));
83 83
     }
84 84
 }
85 85
 
Please login to merge, or discard this patch.
_things/delete_background_tasks___user_task.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
     // launched several times.
70 70
     $record = DB::queryFirstRow(
71 71
         'SELECT *
72
-        FROM ' . prefixTable('background_tasks') . '
72
+        FROM ' . prefixTable('background_tasks').'
73 73
         WHERE is_in_progress = %i AND process_type = %s
74 74
         ORDER BY increment_id ASC LIMIT 1',
75 75
         0,
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,9 @@
 block discarded – undo
77 77
     );
78 78
 
79 79
     // No more pending user_build_cache_tree tasks
80
-    if (DB::count() === 0)
81
-        exit;
80
+    if (DB::count() === 0) {
81
+            exit;
82
+    }
82 83
 
83 84
     // get email properties
84 85
     $arguments = json_decode($record['arguments'], true);
Please login to merge, or discard this patch.
_things/delete_background_tasks___items_handler_subtask.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 $subtask = DB::queryfirstrow(
58 58
     'SELECT *
59
-    FROM ' . prefixTable('background_subtasks') . '
59
+    FROM ' . prefixTable('background_subtasks').'
60 60
     WHERE process_id = %i AND finished_at IS NULL
61 61
     ORDER BY increment_id ASC',
62 62
     (int) $request->request->get('subTask')
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
 list($taskArguments) = DB::queryFirstField(
66 66
     'SELECT arguments
67
-    FROM ' . prefixTable('background_tasks') . '
67
+    FROM ' . prefixTable('background_tasks').'
68 68
     WHERE increment_id = %i',
69 69
     $subtask['process_id']
70 70
 );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     // Loop on all files for this item
76 76
     // and encrypt them for each user
77 77
     if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
78
-    foreach($args['files_keys'] as $file) {
78
+    foreach ($args['files_keys'] as $file) {
79 79
         storeUsersShareKey(
80 80
             prefixTable('sharekeys_items'),
81 81
             0,
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     // Loop on all encrypted fields for this item
93 93
     // and encrypt them for each user
94 94
     if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
95
-    foreach($args['fields_keys'] as $field) {
95
+    foreach ($args['fields_keys'] as $field) {
96 96
         storeUsersShareKey(
97 97
             prefixTable('sharekeys_fields'),
98 98
             0,
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
 if ($args['step'] === 'create_users_files_key') {
75 75
     // Loop on all files for this item
76 76
     // and encrypt them for each user
77
-    if (WIP === true) provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
77
+    if (WIP === true) {
78
+        provideLog('[DEBUG] '.print_r($args['files_keys'], true), $SETTINGS);
79
+    }
78 80
     foreach($args['files_keys'] as $file) {
79 81
         storeUsersShareKey(
80 82
             prefixTable('sharekeys_items'),
@@ -91,7 +93,9 @@  discard block
 block discarded – undo
91 93
 } elseif ($args['step'] === 'create_users_fields_key') {
92 94
     // Loop on all encrypted fields for this item
93 95
     // and encrypt them for each user
94
-    if (WIP === true) provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
96
+    if (WIP === true) {
97
+        provideLog('[DEBUG] '.print_r($args, true), $SETTINGS);
98
+    }
95 99
     foreach($args['fields_keys'] as $field) {
96 100
         storeUsersShareKey(
97 101
             prefixTable('sharekeys_fields'),
Please login to merge, or discard this patch.