moodleou / moodle-mod_subpage

Subpage module allows you to add Moodle activities onto inner page within course
21 stars 15 forks source link

Upgrading moodle 2.5 to 2.7 with subpage mod #9

Closed tneath closed 9 years ago

tneath commented 9 years ago

I am using a test environment to see if it is possible to upgrade my existing Moodle 2.5 to Moodle 2.7

However I am having problems with courses that have the subpage module in use.

my method of upgrade is

Upgrade subpage from 2.4+ to latest 2.7 during the moodle upgrade process. so as I copy my plugins from the old Moodle to the new Moodle version I am replacing the mod/subpage folder with the 2.7 version

After this upgrade When I try to access a course that uses subpage in Moodle 2.7 I get a message saying.

Can not find data record in database table subpage.

sammarshallou commented 9 years ago

Hi, we are currently using Moodle 2.7 with subpage successfully on our live system, so the upgrade process does work. Also I just had a look and the subpage itself doesn't seem to have any database upgrade steps between 2.5 and 2.7. So don't know why it wouldn't work.

The error message sounds like it would happen in the following sequence. Suppose you have a url like mod/subpage/view.php?id=1234. Then it will look up entry with id 1234 in the mdl_course_modules table. From that it will look at the 'instance' field which will have another number, say 567. Then it will look up entry 567 in the mdl_subpage table. The error you've quoted would occur if, for some reason, there isn't an entry 567 in the mdl_subpage table.

I can't think of any reason why this would happen during a Moodle upgrade, but if you want to investigate, you'll probably need to look in your database as above, and see what's wrong with that table. For example maybe the 'instance' value somehow got set to 0, or maybe all the entries in mdl_subpage got deleted, something like that.

tneath commented 9 years ago

Thanks for the response. I looked at a url in my existing Moodle 2.5 as I cannot access the course in the Moodle 2.7 and found mod/subpage/view.php?id=3903 Now looking at the database on the Moodle 2.7 sever in mdl_course_modules I found id 3903 and this record gives instance 121 In mdl_subpage I found id 212 and the name field in this record contains the name I see in Moodle 2.5 so the mdl_subpage table exists and seems to contain the correct data.

sammarshallou commented 9 years ago

Oh I see, so you're looking at the course page when it crashes and not a subpage? Okay. I can probably work out a query you could use to investigate every subpage on the course to find out which one is missing, but first, how about if you try temporarily turning off subpage using the eye icon on admin / plugins / activity modules - does that make it work (obviously all the subpages will not appear, but other than that) or does it still break somewhere else? I'm wondering if there is a more general problem somehow.

tneath commented 9 years ago

Thanks for that. I have turned subpage off and can now access the course. I am also able to access documents in the subpage Orphaned activities sections above 111 at the bottom of the page once I turn editing on. With subpage on I am unable to access these documents even when I use the direct url ie /mod/resorce/view.php?id=11860 this produces the Can not find data record in database table subpage error.

sammarshallou commented 9 years ago

OK, it sounds like there's pretty definitely a missing subpage somewhere on that course. To identity it, try this db query:

select cm.id, cm.instance, s.id AS subpageid from mdl_course_modules cm left join mdl_subpage s on s.id = cm.instance where cm.module = (select id from mdl_modules where name='subpage') and cm.course = ????

with ???? being your course id.

There should be 3 columns of numbers, but look through the results to see if there are any where the last number (subpage id) is null, blank.

If this doesn't find any blank ones, it must be something else, I can think of another query to try probably...

tneath commented 9 years ago

Ok I have run the db query and found a row in the results that shows id 9643 instance 0 subpageid NULL I have deleted the row from mdl_course_modules and this has fixed the problem. As far as I can tell looking at the course in the live Moodle 2.5 version id 9643 does not show so it looks like in Moodle 2.5 an error of this type does not show and Moodle functions correctly. I had the same problem when I did a test upgrade to Moodle 2.6 so it looks like a code change between 2.5 and 2.6 Thanks for your assistance with this problem Sam.

sammarshallou commented 9 years ago

Brilliant! Glad you sorted it. Yes this sounds like incorrect information in the database (probably because the system crashed out halfway through doing something) which was previously ignored but now causes an error. By the way, I think there has been a change in newer versions to make this kind of incorrect data less likely to happen, but this doesn't help for existing data.