Moodle

rebuild_course_cache() is called in the upgrade script without mdl_context_rel existing

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.3
  • Fix Version/s: 1.8.4
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Environment:
    Postgres 8.1
  • Database:
    PostgreSQL
  • Affected Branches:
    MOODLE_18_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE

Description

It probably only needs a "if (table_exists(...))" around the rebuild_course_cache() call in lib/db/upgrade.php (line 48).

Here is an upgrade log of a 1.6 to 1.8 upgrade without the rebuild_course_cache() calls commented out. I get errors like these:

(postgres7): DELETE FROM mdl_context_rel WHERE c2 = '1'
Warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "mdl_context_rel" does not exist in /home/francois/code/private-moodle-r2/lib/adodb/drivers/adodb-postgres7.inc.php on line 115
-1: ERROR: relation "mdl_context_rel" does not exist

ADOConnection._Execute(DELETE FROM mdl_context_rel WHERE c2 = '1', false) % line 890, file: adodb.inc.php
ADOConnection.Execute(DELETE FROM mdl_context_rel WHERE c2 = '1') % line 1282, file: dmllib.php
delete_records(context_rel, c2, 1) % line 4077, file: accesslib.php
insert_context_rel(Object:stdClass) % line 1772, file: accesslib.php
create_context(70, 1260) % line 1986, file: accesslib.php

If you need any help testing this on Postgres, let me know.

Activity

Hide
Yu Zhang added a comment -

Hi Francois,

I don't think rebuild_course_cache() would be touching the context_rel table. Could you please try to uninstall the facetoface module and try the upgrade from 1.6 to 1.8 again?

Cheers,

Yu

Show
Yu Zhang added a comment - Hi Francois, I don't think rebuild_course_cache() would be touching the context_rel table. Could you please try to uninstall the facetoface module and try the upgrade from 1.6 to 1.8 again? Cheers, Yu
Hide
Yu Zhang added a comment -

Or perhaps a custom assignment plugin that uses contexts in get_coursemodule_info() call.

Show
Yu Zhang added a comment - Or perhaps a custom assignment plugin that uses contexts in get_coursemodule_info() call.
Hide
Francois Marier added a comment -

You were right Yu. The problem was caused by mod/assignment and the upgrade works fine if I delete the module.

I'll test that again and close the bug. Assigning to myself in the meantime.

Thanks for catching that and sorry for bothering you with some custom broken code

Show
Francois Marier added a comment - You were right Yu. The problem was caused by mod/assignment and the upgrade works fine if I delete the module. I'll test that again and close the bug. Assigning to myself in the meantime. Thanks for catching that and sorry for bothering you with some custom broken code
Hide
Francois Marier added a comment -

Actually, it doesn't come from any custom code. If you look into mod/assignment/lib.php on MOODLE_18_STABLE, in function assignment_get_coursemodule_info(), you will find this call:

$ass = new $assignmentclass($coursemodule->id, $assignment);

which runs the code from the base class at the top of the same file, in function assignment_base(). That code uses context information.

If I put a "return false" just before the new call on line 2354, the upgrade errors go away.

Show
Francois Marier added a comment - Actually, it doesn't come from any custom code. If you look into mod/assignment/lib.php on MOODLE_18_STABLE, in function assignment_get_coursemodule_info(), you will find this call: $ass = new $assignmentclass($coursemodule->id, $assignment); which runs the code from the base class at the top of the same file, in function assignment_base(). That code uses context information. If I put a "return false" just before the new call on line 2354, the upgrade errors go away.
Hide
Yu Zhang added a comment -

Merci, changed this call to call_user_func(array($assignmentclass, 'get_coursemodule_info'), $coursemodule); so that the assignment object will not be created and thus no context creation. Problem does not exist in 1.9 and above as context_rel has been removed. Cheers,

Yu

Show
Yu Zhang added a comment - Merci, changed this call to call_user_func(array($assignmentclass, 'get_coursemodule_info'), $coursemodule); so that the assignment object will not be created and thus no context creation. Problem does not exist in 1.9 and above as context_rel has been removed. Cheers, Yu

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: