Skip to content

Commit

Permalink
MDL-72052 assign: - cache assign class.
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Jul 5, 2021
1 parent a747fd3 commit 0005474
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mod/assign/submission/comments/lib.php
Expand Up @@ -43,7 +43,10 @@ function assignsubmission_comments_comment_validate(stdClass $options) {
$context = $options->context;

require_once($CFG->dirroot . '/mod/assign/locallib.php');
$assignment = new assign($context, null, null);
static $assignment = null;
if (is_null($assignment) || $assignment->get_context() != $context) {
$assignment = new assign($context, null, null);
}

if ($assignment->get_instance()->id != $submission->assignment) {
throw new comment_exception('invalidcontext');
Expand Down Expand Up @@ -71,7 +74,10 @@ function assignsubmission_comments_comment_permissions(stdClass $options) {
$context = $options->context;

require_once($CFG->dirroot . '/mod/assign/locallib.php');
$assignment = new assign($context, null, null);
static $assignment = null;
if (is_null($assignment) || $assignment->get_context() != $context) {
$assignment = new assign($context, null, null);
}

if ($assignment->get_instance()->id != $submission->assignment) {
throw new comment_exception('invalidcontext');
Expand Down

0 comments on commit 0005474

Please sign in to comment.