Skip to content

Commit

Permalink
Merge pull request #53 from catalyst/issue51
Browse files Browse the repository at this point in the history
issue #51: fix the issue when relateduserid is null
  • Loading branch information
dmitriim authored Mar 21, 2024
2 parents fa28578 + a6f07c4 commit 75c8d8d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ public function get_sql(): condition_sql {
*/
public function get_events(): array {
return [
'\core\event\cohort_updated',
'\core\event\cohort_member_added',
'\core\event\cohort_member_removed',
];
Expand Down
3 changes: 1 addition & 2 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace tool_dynamic_cohorts;

use core\event\base;
use tool_dynamic_cohorts\rule_manager;

/**
* Event observer class.
Expand Down Expand Up @@ -50,7 +49,7 @@ public static function process_event(base $event): void {
protected static function get_userid_from_event(base $event): int {
$data = $event->get_data();

if (array_key_exists('relateduserid', $data)) {
if (array_key_exists('relateduserid', $data) && !empty($data['relateduserid'])) {
$userid = $data['relateduserid'];
} else {
$userid = $data['userid'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ public function test_get_sql_data_custom_fields() {
*/
public function test_get_events() {
$this->assertEquals([
'\core\event\cohort_updated',
'\core\event\cohort_member_added',
'\core\event\cohort_member_removed',
], $this->get_condition()->get_events());
Expand Down

0 comments on commit 75c8d8d

Please sign in to comment.