Skip to content

Commit

Permalink
pkp#97 Updated code to use the table's primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jan 31, 2025
1 parent d533569 commit 71d1e86
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions classes/migration/upgrade/I57_UpdateSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function up(): void
$settings = DB::table('plugin_settings')
->where('plugin_name', '=', 'plnplugin')
->whereIn('setting_name', ['terms_of_use', 'terms_of_use_agreement'])
->pluck('setting_value', 'setting_name');
foreach ($settings as $name => $value) {
->pluck('setting_value', 'plugin_setting_id');
foreach ($settings as $id => $value) {
$isUpdateRequired = false;
try {
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
Expand All @@ -58,8 +58,7 @@ public function up(): void

if ($isUpdateRequired) {
DB::table('plugin_settings')
->where('plugin_name', '=', 'plnplugin')
->where('setting_name', '=', $name)
->where('plugin_setting_id', '=', $id)
->update(['setting_value' => json_encode($value)]);
}
}
Expand Down

0 comments on commit 71d1e86

Please sign in to comment.