@@ -55,7 +55,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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('Starting task: ' . print_r($task, true), 'INFO'); |
|
| 171 | + if (LOG_TASKS=== true) { |
|
| 172 | + $this->logger->log('Starting task: ' . print_r($task, true), 'INFO'); |
|
| 173 | + } |
|
| 164 | 174 | |
| 165 | 175 | // Store progress in the database |
| 166 | 176 | DB::update( |
@@ -188,7 +198,9 @@ discard block |
||
| 188 | 198 | $process->mustRun(); |
| 189 | 199 | |
| 190 | 200 | } catch (Exception $e) { |
| 191 | - if (LOG_TASKS=== true) $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
| 201 | + if (LOG_TASKS=== true) { |
|
| 202 | + $this->logger->log('Error launching task: ' . $e->getMessage(), 'ERROR'); |
|
| 203 | + } |
|
| 192 | 204 | DB::update( |
| 193 | 205 | prefixTable('background_tasks'), |
| 194 | 206 | [ |
@@ -290,7 +302,9 @@ discard block |
||
| 290 | 302 | $taskIds |
| 291 | 303 | ); |
| 292 | 304 | |
| 293 | - if (LOG_TASKS=== true) $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
| 305 | + if (LOG_TASKS=== true) { |
|
| 306 | + $this->logger->log('Old finished tasks cleaned: ' . count($taskIds), 'INFO'); |
|
| 307 | + } |
|
| 294 | 308 | } |
| 295 | 309 | } |
| 296 | 310 | |
@@ -134,7 +134,9 @@ |
||
| 134 | 134 | handleAttachmentError('File exceeds the maximum allowed size', 120, 413); |
| 135 | 135 | die(); |
| 136 | 136 | } |
| 137 | - if (WIP === true) error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 137 | + if (WIP === true) { |
|
| 138 | + error_log('POST_MAX_SIZE: ' . $POST_MAX_SIZE." - CONTENT_LENGTH: ".$_SERVER['CONTENT_LENGTH']." - UNIT: ".$unit." - MAX: ".$maxSize." - MULTIPLIER: ".$multiplier." - FILE_SIZE: ".$post_fileSize); |
|
| 139 | + } |
|
| 138 | 140 | |
| 139 | 141 | // delete expired tokens |
| 140 | 142 | DB::delete(prefixTable('tokens'), 'end_timestamp < %i', time()); |
@@ -80,8 +80,9 @@ discard block |
||
| 80 | 80 | $session = SessionManager::getSession(); |
| 81 | 81 | |
| 82 | 82 | // Random encryption key |
| 83 | -if ($session->get('key') === null) |
|
| 83 | +if ($session->get('key') === null) { |
|
| 84 | 84 | $session->set('key', generateQuickPassword(30, false)); |
| 85 | +} |
|
| 85 | 86 | |
| 86 | 87 | $request = SymfonyRequest::createFromGlobals(); |
| 87 | 88 | $configManager = new ConfigManager(); |
@@ -980,7 +981,10 @@ discard block |
||
| 980 | 981 | <input type="password" class="form-control" id="dialog-ldap-user-build-keys-database-code"> |
| 981 | 982 | <br/> |
| 982 | 983 | </div> |
| 983 | - <div class="input-group mb-3<?php if ($session_auth_type === 'oauth2') echo ' hidden'; ?>"> |
|
| 984 | + <div class="input-group mb-3<?php if ($session_auth_type === 'oauth2') { |
|
| 985 | + echo ' hidden'; |
|
| 986 | +} |
|
| 987 | +?>"> |
|
| 984 | 988 | <div class="input-group-prepend"> |
| 985 | 989 | <span class="input-group-text"><?php echo $lang->get('provide_your_current_password'); ?></span> |
| 986 | 990 | </div> |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function execute() { |
| 66 | 66 | try { |
| 67 | - if (LOG_TASKS=== true) $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
| 67 | + if (LOG_TASKS=== true) { |
|
| 68 | + $this->logger->log('Processing task: ' . print_r($this->taskData, true), 'DEBUG'); |
|
| 69 | + } |
|
| 68 | 70 | // Dispatch selon le type de processus |
| 69 | 71 | switch ($this->processType) { |
| 70 | 72 | case 'item_copy': |
@@ -136,7 +138,9 @@ discard block |
||
| 136 | 138 | $arguments = ''; |
| 137 | 139 | } |
| 138 | 140 | |
| 139 | - if (LOG_TASKS=== true) $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 141 | + if (LOG_TASKS=== true) { |
|
| 142 | + $this->logger->log('Process: '.$this->processType.' -- '.print_r($arguments, true), 'DEBUG'); |
|
| 143 | + } |
|
| 140 | 144 | |
| 141 | 145 | // Add 'arguments' only if not empty |
| 142 | 146 | if (!empty($arguments)) { |
@@ -150,7 +154,9 @@ discard block |
||
| 150 | 154 | 'increment_id = %i', |
| 151 | 155 | $this->taskId |
| 152 | 156 | ); |
| 153 | - if (LOG_TASKS=== true) $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
| 157 | + if (LOG_TASKS=== true) { |
|
| 158 | + $this->logger->log('Finishing task: ' . $this->taskId, 'DEBUG'); |
|
| 159 | + } |
|
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | /** |
@@ -185,7 +191,9 @@ discard block |
||
| 185 | 191 | * @return void |
| 186 | 192 | */ |
| 187 | 193 | private function processSubTasks($arguments) { |
| 188 | - if (LOG_TASKS=== true) $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 194 | + if (LOG_TASKS=== true) { |
|
| 195 | + $this->logger->log('processSubTasks: '.print_r($arguments, true), 'DEBUG'); |
|
| 196 | + } |
|
| 189 | 197 | // Get all subtasks related to this task |
| 190 | 198 | $subtasks = DB::query( |
| 191 | 199 | 'SELECT * FROM ' . prefixTable('background_subtasks') . ' WHERE task_id = %i AND is_in_progress = 0 ORDER BY `task` ASC', |
@@ -194,7 +202,9 @@ discard block |
||
| 194 | 202 | |
| 195 | 203 | // Check if there are any subtasks to process |
| 196 | 204 | if (empty($subtasks)) { |
| 197 | - if (LOG_TASKS=== true) $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
| 205 | + if (LOG_TASKS=== true) { |
|
| 206 | + $this->logger->log('No subtask was found for task: ' . $this->taskId, 'DEBUG'); |
|
| 207 | + } |
|
| 198 | 208 | return; |
| 199 | 209 | } |
| 200 | 210 | |
@@ -204,7 +214,9 @@ discard block |
||
| 204 | 214 | // Get the subtask data |
| 205 | 215 | $subtaskData = json_decode($subtask['task'], true); |
| 206 | 216 | |
| 207 | - if (LOG_TASKS=== true) $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
| 217 | + if (LOG_TASKS=== true) { |
|
| 218 | + $this->logger->log('Processing subtask: ' . $subtaskData['step'], 'DEBUG'); |
|
| 219 | + } |
|
| 208 | 220 | |
| 209 | 221 | // Mark subtask as in progress |
| 210 | 222 | DB::update( |
@@ -1228,7 +1228,9 @@ discard block |
||
| 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 { |
@@ -1553,7 +1555,9 @@ discard block |
||
| 1553 | 1555 | |
| 1554 | 1556 | // create a task for all fields updated |
| 1555 | 1557 | if ($encryptionTaskIsRequested === true && (int) $dataItem['perso'] !== 1) { |
| 1556 | - if (WIP === true) error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
| 1558 | + if (WIP === true) { |
|
| 1559 | + error_log('createTaskForItem - '.print_r($tasksToBePerformed, true)); |
|
| 1560 | + } |
|
| 1557 | 1561 | createTaskForItem( |
| 1558 | 1562 | 'item_update_create_keys', |
| 1559 | 1563 | array_unique($tasksToBePerformed), |
@@ -2103,7 +2107,9 @@ discard block |
||
| 2103 | 2107 | $inputData['itemId'] |
| 2104 | 2108 | ); |
| 2105 | 2109 | foreach ($rows as $record) { |
| 2106 | - if ($record['raison'] === NULL) continue; |
|
| 2110 | + if ($record['raison'] === NULL) { |
|
| 2111 | + continue; |
|
| 2112 | + } |
|
| 2107 | 2113 | $reason = explode(':', $record['raison']); |
| 2108 | 2114 | if (count($reason) > 0) { |
| 2109 | 2115 | $sentence = date($SETTINGS['date_format'] . ' ' . $SETTINGS['time_format'], (int) $record['date']) . ' - ' |
@@ -4819,8 +4825,9 @@ discard block |
||
| 4819 | 4825 | $ids = $tree->getDescendants($folder['id'], true, false, true); |
| 4820 | 4826 | |
| 4821 | 4827 | // This folder is owned by user |
| 4822 | - if (in_array($inputData['folderId'], $ids)) |
|
| 4823 | - $accessLevel = 30; |
|
| 4828 | + if (in_array($inputData['folderId'], $ids)) { |
|
| 4829 | + $accessLevel = 30; |
|
| 4830 | + } |
|
| 4824 | 4831 | } |
| 4825 | 4832 | } |
| 4826 | 4833 | |
@@ -55,13 +55,17 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | if (empty($subtasks)) { |
| 58 | - if (LOG_TASKS=== true) $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 58 | + if (LOG_TASKS=== true) { |
|
| 59 | + $this->logger->log("No subtask was found for task {$this->taskId}"); |
|
| 60 | + } |
|
| 59 | 61 | return; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | // Process each subtask |
| 63 | 65 | foreach ($subtasks as $subtask) { |
| 64 | - if (LOG_TASKS=== true) $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 66 | + if (LOG_TASKS=== true) { |
|
| 67 | + $this->logger->log("Processing subtask {$subtask['increment_id']} for task {$this->taskId}"); |
|
| 68 | + } |
|
| 65 | 69 | $this->processGenerateUserKeysSubtask($subtask, $arguments); |
| 66 | 70 | } |
| 67 | 71 | |
@@ -98,7 +102,9 @@ discard block |
||
| 98 | 102 | $subtask['increment_id'] |
| 99 | 103 | ); |
| 100 | 104 | |
| 101 | - if (LOG_TASKS=== true) $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 105 | + if (LOG_TASKS=== true) { |
|
| 106 | + $this->logger->log("Subtask is in progress: ".$taskData['step'], 'INFO'); |
|
| 107 | + } |
|
| 102 | 108 | switch ($taskData['step'] ?? '') { |
| 103 | 109 | case 'step0': |
| 104 | 110 | $this->generateNewUserStep0($arguments); |
@@ -752,7 +758,7 @@ discard block |
||
| 752 | 758 | 'login' => $userInfo['login'], |
| 753 | 759 | 'name' => $userInfo['name'], |
| 754 | 760 | ]; |
| 755 | - }else { |
|
| 761 | + } else { |
|
| 756 | 762 | // Normal case |
| 757 | 763 | return [ |
| 758 | 764 | 'private_key' => decryptPrivateKey($pwd, $userInfo['private_key']), |