mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-61519 coursecat: do not cache get_all_children_ids
This commit is contained in:
parent
c4172077df
commit
ef780a0051
@ -1178,20 +1178,15 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
||||
* @return int[]
|
||||
*/
|
||||
public function get_all_children_ids() {
|
||||
$coursecattreecache = cache::make('core', 'coursecattree');
|
||||
$children = $coursecattreecache->get($this->id . 'allchildren');
|
||||
if ($children === false) {
|
||||
$children = [];
|
||||
$walk = [$this->id];
|
||||
while (count($walk) > 0) {
|
||||
$catid = array_pop($walk);
|
||||
$directchildren = self::get_tree($catid);
|
||||
if ($directchildren !== false && count($directchildren) > 0) {
|
||||
$walk = array_merge($walk, $directchildren);
|
||||
$children = array_merge($children, $directchildren);
|
||||
}
|
||||
$children = [];
|
||||
$walk = [$this->id];
|
||||
while (count($walk) > 0) {
|
||||
$catid = array_pop($walk);
|
||||
$directchildren = self::get_tree($catid);
|
||||
if ($directchildren !== false && count($directchildren) > 0) {
|
||||
$walk = array_merge($walk, $directchildren);
|
||||
$children = array_merge($children, $directchildren);
|
||||
}
|
||||
$coursecattreecache->set($this->id . 'allchildren', $children);
|
||||
}
|
||||
|
||||
return $children;
|
||||
|
Loading…
x
Reference in New Issue
Block a user