Passed
Pull Request — master (#4676)
by Nils
05:47
created
sources/main.functions.php 1 patch
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2366,7 +2366,9 @@  discard block
 block discarded – undo
2366 2366
 function encryptUserObjectKey(string $key, string $publicKey): string
2367 2367
 {
2368 2368
     // Empty password
2369
-    if (empty($key)) return '';
2369
+    if (empty($key)) {
2370
+        return '';
2371
+    }
2370 2372
 
2371 2373
     // Sanitize
2372 2374
     $antiXss = new AntiXSS();
@@ -2515,7 +2517,9 @@  discard block
 block discarded – undo
2515 2517
         ];
2516 2518
     }
2517 2519
 
2518
-    if (WIP) error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2520
+    if (WIP) {
2521
+        error_log('DEBUG: File image url -> '.filter_var($safeFilePath, FILTER_SANITIZE_URL));
2522
+    }
2519 2523
 
2520 2524
     // Decrypt file content and return
2521 2525
     return base64_encode($cipher->decrypt($ciphertext));
@@ -2650,7 +2654,9 @@  discard block
 block discarded – undo
2650 2654
         foreach ($users as $user) {
2651 2655
             // Insert in DB the new object key for this item by user
2652 2656
             if (count($objectKeyArray) === 0) {
2653
-                if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey);
2657
+                if (WIP === true) {
2658
+                    error_log('TEAMPASS Debug - storeUsersShareKey case1 - ' . $object_name . ' - ' . $post_object_id . ' - ' . $user['id'] . ' - ' . $objectKey);
2659
+                }
2654 2660
                 DB::insert(
2655 2661
                     $object_name,
2656 2662
                     [
@@ -2664,7 +2670,9 @@  discard block
 block discarded – undo
2664 2670
                 );
2665 2671
             } else {
2666 2672
                 foreach ($objectKeyArray as $object) {
2667
-                    if (WIP === true) error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']);
2673
+                    if (WIP === true) {
2674
+                        error_log('TEAMPASS Debug - storeUsersShareKey case2 - ' . $object_name . ' - ' . $object['objectId'] . ' - ' . $user['id'] . ' - ' . $object['objectKey']);
2675
+                    }
2668 2676
                     DB::insert(
2669 2677
                         $object_name,
2670 2678
                         [
@@ -3990,7 +3998,9 @@  discard block
 block discarded – undo
3990 3998
         $taskName = [$taskName];
3991 3999
     }
3992 4000
     foreach($taskName as $task) {
3993
-        if (WIP === true) error_log('createTaskForItem - task: '.$task);
4001
+        if (WIP === true) {
4002
+            error_log('createTaskForItem - task: '.$task);
4003
+        }
3994 4004
         switch ($task) {
3995 4005
             case 'item_password':
3996 4006
                 
@@ -4421,19 +4431,22 @@  discard block
 block discarded – undo
4421 4431
 
4422 4432
             // Organisation name (removed username@ and .tld)
4423 4433
             $domain = explode('.', $emailParts[1]);
4424
-            if (count($domain) > 1)
4425
-                $forbiddenWords[] = $domain[0];
4434
+            if (count($domain) > 1) {
4435
+                            $forbiddenWords[] = $domain[0];
4436
+            }
4426 4437
         }
4427 4438
     }
4428 4439
 
4429 4440
     // Search forbidden words in password
4430 4441
     foreach ($forbiddenWords as $word) {
4431
-        if (empty($word))
4432
-            continue;
4442
+        if (empty($word)) {
4443
+                    continue;
4444
+        }
4433 4445
 
4434 4446
         // Stop if forbidden word found in password
4435
-        if (stripos($password, $word) !== false)
4436
-            return false;
4447
+        if (stripos($password, $word) !== false) {
4448
+                    return false;
4449
+        }
4437 4450
     }
4438 4451
 
4439 4452
     // Get password complexity
Please login to merge, or discard this patch.
sources/folders.class.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -112,8 +112,9 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function isParentFolderAllowed($parent_id, $user_accessible_folders, $user_is_admin, $user_can_create_root_folder)
114 114
     {
115
-        if ($parent_id == 0 && $user_can_create_root_folder == true)
116
-	    return true;
115
+        if ($parent_id == 0 && $user_can_create_root_folder == true) {
116
+        	    return true;
117
+        }
117 118
 
118 119
         if (in_array($parent_id, $user_accessible_folders) === false
119 120
             && (int) $user_is_admin !== 1
@@ -438,8 +439,9 @@  discard block
 block discarded – undo
438 439
             )['count'];
439 440
 
440 441
             // Don't insert duplicates
441
-            if ($count > 0)
442
-                continue;
442
+            if ($count > 0) {
443
+                            continue;
444
+            }
443 445
 
444 446
             // Insert new background task
445 447
             DB::insert(
Please login to merge, or discard this patch.
sources/items.queries.php 1 patch
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1228,7 +1228,9 @@  discard block
 block discarded – undo
1228 1228
                 );
1229 1229
 
1230 1230
                 // Create a task to create sharekeys for users
1231
-                if (WIP=== true) error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw);
1231
+                if (WIP=== true) {
1232
+                    error_log('createTaskForItem - new password for this item - '.$post_password ." -- ". $pw);
1233
+                }
1232 1234
                 $tasksToBePerformed = ['item_password'];
1233 1235
                 $encryptionTaskIsRequested = true;
1234 1236
             } else {
@@ -1548,7 +1550,9 @@  discard block
 block discarded – undo
1548 1550
 
1549 1551
             // create a task for all fields updated
1550 1552
             if ($encryptionTaskIsRequested === true) {
1551
-                if (WIP === true) error_log('createTaskForItem - '.print_r($tasksToBePerformed, true));
1553
+                if (WIP === true) {
1554
+                    error_log('createTaskForItem - '.print_r($tasksToBePerformed, true));
1555
+                }
1552 1556
                 createTaskForItem(
1553 1557
                     'item_update_create_keys',
1554 1558
                     array_unique($tasksToBePerformed),
@@ -2055,7 +2059,9 @@  discard block
 block discarded – undo
2055 2059
                 $inputData['itemId']
2056 2060
             );
2057 2061
             foreach ($rows as $record) {
2058
-                if ($record['raison'] === NULL) continue;
2062
+                if ($record['raison'] === NULL) {
2063
+                    continue;
2064
+                }
2059 2065
                 $reason = explode(':', $record['raison']);
2060 2066
                 if (count($reason) > 0) {
2061 2067
                     $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - '
@@ -4571,7 +4577,9 @@  discard block
 block discarded – undo
4571 4577
                 $inputData['itemId']
4572 4578
             );
4573 4579
             
4574
-            if (WIP === true) error_log('Existing edition locks: '.DB::count());
4580
+            if (WIP === true) {
4581
+                error_log('Existing edition locks: '.DB::count());
4582
+            }
4575 4583
 
4576 4584
             // Check if item has no edition lock
4577 4585
             if ((int) DB::count() > 0 ) {
@@ -4584,7 +4592,9 @@  discard block
 block discarded – undo
4584 4592
                 } else {
4585 4593
                     $delay = EDITION_LOCK_PERIOD; // One day delay
4586 4594
                 }
4587
-                if (WIP === true) error_log('delay: ' . $delay);
4595
+                if (WIP === true) {
4596
+                    error_log('delay: ' . $delay);
4597
+                }
4588 4598
 
4589 4599
                 // We remove old edition locks if delay is expired meaning more than 1 day long
4590 4600
                 if (round(abs(time() - $dataTmp['timestamp']),0) > $delay) {
@@ -4592,7 +4602,9 @@  discard block
 block discarded – undo
4592 4602
                     // In this case, delete edition lock and possible ongoing processes
4593 4603
                     // and continue editing this time
4594 4604
                     // We coonsidere if the most recent item is still locked then all other locks can be removed
4595
-                    if (WIP === true)  error_log('Delay is expired, removing old locks');
4605
+                    if (WIP === true) {
4606
+                        error_log('Delay is expired, removing old locks');
4607
+                    }
4596 4608
                     foreach ($dataItemEditionLocks as $itemEditionLock) {
4597 4609
                         // delete lock
4598 4610
                         DB::delete(
@@ -4859,8 +4871,9 @@  discard block
 block discarded – undo
4859 4871
                 $ids = $tree->getDescendants($folder['id'], true, false, true);
4860 4872
 
4861 4873
                 // This folder is owned by user
4862
-                if (in_array($inputData['folderId'], $ids))
4863
-                    $accessLevel = 30;
4874
+                if (in_array($inputData['folderId'], $ids)) {
4875
+                                    $accessLevel = 30;
4876
+                }
4864 4877
             }
4865 4878
         }
4866 4879
 
Please login to merge, or discard this patch.
_things/delete_background_tasks___items_handler.php 1 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___user_task.php 1 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 1 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 1 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 1 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/background_tasks___handler.php 1 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.