From: nfreear Date: Mon, 12 Nov 2007 16:53:53 +0000 (+0000) Subject: Fixes MDL-12125, Call to a member function FetchRow on a non-object in get_user_acces... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0dbb2191fb81bac02e12ea045fbf5d4195c6ed90;p=moodle.git Fixes MDL-12125, Call to a member function FetchRow on a non-object in get_user_access_sitewide. --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 233dcd9a70..16c712c469 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1258,12 +1258,14 @@ function get_user_access_sitewide($userid) { $rs = get_recordset_sql($sql); unset($clauses); - while ($rd = rs_fetch_next_record($rs)) { - $k = "{$rd->path}:{$rd->roleid}"; - $accessdata['rdef'][$k][$rd->capability] = $rd->permission; + if ($rs) { + while ($rd = rs_fetch_next_record($rs)) { + $k = "{$rd->path}:{$rd->roleid}"; + $accessdata['rdef'][$k][$rd->capability] = $rd->permission; + } + unset($rd); + rs_close($rs); } - unset($rd); - rs_close($rs); } // @@ -1289,13 +1291,14 @@ function get_user_access_sitewide($userid) { ORDER BY sctx.depth, sctx.path, ra.roleid"; $rs = get_recordset_sql($sql); - while ($rd = rs_fetch_next_record($rs)) { - $k = "{$rd->path}:{$rd->roleid}"; - $accessdata['rdef'][$k][$rd->capability] = $rd->permission; + if ($rs) { + while ($rd = rs_fetch_next_record($rs)) { + $k = "{$rd->path}:{$rd->roleid}"; + $accessdata['rdef'][$k][$rd->capability] = $rd->permission; + } + unset($rd); + rs_close($rs); } - unset($rd); - rs_close($rs); - return $accessdata; }