Skip to content

Commit

Permalink
pkp#10249 Clear invalid images and setup the setting_type
Browse files Browse the repository at this point in the history
(cherry picked from commit f09741c)
  • Loading branch information
jonasraoni committed Jul 31, 2024
1 parent 53c1fbc commit 80670e3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public function up(): void
$globPattern = "{$publicFilesPath}/profileImage-{$row->user_id}.*";
$candidates = glob($globPattern, GLOB_NOSORT);
if (empty($candidates)) {
$this->_installer->log("Failed to locate a profile image for the user ID {$row->user_id} at {$globPattern}");
$this->_installer->log("Failed to locate a profile image for the user ID {$row->user_id} at {$globPattern}, cleaning up the value");
DB::table('user_settings')
->where('user_id', $row->user_id)
->where('setting_name', 'profileImage')
->update(['setting_value' => null]);
continue;
}

Expand All @@ -61,7 +65,8 @@ public function up(): void
'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 80670e3

Please sign in to comment.