/enrol/database/cli/sync.php "Coding error detected"

/enrol/database/cli/sync.php "Coding error detected"

by David Meuleman -
Number of replies: 6

Attempting to do external database authentication and enrolment in Moodle 2.0 RC2.  Auth works fine.  Enrolment works fine when the user logs in.  However, if I try to run the sync program using the cli...

$sudo -u apache /usr/bin/php /var/www/html/enrol/database/cli/sync.php
!!! Coding error detected, it must be fixed by a programmer: PHP catchable fatal error !!!

I also tried to bulk add users via /var/www/html/auth/db/cli/sync_users.php, and that worked correctly.

Average of ratings: -
In reply to David Meuleman

Re: /enrol/database/cli/sync.php "Coding error detected"

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hmmm, strange. I have just run enrol/database/cli/sync.php (in a local test install) and it has run flawlessly. But I updated the install just before running the test with the latest code from git.moodle.org (so it might happen that someone has fixed the coding error between your test and mine).

I run my tests on Debian (Squeeze), using Apache 2.2.16, PHP 5.3.3 and MySQL 5.1.49 for both Moodle and external enrolment database.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: /enrol/database/cli/sync.php "Coding error detected"

by David Meuleman -

CentOS 5.5, Aacphe 2.2.3, PHP 5.3.3, MySQL 5.0.77.  External enrolment db is on the localhost.

Just used git to install 2.0 RC2 (Build: 20101124).  Same error.

Turned on debugging for developers.

Default exception handler: Coding error detected, it must be fixed by a programmer: PHP catchable fatal error Debug: Argument 3 passed to enrol_database_plugin::db_get_sql() must be an array, boolean given, called in /var/www/html/enrol/database/lib.php on line 359 and defined
* line 351 of /lib/setuplib.php: coding_exception thrown
* line 578 of /enrol/database/lib.php: call to default_error_handler()
* line 359 of /enrol/database/lib.php: call to enrol_database_plugin->db_get_sql()
* line 47 of /enrol/database/cli/sync.php: call to enrol_database_plugin->sync_enrolments()

!!! Coding error detected, it must be fixed by a programmer: PHP catchable fatal error !!!
!! Argument 3 passed to enrol_database_plugin::db_get_sql() must be an array, boolean given, called in /var/www/html/enrol/database/lib.php on line 359 and defined !!
!! Stack trace: * line 351 of /lib/setuplib.php: coding_exception thrown
* line 578 of /enrol/database/lib.php: call to default_error_handler()
* line 359 of /enrol/database/lib.php: call to enrol_database_plugin->db_get_sql()
* line 47 of /enrol/database/cli/sync.php: call to enrol_database_plugin->sync_enrolments()
!!
In reply to David Meuleman

Re: /enrol/database/cli/sync.php "Coding error detected"

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi David,

can you try the attached patch[1] and see if it makes a difference?

Saludos.
Iñaki.

[1] If you don't know how to apply a patch, have a look at http://docs.moodle.org/en/Development:How_to_apply_a_patch
In reply to Iñaki Arenaza

Re: /enrol/database/cli/sync.php "Coding error detected"

by David Meuleman -

Thanks.

I installed Wednesday's release this morning and applied this patch.  It is no longer producing the error.  However, there is still one hitch.

If I create a course, and immediately run the sync program, it does not enrol anybody in the course.  If I log in as one of the students in that course, it adds me to the course.  Then, if I run the sync program, it enrols everybody else.

It seems to be tied to needing at least one person to be enroled via the external database.  If I manually add somebody to the course and then run the sync program, it does not enrol the users.

In reply to David Meuleman

Re: /enrol/database/cli/sync.php "Coding error detected"

by David Meuleman -

I added the following function to the enrol_database_plugin class in /enrol/database/lib.php

public function add_default_instance($course) {
$fields = array();
return $this->add_instance($course, $fields);
}

Then, I inserted a row in the config_plugins table:

INSERT INTO `mdl_config_plugins` (`plugin`, `name`, `value`) VALUES ('enrol_database', 'defaultenrol', '1');

Everything works great now.  Would be nice to have a place in the plugin config for that defaultenrol value.