Zero users?! Search function returns no users yet accounts working and accessible

Zero users?! Search function returns no users yet accounts working and accessible

by Dan McMahon -
Number of replies: 3

A curious error, this - any part of Moodle that searches the database of users (when adding staff to a course page, when showing a list of all users, when trying to add someone to your instant messaging Contact list) returns zero results. This means we can't add teachers to pages!

The accounts are there, though, and in fact listing all users (Administration -> Users -> Edit User Accounts) gives a 0 user count, but all the accounts are listed underneath it. You can use the A-Z firstname/surname shortcuts fine, and the lists they pull up are accurate, but the search function itself does not. i.e. clicking Firstname J and Surname S will return a list of users including John Smith, but a search for John Smith returns no results.

Presume this is a database connection error, though I've no idea how it happened!

We're on Moodle 1.5.2+ (on IIS 5.1) and upgrading to 1.6 very soon, this process may solve our problem but I'm fascinated to know how the hell it happened in the meantime!

Average of ratings: -
In reply to Dan McMahon

Re: Zero users?! Search function returns no users yet accounts working and accessible

by Dan McMahon -

Just a thought... we Moodlers are generally warned off from altering the database directly (breaking associations Moodle relies on etc.) Would it be hideously damaging to find staff records in the database and manually associate them with course pages?

In reply to Dan McMahon

Re: Zero users?! Search function returns no users yet accounts working and accessible

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Dan,

The problem sounds like it could be due to the version of MySQL. Please check bug 3781 (thanks to Anthony Borrow smile) for further details and let us know whether upgrading your version of MySQL resolves the problem.
In reply to Helen Foster

Re: Zero users?! Search function returns no users yet accounts working and accessible

by Dan McMahon -

That looks very like the problem we've got. The SQL upgrade is tied into the same 'job' as the 1.6 upgrade so fingers crossed it'll get fixed - I'll post the outcome to this thread.

In the meantime, and in the spirit of maximising the use of this thread to any future confused person stumbling across it: I have been adding records to the mdl_user_teachers table by hand - taking the userid value from mdl_user's id field (identifying the Moodle user to be given teacher rights) and the course value from mdl_course's id field (identifying the course page). Save changes, return to your Moodle site and bingo! Be sure to let SQL generate the id field for mdl_user_teachers though, as it should be a unique identifier for that relationship.

Seems to be problem-free so far - don't believe any other data or function is dependent on this table, so outside-of-Moodle changes shouldn't be a problem - only doing by hand what Moodle would be able to do if SQL was behaving.