Upgrade to 1.9.3 with a minor glitch or 2

Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Number of replies: 16
I upgraded from 1.9.1 to 1.9.3 - mostly to utilize the demo training course.

It seems to mostly work, but I don't seem to be able to access an admin panel once the upgrade is complete.

It allows me to login as admin - but I can't seem to get to a page that allows me to have the ability to turn editing on or access the admin panel.

Any thoughts???

Happy New year!!!

Paul
Average of ratings: -
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

It seems strange that such a minor upgrade (within the 1.9.x range) would cause this to happen, but this is what it looks like has happened:

Moodle remembers that there is a user named admin, and what its password is, but it doesn't seem to remember what role that user has, or what capabilities that role should have. Since you no longer have Administrator capabilities, the only way you can determine the problem and fix it (besides restoring the old version) is to directly manipulate the database.

Assuming your database type is MySQL, you can use your favorite MySQL client program, such as phpMyAdmin, to look at these tables (assuming your table prefix is the default, mdl_):

mdl_user
mdl_role
mdl_role_assignments
mdl_role_capabilities

First, look in mdl_user for a row in which username is admin, and note the value of id. This is your user id. To do this with a query:

select id from mdl_user where username='admin';

Second, look in mdl_role_assignments for rows where userid is your user id, and note the value of roleid. There will probably be more than one, because there are different contexts. On my Moodle site, there are two rows, and in both the roleid is 1. Look in the mdl_role table to see the name of that role by looking for a row in which id matches the roleid from mdl_role_assignments, and looking at the value of name. Query:

select name from mdl_role,mdl_role_assignments where userid=U and mdl_role.id=roleid;

where U is your user id. This name should be Administrator. If it is not, that is your problem.

If the name of your role is correct, you need to look at all the rows in mdl_role_capabilities where roleid is your role id from the mdl_role_assignments table, and see what the values are in the capability column. Query:

select capability from mdl_role_capabilities,mdl_role_assignments where userid=U and mdl_role_capabilities.roleid=mdl_role_assignments.roleid;

where U is as in the previous paragraph.

When I ran this query, I got 382 rows. That's probably how many capabilities there are, because Administrator is supposed to have all capabilities.

See:

http://moodle.org/mod/forum/discuss.php?d=66281 (complex)
http://moodle.org/mod/forum/discuss.php?d=82400#p364679 (mine, on role assignment)
http://moodle.org/mod/forum/discuss.php?d=85883#p380354 (mine, on role capabilities)
http://moodle.org/mod/forum/discuss.php?d=105845#p465951
http://moodle.org/mod/forum/discuss.php?d=112573#p494081

RLE
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Thanks Richard.

I've sorted out that as admin, I do have admin rights. Can edit courses etc.

But, once I've logged in, I still can get access to the site administration panel.

Is there a work around for this?

Cheers
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

You say you have admin rights, but do you have all of them? As I said in my previous post, in my Moodle site on my PC when I log in as admin, I have almost 400 capabilities. How many do you have? Maybe you are missing one or more capabilities that are necessary to get the Administration menu.

When I log in as admin from the front page, it takes me back to the front page with the Administration menu on it. If you are not getting that, maybe it is because of a missing capability.

RLE
In reply to Richard Enison

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Thanks for your post - you've nailed on the head what I was looking for - the front page with the Administartion Menu.

Checked the SQL queries - I am admin. Checked the capabilities - I have 201. I have enclosed a word doc with export from the query showing what I have. A "Yes Minister" kind of question - which capabilities am I missing, and how do I get them back????

Cheers
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

As I said earlier today in another thread (http://moodle.org/mod/forum/discuss.php?d=113203#p496992), I was mistaken about there being almost 400 capabilities. It must be counting them twice because there are different contexts. The fact is I have less than 200. You have a few more, probably because you are running 1.9.3 and I am running 1.9.1. And as I also said in the other thread, I checked the "definition of the has_capability function in lib/accesslib, and it does look like it treats roles that have the moodle/site:doanything as having all capabilities in any case, as one would expect from the name." Which means that if your username, admin, has the role with id 1, based on the data in your attachment, you should be able to do anything. Lacking a capability should not be your problem.

I have been trying to track down where in the code it decides whether to include the Administration Menu on the front page. I haven't found it yet, but I'm sneaking up on it. I'll try to get back to you when I do.

RLE
In reply to Richard Enison

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Thank you Richard
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

OK. Just for laughs, here's a thought. I'm still working on the problem. In the course of doing that, I am reviewing the docs on roles and capabilities, and I have come across this: Is it possible that at some point, you accidentally clicked on the "Switch role to ..." menu, or clicked on it to see what a page would look like to a student or some other role, and forgot about it and never switched back to admin?

RLE
In reply to Richard Enison

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
I could almost guarantee I didn't switch roles.

Cheers
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

OK. Here's another question that, depending on your answer, could expedite my search for the cause of the problem:

Getting back to the database: in the table mdl_block, I believe you will find a row in which the value of name is admin_tree. If not, that is a problem. Note the value in the id column. In my database, it is 4. Now look in the table mdl_block_instance, for a row in which blockid is the same number. To do this with a query:

SELECT mdl_block_instance.* FROM mdl_block_instance,mdl_block WHERE blockid=mdl_block.id AND name='admin_tree';

As you probably know, I have used all uppercase letters for the SQL keywords and lowercase letters for the names of tables and columns. The query does not need to be typed in that way.

Anyway, I get two rows when I run that query: one for pagetype course-view, and one for admin. The front page of your site is the course-view type, because the site is a course. But if you click on one of the items on the admin menu, you will find yourself on an admin page, with the same menu on it.

[EDIT: I forgot to mention what the question was! How many rows do you get? If it is 0, that's the problem.]

BTW, on my front page, the admin menu is at the bottom of the left column. Do you have a vertical scroll bar on yours? If so, have you tried scrolling down to see if you can find the menu?

RLE
In reply to Richard Enison

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
I seem to have the same values a you. The only thing that looked odd to me - (and I'm not really sure what I'm looking at in moodle terms) - is the position.

I've inlcued a screen dump for you.

My ID was 4, and it returned the 2 rows.

I can supply you with access if you need it, but I can't set up a new account - can't get access to the admin menu.

Cheers


In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

The query result shown in your screen dump looks fine. It's just like mine, including the position column, showing a lower case L for Left, indicating the left column of the page. It could have been r or c. Look at the rest of the mdl_block_instance table and you'll see.

This makes your problem all the more puzzling. Yours and CM's are even more similar than it appeared at first. I have given both of you links to each other's threads. In your case, it is in my post of just over 48 hours ago. Both of you are able to log in as admin with the admin role which has the doanything capability, yet you are both not getting things on your pages that you should. In your case, blocks are missing (admin, admin_tree). In her case, the list of assignable roles appears to be empty. I gave her tables to look at in the database to see why the list is empty. Now I wouldn't be surprised if she checks those tables and finds everything as it should be. Your problems are not in the database, it seems, but elsewhere. Who knows? You both might benefit from reading each other's threads.

In the meantime, I'm going to think about how to pin down the cause of your problem while I wait for a reply from her.

RLE
In reply to Richard Enison

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Will it be simpler to just re-install Moodle 1.9.3??

Cheers
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
As I was trying to work out what's going on here - I went to My Moodle.

Tried to add a Site Administration block to my page - and it's sent the page out of whack. But with no Site Administration Block.

Don't know whether it's relevant, but I hoped it might help shine some new light onto my problem.

Cheers
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Hope this doesn't confuse things, but I just tried an upgrade on my hosted Moodle - hosted with LVCS Plesk. It was an upgrade from a 1.8 version to 1.9.3 weekly used in the root of this problem.

In that system, I had debugging turned on. It returned this error message:
"Fatal error: Call to undefined function admin_get_root() in /var/www/vhosts/rightintoit.com/httpdocs/moodle/blocks/admin_tree/block_admin_tree.php on line 104"

From a noob's point of view this looks similar to my main problem. Thought it may help.

Cheers


In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by Richard Enison -
PR,

No, that's interesting. And to answer your earlier question (wouldn't it be simpler to re-install?), that depends. It depends on what the cause of the problem is. If there is a corrupted file somewhere among your Moodle script files, and downloading and installing over it fixes that, the answer is obviously yes. But what if it is more subtle than that, and re-installing gets you right back where you are now? Then the answer is no, except that at least you would know (hopefully) that the problem lies elsewhere. I say hopefully because the problem could be in the download process itself, so that every time you download Moodle again, it gets corrupted somewhere. Doesn't seem too likely, but it does happen. There are ways of confirming file integrity in downloading, but let's cross that bridge when our chickens have hatched.

Anyway, yes, that error definitely does appear to be related to your problem, although you didn't report getting that error before. Maybe that's because you didn't have debugging and error-logging on. The function admin_get_root should not be coming up as undefined. It is a very basic function in Moodle, and it is defined in lib/adminlib.php, around line 4058. The line in block_admin_tree just before 104 (it's line 113 in the published cross-reference listing) requires that file, so if it was missing you should have gotten an error from the require_once statement. Perhaps it is there, but corrupted. But what are the odds that you have Moodle on two servers with the same corrupt file in both? Pretty high, if one was copied from the other, or from a backup of the other.

And if you do re-install, be sure to delete all vestiges of the old installation (after backing up, just in case!). There could be a file somewhere that doesn't belong that is causing problems, and if you just re-install on top of the same directory, it won't get overridden.

RLE
In reply to paul rayner

Re: Upgrade to 1.9.3 with a minor glitch or 2

by paul rayner -
Richard
I successfully created a "parallel universe" using the same moodle package - all without trouble.
Busily migrating courses across now.
Thanks so much for your help, encouragement and interest.

Your support is why I choose Open Source software.

Cheers