-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearer errors in event DB record no longer found #386
Comments
Yeah agree we should have a clearer error for this. |
@garemoko @ryansmith94 @gordonmacqueen-lp @Patches- @lzabo A simple solution is:
This can also occur in user_created events where the relateduserid is used, possibly incorrectly: It seems that when setting the actor variable we need a valid user: |
@mlynn-lp yeah a util sounds good 👍 do you think the following code is functionally equivalent to the code above? $userid = $event->userid == 0 && isset($CFG->siteguest) ? $CFG->siteguest : $event->userid;
$user = $repo->read_record_by_id('user', $userid); |
I would recommend setting the |
@ryansmith94 Yes that would work but I'd have to use the ternary further down to reset the userid if the event is from a guest. At that point $userid would not be zero, so I couldn't detect it using that method therefore I would prefer to use a simple boolean variable to indicate if the event is from a guest or not. |
@mlynn-lp that code I sent doesn't change the $guest = $event->userid == 0;
$userid = $guest && isset($CFG->siteguest) ? $CFG->siteguest : $event->userid;
$user = $repo->read_record_by_id('user', $userid);
// Other code that uses $guest. |
@ryansmith94 The exception is being thrown because Moodle stores userid 0 in the logstore when in fact the event was from the guest user. I reset the userid to 0 so that the original userid is stored in xapi_logstore_log (same as it will be stored in logstore_standard_log) but for user retrieval purposes we know in some cases that the action was initiated by the guest user, so I retrieve the guest user details. I think this may be a duplicate of issue #386. |
@mlynn-lp thanks for explaining the exception, I had understood that part. I understand why you needed to reset the You're right, it does seem to be a duplicate of #386. |
My error - it is a similar issue to #606. |
Description
Possibly a dupe of #339 (comment)
Currently when a DB record is not found, we throw quite a long exception message that may not be clear to the end user what's going on.
Issues of missing DB records are quite common in processing historical data and I guess can also happen when using cron tasks especially if there is more time between tasks. It would be nice to have a clear error in this case.
The text was updated successfully, but these errors were encountered: