Issue Details (XML | Word | Printable)

Key: MDL-17877
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Tim Hunt
Reporter: Howard Miller
Votes: 0
Watchers: 3
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Undefined property: stdClass::$id in /.../lib/accesslib.php on line 4727

Created: 13/Jan/09 07:43 PM   Updated: 21/Jan/09 04:58 PM
Return to search
Component/s: Roles
Affects Version/s: 1.9.3
Fix Version/s: 1.9.4

Participants: Helen Foster, Howard Miller, MurielB and Tim Hunt
Security Level: None
QA Assignee: Helen Foster
Resolved date: 14/Jan/09
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
I just did an upgrade on my 1.9 test site to build 2007101533.01 and Moodle is now throwing the above notice hundreds of times on every page. It's this bit of code...

4718
4719 //error_log(" Record: " . print_r($user,1));
4720
4721 //
4722 // Pagination controls
4723 // Note that we might end up removing a user
4724 // that ends up _not_ having the rights,
4725 // therefore rolling back $c
4726 //
4727 if ($lastuserid != $user->id) {
4728

Granted, it could be a local issue on my test site, but I thought I'd better report it to be safe!!


 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Howard Miller added a comment - 13/Jan/09 07:44 PM
Dumped the object (just whatever the first time it was called) and...

stdClass Object
(
[username] => guest
[firstname] => Guest User
[lastname] =>
[roleid] =>
[depth] =>
)


Howard Miller added a comment - 13/Jan/09 08:01 PM
Yet more info.... This is an example of the SQL that generates that recordset...

SELECT username,firstname,lastname ,ra.roleid, ra.depth FROM (SELECT u.id as userid, ra.roleid,
ctx.depth
FROM mdl_user u..........

So it's possibly what gets passed into get_users_by_capability() in the $fields parameter that's the problem?


Howard Miller added a comment - 13/Jan/09 08:07 PM
Sorry... more info... the call path leads back to the constructor for this class...

class admin_setting_users_with_capability

in adminlib.php. The change in question (by Tim) is here:

http://cvs.moodle.org/moodle/lib/adminlib.php?r1=1.153.2.57&r2=1.153.2.58

Adding id to the list of fields seems to fix it. I have no idea what this is all for so I am reluctant to commit this myself


Tim Hunt added a comment - 14/Jan/09 01:30 PM
Ah right. That is a new admin_setting class that I wrote recently, and I screwed up by trying to limit the list of fields too much. Yes, adding id to the list of fields is the correct fix. has_cap requires it.

However, the problem only occurs in the more complex branch of the code which is used when there are negative permissions like PREVENT and PROHIBIT, which is more rarely used, which is probably why other people have not seen this.

Acutally, we should check that u.id is in the list of fields, and if not display a nice error if not. I'll fix it.


Tim Hunt added a comment - 14/Jan/09 01:46 PM
Thanks for the clear report and diagnosis Howard.

MurielB added a comment - 15/Jan/09 09:00 PM
hi,
i update today (20090115) my moodle 1.9.3 to 1.9.3+ (build 20090114)
i've got this error after the update :
Notice: Undefined property: stdClass::$id in /moodle/lib/accesslib.php on line 4727
i read your report but don't understand what i have to do to fix this bug ...

please can you tell me more ?

thanks


Helen Foster added a comment - 21/Jan/09 04:58 PM
Muriel, the simplest way to fix your problem would be to update to the latest stable version of Moodle 1.9.3+ from http://download.moodle.org/

Howard, thanks for reporting this issue and Tim, thanks for fixing it.