Beta1.1 - Moving Stuff

Beta1.1 - Moving Stuff

by Howard Miller -
Number of replies: 9
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Possible really nasty problem...

I upgraded one of our sites from 1.0.9. to 1.1

A user almost immediately reported that they moved a section within a course and the contents vanished.

I created some dummy content and moved it about a bit, both by moving the individual items and the whole section. It worked ok once or twice and then, indeed, the content vanished.

I am working on reproducing this repeatly, but I'm a bit worried!

HM
Average of ratings: -
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
OK... it does NOT do this when I create a new course and then move stuff about. It seems to relate to an existing course.

Is it possible that the database has been corrupted during the upgrade. Is there an easy way to spot what might have happened.

I'm going to have a dig into the tables anyway and see if I can spot anything.

Any help appreciated
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Wierd, because this stuff has been in CVS since soon after 1.0.9 was released and I've never had a problem with it.

Try looking for duplicate records ...

I'm off to party for half an hour and then bed - it's my birthday and I've spent the whole day Moodling. mixed

Let me know how you go.
In reply to Martin Dougiamas

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Mmm....

Need a bit of help here.

What happens is this... All visible sections are populated. You try to move section 1 down. Section 1 contents now appear as section 2. Section 1 is now an empty section. Section 2 contents are missing in action.

I checked the DB. Table course_sections indeed has both entries set to section=2. Ok, I manualy changed one of them to section 1 and refreshed the course page. No difference!

So I suppose the question is, what other than the course_sections table would cause a section to appear empty. (The sequence and summary lists are present and correct)
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Tom Murdock -
I can confirm this problem. I only have trouble with section 1 & 2. As an aside, Howard, are you able to hide this new empty section 2? Mine stubbornly stays visible.

-Tom
In reply to Tom Murdock

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes indeed, my empty section 1 will not hide either, although in the database the flag has correctly changed to zero.

Worth noting that I created a new course with the same layout, filled it full of dummy material and it seems to work fine. Mmmm...
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Bit more info.....

OK... I can ow fix and then reproduce this quite easily.

I have 12 sections displayed, all populated. I click the down arrow on section 1. The visual result is that section 1 becomes section 2. The new section 1 is empty and the old contents of section 2 have vanished.

In the database both course_sections entries are now numbered as section=2. However closer inspection reveals that section 1 has appeared at the end of the table as a new empty section.

The fix therefore, is to delete the new section 1 entry and correct the duplicate section numbers. The course then displays correctly.

However, if you move it again, exactly the same thing happens... so I'm off to look at the move code. Looks like a bug though!

Got IT...... Kind of.... if section 2 comes before section1 in the database table. view.php seems to think that there isn't a section 1 and generates the empty one. This would also hold for both being numbered 2. This isn't the whole answer, but it certainly doesn't help. I need to establish why they both get numbered 2 in the first place. Onwards...
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yet more info.

I have traced this back to "move_section" function in course/lib.php. The first

update_record("course_sections", $sectionrecord);

returns false. Getting there......

PS. Moving sections 3+ down does nothing (except show up this error).

PPS. The move_section function returns its status, but this isn't checked or trapped! Grrrrrrrr.....
In reply to Martin Dougiamas

Re: Beta1.1 - Moving Stuff

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Got It!

Its single quotes in the summary. It breaks the SQL. I have reported it as a bug

http://moodle.org/bugs/bug.php?op=show&bugid=641

I don't understand how this is sorted elsewhere (eg, when the summary is edited). Is there some sort of special character escaping function that was overlooked for the move functions??
In reply to Howard Miller

Re: Beta1.1 - Moving Stuff

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Ah, well done, thanks Howard. I've fixed it in CVS.

Magic quotes takes care of all cases except when transferring data straight from the database to the database (which is rare, and in this particular case, not even necessary).