mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
navigation MDL-20227 Added compare function
This allows us to compare the modinfo stored in the cache with that against that active course
This commit is contained in:
parent
3175908906
commit
fdd35767f3
1 changed files with 24 additions and 3 deletions
|
@ -912,7 +912,7 @@ class global_navigation extends navigation_node {
|
||||||
$course = $PAGE->course;
|
$course = $PAGE->course;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->cache->cached('modinfo'.$course->id)) {
|
if (!$this->cache->compare('modinfo'.$course->id, $course->modinfo)) {
|
||||||
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
||||||
}
|
}
|
||||||
$modinfo = $this->cache->{'modinfo'.$course->id};
|
$modinfo = $this->cache->{'modinfo'.$course->id};
|
||||||
|
@ -969,7 +969,7 @@ class global_navigation extends navigation_node {
|
||||||
$course = $PAGE->course;
|
$course = $PAGE->course;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->cache->cached('modinfo'.$course->id)) {
|
if (!$this->cache->compare('modinfo'.$course->id, $course->modinfo)) {
|
||||||
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
||||||
}
|
}
|
||||||
$modinfo = $this->cache->{'modinfo'.$course->id};
|
$modinfo = $this->cache->{'modinfo'.$course->id};
|
||||||
|
@ -1276,7 +1276,7 @@ class global_navigation extends navigation_node {
|
||||||
$sections = $this->cache->$coursesecstr;
|
$sections = $this->cache->$coursesecstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->cache->cached('modinfo'.$course->id)) {
|
if (!$this->cache->compare('modinfo'.$course->id, $course->modinfo)) {
|
||||||
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
$this->cache->{'modinfo'.$course->id} = get_fast_modinfo($course);
|
||||||
}
|
}
|
||||||
$modinfo = $this->cache->{'modinfo'.$course->id};
|
$modinfo = $this->cache->{'modinfo'.$course->id};
|
||||||
|
@ -3073,6 +3073,27 @@ class navigation_cache {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Compare something to it's equivilant in the cache
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @param bool $serialise Whether to serialise the value before comparison
|
||||||
|
* this should only be set to false if the value is already
|
||||||
|
* serialised
|
||||||
|
* @return bool If the value is the same false if it is not set or doesn't match
|
||||||
|
*/
|
||||||
|
public function compare($key, $value, $serialise=true) {
|
||||||
|
if ($this->cached($key)) {
|
||||||
|
if ($serialise) {
|
||||||
|
$value = serialize($value);
|
||||||
|
}
|
||||||
|
if ($this->session[$key][self::CACHEVALUE] === $value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Whipes the entire cache, good to force regeneration
|
* Whipes the entire cache, good to force regeneration
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue