Moodle

Upgrading to 1.9 beta 2 - Fatal Error in get_user_access_sitewide

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.9
  • Fix Version/s: None
  • Component/s: General, Roles / Access
  • Labels:
    None
  • Environment:
    MySQL 5.0.37, PHP 5.1.4, Windows Server 2003
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

in accesslib.php at approximately line 1268:

$sql = "SELECT sctx.path, ra.roleid,
ctx.path AS parentpath,
rco.capability, rco.permission
FROM {$CFG->prefix}role_assignments ra
JOIN {$CFG->prefix}context ctx
ON ra.contextid=ctx.id
JOIN {$CFG->prefix}context sctx
ON (sctx.path LIKE " . sql_concat('ctx.path',"'/%'"). " )
JOIN {$CFG->prefix}role_capabilities rco
ON (rco.roleid=ra.roleid AND rco.contextid=sctx.id)
WHERE ra.userid = $userid
AND sctx.contextlevel <= ".CONTEXT_COURSE."
ORDER BY sctx.depth, sctx.path, ra.roleid";

$rs = get_recordset_sql($sql);

When attempting to upgrade a site from 1.8.2+ to 1.9 beta 2 I found that here get_recordset_sql($sql) is returning false. This causes fatal "Call to a member function on a non-object" errors in the code that follows.

My niave fix was to try wrapping this code in an if block,

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);
}

This allowed the upgrade to proceed, however I also encountered a couple of "You don't have permission to do this" style errors along the way, which leads me to believe my "solution" is not the way forward

Activity

Hide
Martin Dougiamas added a comment -

Do you have any 3rd party modules installed? Or any hacks?

Show
Martin Dougiamas added a comment - Do you have any 3rd party modules installed? Or any hacks?
Hide
Andrew Walker added a comment -

No hacks I can think of, but we do have a couple of non-standard blocks and modules.

(Modules - questionnaire, feedback, object and book. Blocks - feedback, course menu plus a couple of homemade ones)

This afternoon I'll see if I can make another copy of our 1.8 database, and then try the upgrade again after uninstalling these blocks/modules.

Thanks

Show
Andrew Walker added a comment - No hacks I can think of, but we do have a couple of non-standard blocks and modules. (Modules - questionnaire, feedback, object and book. Blocks - feedback, course menu plus a couple of homemade ones) This afternoon I'll see if I can make another copy of our 1.8 database, and then try the upgrade again after uninstalling these blocks/modules. Thanks
Hide
Petr Škoda (skodak) added a comment -

I am going to look into this problem during the weekend, thanks for the report...

Show
Petr Škoda (skodak) added a comment - I am going to look into this problem during the weekend, thanks for the report...
Hide
Andrew Walker added a comment -

I just tested again with a Moodle 1.9 Beta 2 zip file downloaded today and I can no longer reproduce this issue

Show
Andrew Walker added a comment - I just tested again with a Moodle 1.9 Beta 2 zip file downloaded today and I can no longer reproduce this issue
Hide
Dan Poltawski added a comment -

Closing this as per last comment, thanks

Show
Dan Poltawski added a comment - Closing this as per last comment, thanks

People

Dates

  • Created:
    Updated:
    Resolved: