Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
ef780a00
Commit
ef780a00
authored
Mar 20, 2018
by
Martin Gauk
Browse files
MDL-61519 coursecat: do not cache get_all_children_ids
parent
c4172077
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/coursecatlib.php
View file @
ef780a00
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment