mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-43367 stop returning of bogus context children when path unknown
This also prevents deletion of system context.
This commit is contained in:
parent
edd9bb451c
commit
19dc3b0b0d
@ -5462,6 +5462,10 @@ abstract class context extends stdClass implements IteratorAggregate {
|
||||
public function delete() {
|
||||
global $DB;
|
||||
|
||||
if ($this->_contextlevel <= CONTEXT_SYSTEM) {
|
||||
throw new coding_exception('Cannot delete system context');
|
||||
}
|
||||
|
||||
// double check the context still exists
|
||||
if (!$DB->record_exists('context', array('id'=>$this->_id))) {
|
||||
context::cache_remove($this);
|
||||
@ -5557,6 +5561,11 @@ abstract class context extends stdClass implements IteratorAggregate {
|
||||
public function get_child_contexts() {
|
||||
global $DB;
|
||||
|
||||
if (empty($this->_path) or empty($this->_depth)) {
|
||||
debugging('Can not find child contexts of context '.$this->_id.' try rebuilding of context paths');
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT ctx.*
|
||||
FROM {context} ctx
|
||||
WHERE ctx.path LIKE ?";
|
||||
@ -6557,6 +6566,11 @@ class context_coursecat extends context {
|
||||
public function get_child_contexts() {
|
||||
global $DB;
|
||||
|
||||
if (empty($this->_path) or empty($this->_depth)) {
|
||||
debugging('Can not find child contexts of context '.$this->_id.' try rebuilding of context paths');
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT ctx.*
|
||||
FROM {context} ctx
|
||||
WHERE ctx.path LIKE ? AND (ctx.depth = ? OR ctx.contextlevel = ?)";
|
||||
|
Loading…
x
Reference in New Issue
Block a user