PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.2.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.2.0
2.2.0 2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 All 43 releases
← All changes | app/Hooks/Handlers/TaskHandler.php +39 -6 2.0.12 → 2.2.0 View file →
@@ -3,8 +3,9 @@
3 3 namespace FluentBoards\App\Hooks\Handlers;
4 4
5 5 use DateTimeImmutable;
6 6 use Exception;
7 +use FluentBoards\App\App;
7 8 use FluentBoards\App\Models\Activity;
8 9 use FluentBoards\App\Models\Meta;
9 10 use FluentBoards\App\Models\TaskMeta;
10 11 use FluentBoards\App\Models\Task;
@@ -84,8 +85,13 @@
84 85 }
85 86
86 87 public function searchNonBoardWordpressUsers()
87 88 {
89 + // This enumerates every WordPress user with their email; only user managers may see it.
90 + if (!current_user_can('list_users')) {
91 + return [];
92 + }
93 +
88 94 $superAdmin = Relation::select('user_id')->distinct()->pluck('user_id');
89 95 $users = User::whereDoesntHave('boards')->whereNotIn('ID', $superAdmin)->get();
90 96
91 97 $formattedUsers = [];
@@ -165,18 +171,45 @@
165 171
166 172
167 173
168 174 /**
169 - * Summary of taskAttachmentDeleted
170 - * @param mixed $task
171 - * @param mixed $deleteUrl
175 + * Delete an attachment file only after the owning database transaction commits.
176 + *
177 + * @param mixed $deletedAttachment
178 + * @param int|null $boardId
172 179 * @return void
173 180 */
174 - public function taskAttachmentDeleted($deletedAttachment)
181 + public function taskAttachmentDeleted($deletedAttachment, $boardId = null)
175 182 {
183 + if ($deletedAttachment->attachment_type === 'url') {
184 + return;
185 + }
186 +
187 + if ($boardId === null) {
188 + $task = Task::find(absint($deletedAttachment->object_id));
189 + $boardId = $task ? $task->board_id : null;
190 + }
191 +
192 + $dbInstance = App::getInstance('db');
193 +
194 + if ($dbInstance->inTransaction()) {
195 + $attachmentSnapshot = clone $deletedAttachment;
196 + $dbInstance->afterCommit(function () use ($attachmentSnapshot, $boardId) {
197 + try {
198 + $this->fileHandler->deleteAttachmentFile($attachmentSnapshot, $boardId);
199 + } catch (\Throwable $e) {
200 + error_log(sprintf(
201 + 'FluentBoards: Failed to delete committed task attachment file: %s',
202 + sanitize_text_field($e->getMessage())
203 + ));
204 + }
205 + });
206 +
207 + return;
208 + }
209 +
176 210 try {
177 - $deleteUrl = $deletedAttachment->full_url;
178 - $this->fileHandler->deleteFileByUrl($deleteUrl);
211 + $this->fileHandler->deleteAttachmentFile($deletedAttachment, $boardId);
179 212 } catch (Exception $e) {
180 213 wp_send_json_error($e->getMessage());
181 214 }
182 215 }