Skip to content

Commit

Permalink
#8933 Fix migration - nullable setting_type & inserting empty event l…
Browse files Browse the repository at this point in the history
…og issue
  • Loading branch information
Vitaliy-1 committed May 22, 2023
1 parent d875555 commit 379e695
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions classes/log/event/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public function __construct()
public function setCustomProps(array $props)
{
$cleanProps = $this->validateCustomProps($props);
if (empty($cleanProps)) {
return;
}
$this->customProps = $cleanProps;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/migration/install/LogMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function up(): void
$table->string('locale', 14)->default('');
$table->string('setting_name', 255);
$table->mediumText('setting_value')->nullable();
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)')->nullable()->default(null);
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)')->nullable();
$table->unique(['log_id', 'setting_name', 'locale'], 'event_log_settings_unique');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function up(): void
$table->string('locale', 14)->default('')->after('log_id');
$table->dropUnique('event_log_settings_unique');
$table->unique(['log_id', 'locale', 'setting_name'], 'event_log_settings_unique');
$table->string('setting_type', 6)->default(null)->change();
$table->string('setting_type', 6)->nullable()->change();
});

// Events can be triggered without a user, e.g., in schedule tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,13 @@ public function _logEventAndCreateNotification($request, $submission)
{
$currentUser = $request->getUser();
$eventLog = Repo::eventLog()->newDataObject([
[
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => EventLogEntry::SUBMISSION_LOG_MESSAGE_SENT,
'userId' => Validation::loggedInAs() ?? $currentUser->getId(),
'message' => 'informationCenter.history.messageSent',
'isTranslated' => 0,
'dateLogged' => Core::getCurrentDate()
]
'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION,
'assocId' => $submission->getId(),
'eventType' => EventLogEntry::SUBMISSION_LOG_MESSAGE_SENT,
'userId' => Validation::loggedInAs() ?? $currentUser->getId(),
'message' => 'informationCenter.history.messageSent',
'isTranslated' => 0,
'dateLogged' => Core::getCurrentDate()
]);
Repo::eventLog()->add($eventLog);

Expand Down

0 comments on commit 379e695

Please sign in to comment.