Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by byron catechis -
Number of replies: 5
Debug info: Table 'db264795_359.mdl_course_modules_availability' doesn't exist

SELECT COUNT(1)
FROM mdl_course_modules cm
WHERE cm.availablefrom != 0 OR
cm.availableuntil != 0 OR
EXISTS (SELECT 1 FROM mdl_course_modules_availability WHERE coursemoduleid = cm.id) OR
EXISTS (SELECT 1 FROM mdl_course_modules_avail_fields WHERE coursemoduleid = cm.id)
[array (
)]
Error code: dmlreadexception
Stack trace:
  • line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1476 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1549 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1759 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 3395 of /lib/db/upgrade.php: call to moodle_database->count_records_sql()
  • line 1560 of /lib/upgradelib.php: call to xmldb_main_upgrade()
  • line 361 of /admin/index.php: call to upgrade_core()
Average of ratings: -
In reply to byron catechis

Re: Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by byron catechis -

I am sorry, in reference to my request above, any suggestions as to how to solve the problem, would be greatly appreciated... with not being able to go further with the upgrade, I feel reasonably lost...

Any suggestions how to solve the problem so that the upgrade will complete normally, would be very helpful!

In reply to byron catechis

Re: Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by Ken Task -
Picture of Particularly helpful Moodlers

First, hope you have: 1) done a full site backup of the 2.5.8 and 2) you are working with a sandbox copy of the 2.5.8 to see how things go.

The tables referenced in the error do exist in a 2.5.x and a 2.6.x, but do NOT exist in a fresh 2.7.3 to which I have access - but the fresh 2.7 site is not using that advanced feature.  No such tables are created when that advanced feature is turned on.   And there is no course that has used that feature.

Setting found in Advanced site settings - availability.   Suggest disabling in the 2.5.x sandbox site, then making the march via git to 2.6 and then to 2.7.  Tables may have been consolidated into other tables for the feature, don't know that for sure - just guessing here!

You might have discovered a bug! (lucky you, huh? :\)

'spirit of sharing', Ken

In reply to Ken Task

Re: Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by byron catechis -

Dear Ken,

thank you for the suggestion, the only backup I use is the one for all my websites on the server, and will not be able to access the last version until Monday...

Have access on the server "backend" to moodle/availability/classes/info_module.php

I have found the following code... am not sure if I am in the right place...


namespace core_availability;

defined('MOODLE_INTERNAL') || die();

/**
 * Class handles conditional availability information for an activity.
 *
 * @package core_availability
 * @copyright 2014 The Open University
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class info_module extends info {
    /** @var \cm_info Activity. */
    protected $cm;

    /**
     * Constructs with item details.
     *
     * @param \cm_info $cm Course-module object
     */
    public function __construct(\cm_info $cm) {
        parent::__construct($cm->get_course(), $cm->visible, $cm->availability);
        $this->cm = $cm;
    }

    protected function get_thing_name() {
        // We cannot access $cm->name as a property at this point, because this
        // code may itself run in response to the $cm->name property access, and
        // PHP magic function properties do not allow recursion (because PHP).
        return '<AVAILABILITY_CMNAME_' . $this->cm->id . '/>';
    }

    protected function set_in_database($availability) {
        global $DB;
        $DB->set_field('course_modules', 'availability', $availability,
                array('id' => $this->cm->id));
    }

    /**
     * Gets the course-module object. Intended for use by conditions.
     *
     * @return \cm_info Course module
     */
    public function get_course_module() {
        return $this->cm;
    }

    public function get_context() {
        return \context_module::instance($this->cm->id);
    }

P.S. I have only copied and pasted the first part of the code... let me know if I can "bypass" the problem here... thank you (am attaching the info_module.php file

Byron

In reply to byron catechis

Re: Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by Ken Task -
Picture of Particularly helpful Moodlers

Sorry, not a coder, but the error said:

Debug info: Table 'db264795_359.mdl_course_modules_availability' doesn't exist

When one starts hacking code to bypass an issue in one file, one might discover a chain of files need to be edited.   Then, if one is successful in upgrading, will the future hold some interesting times?

Maybe what we need to do is create an empty course_modules_availability table.

If you have access to the DB for the 2.5.8 does it have that table?

Hmmmm .... are you remotely hosted?   Full access to system?   Is there any restriction on system ... like number of files or DB restriction ... number of tables or table creation.

I have done one git upgrade from 2.5.x to 2.6.x and then to 2.7.highest and didn't have the issue but am also on a dedicated server with no such restrictions.

'spirit of sharing', Ken
In reply to Ken Task

Re: Moodle uprade from 2.5.8 to 2.7.3 - error message: course modules availablility does not exist.

by byron catechis -

Thanks Ken for your input, it is appreciated.

I will sleep on it and let you know how I deal with this. Part of the problem with my 2.5.8 version might be that with the 2.5.1 I had a problem with the "Essential" template which messed my database up... I had to go back to the last backup and could not access certain activities on my courses.

I think that I will probably ask the administrator of the server to use the last backup and I will then use the 2.6. and then the 2.7 upgrades as you had suggested.

Some of my problems were sorted with the upgrade to 2.5.8 however, some "latent ones" might also be hanging around in the background.

Yesterday, I updated my wife's moodle database from 2.5.1 directly to 2.7.3 without a hitch...  it might just be the 2.5.8 version or the latent problems from the Essential upgrade hanging around...

No worries, for every problem there is a solution, not necessarily the cheapest or the fastest to get back up and running.

With regards from Switzerland,

Byron