Error Upgrading to v3.0.53

Error Upgrading to v3.0.53

by Simon Brock -
Number of replies: 6

Hi All,

Just trying to upgrade the latest hotpot v3.0.53 and recieve the following error, i am running moodle 2.4.1

Debug info: SELECT id,category FROM {course} WHERE id = ?
[array (
0 => '10443',
)]
Error code: invalidrecord
Stack trace:
  • line 1357 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1333 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
  • line 6541 of /lib/accesslib.php: call to moodle_database->get_record()
  • line 2005 of /calendar/lib.php: call to context_course::instance()
  • line 1939 of /calendar/lib.php: call to calendar_event->calculate_context()
  • line 2532 of /calendar/lib.php: call to calendar_event->__construct()
  • line 1772 of /mod/hotpot/lib.php: call to calendar_event::create()
  • line 1615 of /mod/hotpot/lib.php: call to hotpot_update_events()
  • line 627 of /mod/hotpot/db/upgrade.php: call to hotpot_refresh_events()
  • line 629 of /lib/upgradelib.php: call to xmldb_hotpot_upgrade()
  • line 360 of /lib/upgradelib.php: call to upgrade_plugins_modules()
  • line 1544 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 349 of /admin/index.php: call to upgrade_noncore()
Average of ratings: -
In reply to Simon Brock

Re: Error Upgrading to v3.0.53

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Simon,
it seems that one of the records in the "hotpot" table on your Moodle DB says its "course" field is "10443", but there is no record in the "course" table whose "id" field is "10443". Could you check that please?

Gordon

In reply to Gordon Bateson

Re: Error Upgrading to v3.0.53

by Simon Brock -

Hi Gordon,

that is correct - the record 10443 appears 11 times in the hotpot table but does not exist in the course table

Simon

In reply to Simon Brock

Re: Error Upgrading to v3.0.53

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Thanks for confirming that Simon.

The following SQL will help you discover how many of these orphaned HotPots you have:

  • ## =====================================
    ## HotPots with a non-existant course id
    ## =====================================
    ##
    SELECT h.id AS hotpotid, h.course AS courseid, h.name AS hotpotname
    FROM mdl_hotpot h LEFT JOIN mdl_course c ON h.course=c.id
    WHERE c.id IS NULL

Do you recgnize those HotPots? Do you notice anything similar between them? Do you know who created these HotPots?

I wonder how orpahned they are. The following SQL will show you if the orphaned HotPots have any associated course module activity records:

  • ## =====================================
    ## course modules (=activities)
    ## for HotPots with a non-existant course id
    ## =====================================
    ##
    SELECT
    cm.id AS coursemoduleid,
    h.id AS hotpotid,
    h.course AS courseid,
    h.name AS hotpotname
    FROM
    mdl_course_modules cm
    LEFT JOIN mdl_modules m ON cm.module=m.id
    LEFT JOIN mdl_hotpot h ON cm.instance=h.id
    LEFT JOIN mdl_course c ON h.course=c.id
    WHERE
    m.name='hotpot' AND c.id IS NULL

BTW, the course id of 10443 suggests that this site has 10,443 courses. That's a lot of courses! Does that seems like a probable number to you?

Can you give any more information on how your Moodle site evoled  over the years to its current state? And in particular, what do you know or surmize about how these particular HotPots, the ones with course id = 10443, came to be there?

cheers
Gordon

In reply to Gordon Bateson

Re: Error Upgrading to v3.0.53

by Simon Brock -

Hi Gordon,

the first sql query returned

+----------+----------+------------------------------------------+
| hotpotid | courseid | hotpotname                               |
+----------+----------+------------------------------------------+
|     3244 |    10443 | Experimental Reports                     |
|     3245 |    10443 | Experimental Reports Jumble              |
|     3246 |    10443 | Scientific Investigation CROSSWORD (1)   |
|     3247 |    10443 | Crossword Puzzle                         |
|     3248 |    10443 | Sci-Words (Chapter 1 Being a Scientist)  |
|     3249 |    10443 | Planet Match Up- Easy                    |
|     3250 |    10443 | Planet Match Up- Medium                  |
|     3251 |    10443 | Planet Match Up - Hard                   |
|     3252 |    10443 | Earth and Space                          |
|     3253 |    10443 | Solar System Crossword.                  |
|     3254 |    10443 | Planets of the solar system (p166 - 168) |
+----------+----------+------------------------------------------+

the second retuned empty

the site has approx 600 courses and has been upgraded since moodle 1

regards,
Simon

In reply to Simon Brock

Re: Error Upgrading to v3.0.53

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Simon,
that is good information. It looks like this issue in confimed to those HotPots.

It seems that these HotPots are all alone and not needed so I suggest you delete them (and their associated attempts), so that you can move on with the upgrade.

Here is some SQL to remove the orphan HotPots and their associated records:

  • ## =====================================
    ## delete all records associated with
    ## HotPots having a non-existant course id
    ##
    ## NOTE: be sure to run these commands in
    ## exact order that they appear here smile
    ## =====================================
    ##
    DELETE FROM mdl_hotpot_responses WHERE attemptid IN (
     SELECT id FROM mdl_hotpot_attempts
     WHERE hotpotid IN (3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254)
    );
    DELETE FROM mdl_hotpot_details WHERE attemptid IN (
     SELECT id FROM mdl_hotpot_attempts
     WHERE hotpotid IN (3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254)
    );
    DELETE FROM mdl_hotpot_cache WHERE hotpotid IN (
     3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254
    );
    DELETE FROM mdl_hotpot_questions WHERE hotpotid IN (
     3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254
    );
    DELETE FROM mdl_hotpot_attempts WHERE hotpotid IN (
     3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254
    );
    DELETE FROM mdl_hotpot WHERE id IN (
     3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254
    );

Please let me know how you get on, and whether, having run these SQL commands, you can then upgrade successfully.

regards
Gordon

In reply to Gordon Bateson

Re: Error Upgrading to v3.0.53

by Simon Brock -

Hi Gordon,

After removing the orphaned records it upgraded successfully.  Thank you very much for your help in solving this problem 

thanks again

regards,
Simon