Forum Vault Caching

Forum Vault Caching

by John White -
Number of replies: 0

Hi all. Hi have not posted here in quite a while, and Moodle has certainly moved on in the interim - excellent!

My question concerns the use of vault factories generally, and specifically the calls in /mod/forum/discuss.php:

$forumvault = $vaultfactory->get_forum_vault();
$forum = $forumvault->get_from_id($discussion->get_forum_id());

In this context, when moving a discussion from one forum to another, the current forum certainly exists but the destination has to be checked on, currently by calling:

    if (!$forumto = $DB->get_record('forum', ['id' => $move])) {
        print_error('cannotmovetonotexist', 'forum', $return);
    }

Where $move is the destination forum id

But because we have a vault factory open, why not use:

    if (!$forumto = $forumvault->get_from_id($move)) {
        print_error('cannotmovetonotexist', 'forum', $return);
    }

Is there any issue over the caching of vault factories that theoretically might allow another user to delete the destination forum in the meantime?

My reading of the /mod/forum/classes/local/factories.vault.php and entity.php suggests that data on all forums has just been refreshed from the database, so that there is no issue. But can I ask for confirmation here please?

This question impacts on a local development that I would later submit in the tracker.

Many thanks, John


Average of ratings: -