Skip to content
Browse files

Merge branch 'MDL-32462_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents 2d3659d + c08ea52 commit 4be12986aa3eb80be86185729ad24a3ed441cd39 @danpoltawski danpoltawski committed Apr 23, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/accesslib.php
View
20 lib/accesslib.php
@@ -5853,12 +5853,24 @@ protected static function get_cleanup_sql() {
protected static function build_paths($force) {
global $DB;
- // first update normal users
+ // First update normal users.
+ $path = $DB->sql_concat('?', 'id');
+ $pathstart = '/' . SYSCONTEXTID . '/';
+ $params = array($pathstart);
+
+ if ($force) {
+ $where = "depth <> 2 OR path IS NULL OR path <> ({$path})";
+ $params[] = $pathstart;
+ } else {
+ $where = "depth = 0 OR path IS NULL";
+ }
+
$sql = "UPDATE {context}
SET depth = 2,
- path = ".$DB->sql_concat("'/".SYSCONTEXTID."/'", 'id')."
- WHERE contextlevel=".CONTEXT_USER;
- $DB->execute($sql);
+ path = {$path}
+ WHERE contextlevel = " . CONTEXT_USER . "
+ AND ($where)";
+ $DB->execute($sql, $params);
}
}

0 comments on commit 4be1298

Please sign in to comment.
Something went wrong with that request. Please try again.