Create courses using API

Re: Create courses using API

by daniel parejo -
Number of replies: 0
Hi everyone,

As i keep trying to solve this, i look at the server logs where i have this moodle and saw this error:

Got error 'PHP message: Potential coding error - active database transaction detected during request shutdown:\n* line 261 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->start_delegated_transaction()\n* line 858 of /course/externallib.php: call to mysqli_native_moodle_database->start_delegated_transaction()\n* line 1499 of /webservice/lib.php: call to core_course_external::create_courses()\n* line 1345 of /webservice/lib.php: call to webservice_base_server->execute()\n* line 44 of /webservice/rest/server.php: call to webservice_base_server->run()\n'

So i go to the first file where the error is mentioned and comment one line:

/**
* On DBs that support it, switch to transaction mode and begin a transaction
* @return moodle_transaction
*/
public function start_delegated_transaction() {
$this->set_dbhwrite();
//return parent::start_delegated_transaction();
}

First of all, yes, my database support transactions, it is MariaDb and all the tables are in InnoDB format.

As seen in the code, if i comment the return line, the course is created correctly, but this code is core so i cant comment this, i hope this info help someone to help me find the solution.

Thanks