moodle3.5.2の開発を行っております。
右も左もわからないまま、ここにたどりつきました。
courseテーブルに存在する、cacherevという項目について
どこかに説明がないでしょうか?
画面からコース登録した場合、タイムスタンプのような値が
上記項目が登録されておりました。
どこかに詳しい情報があればご教示いただけないでしょうか。
下記Moodle Trackerにヒントとなる説明らしきものがありますが、course.cacherevの値はコースキャッシュがリセットされる度にインクリメントされるようです。
"new field course.cacherev added to table course and it is incremented every time the course cache is reset. Object in cache stores the value of cacherev at the moment when cache was built. This allows to avoid race conditions when course cache was simultaneously reset and rebuild by different people and became corrupt."
[MDL-34397] Develop course structure caching - Moodle Tracker
https://tracker.moodle.org/browse/MDL-34397
具体的には下記2つの部分をご覧頂ければ宜しいかと思います。
lib/moodlelib.php 1635行目
/**
* Invalidates browser caches and cached data in temp.
*
* IMPORTANT - If you are adding anything here to do with the cache directory you should also have a look at
* {@link phpunit_util::reset_dataroot()}
*
* @return void
*/
function purge_all_caches() {
global $CFG, $DB;
reset_text_filters_cache();
js_reset_all_caches();
theme_reset_all_caches();
get_string_manager()->reset_caches();
core_text::reset_caches();
if (class_exists('core_plugin_manager')) {
core_plugin_manager::reset_caches();
}
// Bump up cacherev field for all courses.
try {
increment_revision_number('course', 'cacherev', '');
} catch (moodle_exception $e) {
// Ignore exception since this function is also called before upgrade script when field course.cacherev does not exist yet.
}
$DB->reset_caches();
cache_helper::purge_all();
lib/datalib.php 1204行目
/**
* Increment standard revision field.
*
* The revision are based on current time and are incrementing.
* There is a protection for runaway revisions, it may not go further than
* one hour into future.
*
* The field has to be XMLDB_TYPE_INTEGER with size 10.
*
* @param string $table
* @param string $field name of the field containing revision
* @param string $select use empty string when updating all records
* @param array $params optional select parameters
*/
function increment_revision_number($table, $field, $select, array $params = null) {
global $DB;
$now = time();
$sql = "UPDATE {{$table}}
SET $field = (CASE
WHEN $field IS NULL THEN $now
WHEN $field < $now THEN $now
WHEN $field > $now + 3600 THEN $now
ELSE $field + 1 END)";
if ($select) {
$sql = $sql . " WHERE $select";
}
$DB->execute($sql, $params);
}