Skip to content

Commit

Permalink
#10249 Clear invalid images and setup the setting_type
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jul 31, 2024
1 parent 121d5f9 commit f09741c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions classes/migration/upgrade/I10249_FixProfileImageDataLoss.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public function up() {
$globPattern = "{$publicFilesPath}/profileImage-{$row->user_id}.*";
$candidates = glob($globPattern, GLOB_NOSORT);
if (empty($candidates)) {
error_log("Failed to locate a profile image for the user ID {$row->user_id} at {$globPattern}");
error_log("Failed to locate a profile image for the user ID {$row->user_id} at {$globPattern}, cleaning up the value");
Capsule::table('user_settings')
->where('user_id', $row->user_id)
->where('setting_name', 'profileImage')
->update(['setting_value' => null]);
continue;
}

Expand All @@ -49,13 +53,16 @@ public function up() {
Capsule::table('user_settings')
->where('user_id', $row->user_id)
->where('setting_name', 'profileImage')
->update(['setting_value' => json_encode([
'name' => $fileName,
'uploadName' => $fileName,
'width' => $width,
'height' => $height,
'dateUploaded' => date('Y-m-d H:i:s', filemtime($filePath))
])]);
->update([
'setting_value' => json_encode([
'name' => $fileName,
'uploadName' => $fileName,
'width' => $width,
'height' => $height,
'dateUploaded' => date('Y-m-d H:i:s', filemtime($filePath))
]),
'setting_type' => 'object'
]);
}
}, 'user_id');
}
Expand Down

0 comments on commit f09741c

Please sign in to comment.