Passed
Pull Request — master (#4676)
by Nils
05:33
created
_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.
scripts/traits/UserHandlerTrait.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
     private function generateUserKeys($arguments) {
50 50
         // Get all subtasks related to this task
51 51
         $subtasks = DB::query(
52
-            'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
52
+            'SELECT * FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC',
53 53
             $this->taskId
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) $this->logger->log("No subtask was found for task {$this->taskId}");
58 58
             return;
59 59
         }
60 60
     
61 61
         // Process each subtask
62 62
         foreach ($subtasks as $subtask) {
63
-            if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
63
+            if (LOG_TASKS === true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}");
64 64
             $this->processGenerateUserKeysSubtask($subtask, $arguments);
65 65
         }
66 66
     
67 67
         // Are all subtasks completed?
68 68
         $remainingSubtasks = DB::queryFirstField(
69
-            'SELECT COUNT(*) FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0',
69
+            'SELECT COUNT(*) FROM '.prefixTable('background_subtasks').' WHERE task_id = %i AND is_in_progress = 0',
70 70
             $this->taskId
71 71
         );    
72 72
         if ($remainingSubtasks == 0) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                 $subtask['increment_id']
98 98
             );
99 99
             
100
-            if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
100
+            if (LOG_TASKS === true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO');
101 101
             switch ($taskData['step'] ?? '') {
102 102
                 case 'step0':
103 103
                     $this->generateNewUserStep0($arguments);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                 $subtask['increment_id']
149 149
             );
150 150
             
151
-            $this->logger->log("Subtask {$subtask['increment_id']} failure: " . $e->getMessage(), 'ERROR');
151
+            $this->logger->log("Subtask {$subtask['increment_id']} failure: ".$e->getMessage(), 'ERROR');
152 152
         }
153 153
     }
154 154
     
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
         // Loop on items
184 184
         $rows = DB::query(
185 185
             'SELECT id, pw, perso
186
-            FROM ' . prefixTable('items') . '
186
+            FROM ' . prefixTable('items').'
187 187
             WHERE perso =  %i
188 188
             ORDER BY id ASC
189
-            LIMIT ' . $taskData['index'] . ', ' . $taskData['nb'],
189
+            LIMIT ' . $taskData['index'].', '.$taskData['nb'],
190 190
             ($arguments['only_personal_items'] ?? 0) === 1 ? 1 : 0
191 191
         );
192 192
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             // Get itemKey from current user
195 195
             $currentUserKey = DB::queryFirstRow(
196 196
                 'SELECT share_key, increment_id
197
-                FROM ' . prefixTable('sharekeys_items') . '
197
+                FROM ' . prefixTable('sharekeys_items').'
198 198
                 WHERE object_id = %i AND user_id = %i',
199 199
                 $record['id'],
200 200
                 (int) $record['perso'] === 0 ? $arguments['owner_id'] : $arguments['new_user_id']
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             
222 222
             $currentUserKey = DB::queryFirstRow(
223 223
                 'SELECT increment_id
224
-                FROM ' . prefixTable('sharekeys_items') . '
224
+                FROM ' . prefixTable('sharekeys_items').'
225 225
                 WHERE object_id = %i AND user_id = %i',
226 226
                 $record['id'],
227 227
                 $arguments['new_user_id']
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
         // Loop on logs
273 273
         $rows = DB::query(
274 274
             'SELECT increment_id
275
-            FROM ' . prefixTable('log_items') . '
275
+            FROM ' . prefixTable('log_items').'
276 276
             WHERE raison LIKE "at_pw :%" AND encryption_type = "teampass_aes"
277 277
             ORDER BY increment_id ASC
278
-            LIMIT ' . $taskData['index'] . ', ' . $taskData['nb']
278
+            LIMIT ' . $taskData['index'].', '.$taskData['nb']
279 279
         );
280 280
         foreach ($rows as $record) {
281 281
             // Get itemKey from current user
282 282
             $currentUserKey = DB::queryFirstRow(
283 283
                 'SELECT share_key
284
-                FROM ' . prefixTable('sharekeys_logs') . '
284
+                FROM ' . prefixTable('sharekeys_logs').'
285 285
                 WHERE object_id = %i AND user_id = %i',
286 286
                 $record['increment_id'],
287 287
                 $arguments['owner_id']
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                 if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) {
314 314
                     $currentUserKey = DB::queryFirstRow(
315 315
                         'SELECT increment_id
316
-                        FROM ' . prefixTable('sharekeys_items') . '
316
+                        FROM ' . prefixTable('sharekeys_items').'
317 317
                         WHERE object_id = %i AND user_id = %i',
318 318
                         $record['id'],
319 319
                         $arguments['new_user_id']
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
         // Loop on fields
356 356
         $rows = DB::query(
357 357
             'SELECT id
358
-            FROM ' . prefixTable('categories_items') . '
358
+            FROM ' . prefixTable('categories_items').'
359 359
             WHERE encryption_type = "teampass_aes"
360 360
             ORDER BY id ASC
361
-            LIMIT ' . $taskData['index'] . ', ' . $taskData['nb']
361
+            LIMIT ' . $taskData['index'].', '.$taskData['nb']
362 362
         );
363 363
         foreach ($rows as $record) {
364 364
             // Get itemKey from current user
365 365
             $currentUserKey = DB::queryFirstRow(
366 366
                 'SELECT share_key
367
-                FROM ' . prefixTable('sharekeys_fields') . '
367
+                FROM ' . prefixTable('sharekeys_fields').'
368 368
                 WHERE object_id = %i AND user_id = %i',
369 369
                 $record['id'],
370 370
                 $arguments['owner_id']
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                     if ((int) $arguments['new_user_id'] !== (int) $arguments['owner_id']) {
393 393
                         $currentUserKey = DB::queryFirstRow(
394 394
                             'SELECT increment_id
395
-                            FROM ' . prefixTable('sharekeys_items') . '
395
+                            FROM ' . prefixTable('sharekeys_items').'
396 396
                             WHERE object_id = %i AND user_id = %i',
397 397
                             $record['id'],
398 398
                             $arguments['new_user_id']
@@ -435,15 +435,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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']
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
         // get user info
529 529
         $userInfo = DB::queryFirstRow(
530 530
             'SELECT email, login, auth_type, special, lastname, name
531
-            FROM ' . prefixTable('users') . '
531
+            FROM ' . prefixTable('users').'
532 532
             WHERE id = %i',
533 533
             $arguments['new_user_id']
534 534
         );
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
                 filter_var($userInfo['email'], FILTER_SANITIZE_FULL_SPECIAL_CHARS),
544 544
                 // @scrutinizer ignore-type
545 545
                 empty($arguments['email_body']) === false ? $arguments['email_body'] : $lang->get('email_body_user_config_1'),
546
-                'TEAMPASS - ' . $lang->get('login_credentials'),
546
+                'TEAMPASS - '.$lang->get('login_credentials'),
547 547
                 (array) filter_var_array(
548 548
                     [
549
-                        '#code#' => cryption($arguments['new_user_code'], '','decrypt', $this->settings)['string'],
549
+                        '#code#' => cryption($arguments['new_user_code'], '', 'decrypt', $this->settings)['string'],
550 550
                         '#lastname#' => isset($userInfo['name']) === true ? $userInfo['name'] : '',
551 551
                         '#login#' => isset($userInfo['login']) === true ? $userInfo['login'] : '',
552 552
                     ],
@@ -579,13 +579,13 @@  discard block
 block discarded – undo
579 579
     private function getOwnerInfos(int $owner_id, string $owner_pwd) {
580 580
         $userInfo = DB::queryFirstRow(
581 581
             'SELECT pw, public_key, private_key, login, name
582
-            FROM ' . prefixTable('users') . '
582
+            FROM ' . prefixTable('users').'
583 583
             WHERE id = %i',
584 584
             $owner_id
585 585
         );
586 586
 
587 587
         // decrypt owner password
588
-        $pwd = cryption($owner_pwd, '','decrypt', $this->settings)['string'];
588
+        $pwd = cryption($owner_pwd, '', 'decrypt', $this->settings)['string'];
589 589
         // decrypt private key and send back
590 590
         return [
591 591
             'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']),
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,13 +54,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
scripts/traits/ItemHandlerTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
scripts/task_maintenance_purge_old_files.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
scripts/background_tasks___handler.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 use TeampassClasses\ConfigManager\ConfigManager;
31 31
 
32 32
 require_once __DIR__.'/../sources/main.functions.php';
33
-require_once __DIR__ . '/TaskLogger.php';
33
+require_once __DIR__.'/TaskLogger.php';
34 34
 
35 35
 class BackgroundTasksHandler {
36 36
     private $settings;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS === true) $this->logger->log('Process already running', 'INFO');
59 59
             return false;
60 60
         }
61 61
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->processTaskBatches();
65 65
             $this->performMaintenanceTasks();
66 66
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
67
+            if (LOG_TASKS === true) $this->logger->log('Task processing error: '.$e->getMessage(), 'ERROR');
68 68
         } finally {
69 69
             $this->releaseProcessLock();
70 70
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             return false;
84 84
         }
85 85
         
86
-        fwrite($fp, (string)getmypid());
86
+        fwrite($fp, (string) getmypid());
87 87
         return true;
88 88
     }
89 89
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     private function cleanupStaleTasks() {
102 102
         // Mark tasks as failed if they've been running too long
103 103
         DB::query(
104
-            'UPDATE ' . prefixTable('background_tasks') . ' 
104
+            'UPDATE '.prefixTable('background_tasks').' 
105 105
             SET is_in_progress = -1, 
106 106
                 finished_at = %i, 
107 107
                 status = "failed"
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
         // Remove very old failed tasks
115 115
         DB::query(
116
-            'DELETE t, st FROM ' . prefixTable('background_tasks') . ' t
117
-            INNER JOIN ' . prefixTable('background_subtasks') . ' st ON (t.increment_id = st.task_id)
116
+            'DELETE t, st FROM '.prefixTable('background_tasks').' t
117
+            INNER JOIN ' . prefixTable('background_subtasks').' st ON (t.increment_id = st.task_id)
118 118
             WHERE t.finished_at > %i 
119 119
             AND t.status = %s',
120 120
             time() - $this->maxTimeBeforeRemoval,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         
132 132
         // Check if the maximum number of parallel tasks is reached
133 133
         if ($runningTasks >= $this->maxParallelTasks) {
134
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
134
+            if (LOG_TASKS === true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
135 135
             return;
136 136
         }
137 137
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         // Fetch next batch of tasks
141 141
         $tasks = DB::query(
142 142
             'SELECT increment_id, process_type, arguments 
143
-            FROM ' . prefixTable('background_tasks') . '
143
+            FROM ' . prefixTable('background_tasks').'
144 144
             WHERE is_in_progress = 0 
145 145
             AND (finished_at IS NULL OR finished_at = "")
146 146
             ORDER BY increment_id ASC
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         );
150 150
 
151 151
         foreach ($tasks as $task) {
152
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
152
+            if (LOG_TASKS === true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
153 153
             $this->processIndividualTask($task);
154 154
         }
155 155
     }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @param array $task The task to process.
161 161
      */
162 162
     private function processIndividualTask(array $task) {
163
-        if (LOG_TASKS=== true)  $this->logger->log('Processing task: ' . print_r($task, true), 'INFO');
163
+        if (LOG_TASKS === true)  $this->logger->log('Processing task: '.print_r($task, true), 'INFO');
164 164
 
165 165
         // Store progress in the database        
166 166
         DB::update(
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         // Prepare process
178 178
         $process = new Process([
179 179
             PHP_BINARY,
180
-            __DIR__ . '/background_tasks___worker.php',
180
+            __DIR__.'/background_tasks___worker.php',
181 181
             $task['increment_id'],
182 182
             $task['process_type'],
183 183
             $task['arguments']
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     private function countRunningTasks(): int {
195 195
         return DB::queryFirstField(
196 196
             'SELECT COUNT(*) 
197
-            FROM ' . prefixTable('background_tasks') . ' 
197
+            FROM ' . prefixTable('background_tasks').' 
198 198
             WHERE is_in_progress = 1'
199 199
         );
200 200
     }
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
      */
216 216
     private function cleanMultipleItemsEdition() {
217 217
         DB::query(
218
-            'DELETE i1 FROM ' . prefixTable('items_edition') . ' i1
218
+            'DELETE i1 FROM '.prefixTable('items_edition').' i1
219 219
             JOIN (
220 220
                 SELECT user_id, item_id, MIN(timestamp) AS oldest_timestamp
221
-                FROM ' . prefixTable('items_edition') . '
221
+                FROM ' . prefixTable('items_edition').'
222 222
                 GROUP BY user_id, item_id
223 223
             ) i2 ON i1.user_id = i2.user_id AND i1.item_id = i2.item_id
224 224
             WHERE i1.timestamp > i2.oldest_timestamp'
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     private function handleItemTokensExpiration() {
233 233
         DB::query(
234
-            'DELETE FROM ' . prefixTable('items_edition') . '
234
+            'DELETE FROM '.prefixTable('items_edition').'
235 235
             WHERE timestamp < %i',
236 236
             time() - ($this->settings['delay_item_edition'] * 60 ?: EDITION_LOCK_PERIOD)
237 237
         );
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         // 1. Get all finished tasks older than the cutoff timestamp
249 249
         //    and that are not in progress
250 250
         $tasks = DB::query(
251
-            'SELECT increment_id FROM ' . prefixTable('background_tasks') . '
251
+            'SELECT increment_id FROM '.prefixTable('background_tasks').'
252 252
             WHERE status = %s AND is_in_progress = %i AND finished_at < %s',
253 253
             'completed',
254 254
             -1,
@@ -263,19 +263,19 @@  discard block
 block discarded – undo
263 263
     
264 264
         // 2. Delete all subtasks related to these tasks
265 265
         DB::query(
266
-            'DELETE FROM ' . prefixTable('background_subtasks') . '
266
+            'DELETE FROM '.prefixTable('background_subtasks').'
267 267
             WHERE task_id IN %ls',
268 268
             $taskIds
269 269
         );
270 270
     
271 271
         // 3. Delete the tasks themselves
272 272
         DB::query(
273
-            'DELETE FROM ' . prefixTable('background_tasks') . '
273
+            'DELETE FROM '.prefixTable('background_tasks').'
274 274
             WHERE increment_id IN %ls',
275 275
             $taskIds
276 276
         );
277 277
     
278
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
278
+        if (LOG_TASKS === true) $this->logger->log('Old finished tasks cleaned: '.count($taskIds), 'INFO');
279 279
     }
280 280
 }
281 281
 
@@ -289,5 +289,5 @@  discard block
 block discarded – undo
289 289
     $tasksHandler = new BackgroundTasksHandler($settings);
290 290
     $tasksHandler->processBackgroundTasks();
291 291
 } catch (Exception $e) {
292
-    error_log('Teampass Background Tasks Error: ' . $e->getMessage());
292
+    error_log('Teampass Background Tasks Error: '.$e->getMessage());
293 293
 }
294 294
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
     public function processBackgroundTasks() {
56 56
         // Prevent multiple concurrent executions
57 57
         if (!$this->acquireProcessLock()) {
58
-            if (LOG_TASKS=== true) $this->logger->log('Process already running', 'INFO');
58
+            if (LOG_TASKS=== true) {
59
+                $this->logger->log('Process already running', 'INFO');
60
+            }
59 61
             return false;
60 62
         }
61 63
 
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
             $this->processTaskBatches();
65 67
             $this->performMaintenanceTasks();
66 68
         } catch (Exception $e) {
67
-            if (LOG_TASKS=== true) $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
69
+            if (LOG_TASKS=== true) {
70
+                $this->logger->log('Task processing error: ' . $e->getMessage(), 'ERROR');
71
+            }
68 72
         } finally {
69 73
             $this->releaseProcessLock();
70 74
         }
@@ -131,7 +135,9 @@  discard block
 block discarded – undo
131 135
         
132 136
         // Check if the maximum number of parallel tasks is reached
133 137
         if ($runningTasks >= $this->maxParallelTasks) {
134
-            if (LOG_TASKS=== true) $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
138
+            if (LOG_TASKS=== true) {
139
+                $this->logger->log('Wait ... '.$runningTasks.' out of '.$this->maxParallelTasks.' are already running ', 'INFO');
140
+            }
135 141
             return;
136 142
         }
137 143
 
@@ -149,7 +155,9 @@  discard block
 block discarded – undo
149 155
         );
150 156
 
151 157
         foreach ($tasks as $task) {
152
-            if (LOG_TASKS=== true) $this->logger->log('Launching '.$task['increment_id'], 'INFO');
158
+            if (LOG_TASKS=== true) {
159
+                $this->logger->log('Launching '.$task['increment_id'], 'INFO');
160
+            }
153 161
             $this->processIndividualTask($task);
154 162
         }
155 163
     }
@@ -160,7 +168,9 @@  discard block
 block discarded – undo
160 168
      * @param array $task The task to process.
161 169
      */
162 170
     private function processIndividualTask(array $task) {
163
-        if (LOG_TASKS=== true)  $this->logger->log('Processing task: ' . print_r($task, true), 'INFO');
171
+        if (LOG_TASKS=== true) {
172
+            $this->logger->log('Processing task: ' . print_r($task, true), 'INFO');
173
+        }
164 174
 
165 175
         // Store progress in the database        
166 176
         DB::update(
@@ -275,7 +285,9 @@  discard block
 block discarded – undo
275 285
             $taskIds
276 286
         );
277 287
     
278
-        if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
288
+        if (LOG_TASKS=== true) {
289
+            $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO');
290
+        }
279 291
     }
280 292
 }
281 293
 
Please login to merge, or discard this patch.
scripts/background_tasks___worker.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function execute() {
67 67
         try {
68
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
68
+            if (LOG_TASKS === true) $this->logger->log('Processing task: '.print_r($this->taskData, true), 'DEBUG');
69 69
             // Dispatch selon le type de processus
70 70
             switch ($this->processType) {
71 71
                 case 'item_copy':
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             $arguments = '';
138 138
         }
139 139
 
140
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
140
+        if (LOG_TASKS === true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
141 141
 
142 142
         // Add 'arguments' only if not empty
143 143
         if (!empty($arguments)) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             'increment_id = %i',
152 152
             $this->taskId
153 153
         );
154
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
154
+        if (LOG_TASKS === true) $this->logger->log('Finishing task: '.$this->taskId, 'DEBUG');
155 155
     }
156 156
 
157 157
     /**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             'increment_id = %i',
175 175
             $this->taskId
176 176
         );
177
-        $this->logger->log('Task failure: ' . $e->getMessage(), 'ERROR');
177
+        $this->logger->log('Task failure: '.$e->getMessage(), 'ERROR');
178 178
     }
179 179
 
180 180
     /**
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     private function processSubTasks($arguments) {
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function execute() {
67 67
         try {
68
-            if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
68
+            if (LOG_TASKS=== true) {
69
+                $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG');
70
+            }
69 71
             // Dispatch selon le type de processus
70 72
             switch ($this->processType) {
71 73
                 case 'item_copy':
@@ -137,7 +139,9 @@  discard block
 block discarded – undo
137 139
             $arguments = '';
138 140
         }
139 141
 
140
-        if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
142
+        if (LOG_TASKS=== true) {
143
+            $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG');
144
+        }
141 145
 
142 146
         // Add 'arguments' only if not empty
143 147
         if (!empty($arguments)) {
@@ -151,7 +155,9 @@  discard block
 block discarded – undo
151 155
             'increment_id = %i',
152 156
             $this->taskId
153 157
         );
154
-        if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
158
+        if (LOG_TASKS=== true) {
159
+            $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG');
160
+        }
155 161
     }
156 162
 
157 163
     /**
@@ -194,7 +200,9 @@  discard block
 block discarded – undo
194 200
     
195 201
         // Check if there are any subtasks to process
196 202
         if (empty($subtasks)) {
197
-            if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
203
+            if (LOG_TASKS=== true) {
204
+                $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG');
205
+            }
198 206
             return;
199 207
         }
200 208
     
@@ -204,7 +212,9 @@  discard block
 block discarded – undo
204 212
                 // Get the subtask data
205 213
                 $subtaskData = json_decode($subtask['task'], true);
206 214
 
207
-                if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
215
+                if (LOG_TASKS=== true) {
216
+                    $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG');
217
+                }
208 218
 
209 219
                 // Process the subtask based on its type
210 220
                 switch ($subtaskData['step'] ?? '') {
Please login to merge, or discard this patch.
scripts/task_maintenance_users_personal_folder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
scripts/background_tasks___do_calculation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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']
Please login to merge, or discard this patch.
scripts/task_maintenance_clean_orphan_objects.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -73,64 +73,64 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.