0

NOT A DUPLICATE - SEE SOLUTION IN EDIT AT THE BOTTOM

I've done my research and the solutions I've found haven't worked for me, not even the "duplicated" solution marked by the moderators, which has nothing to do with my problem

NOTE: I appreciate all the comments, but I can't just "change my code" as some suggest, this is Moodle, and it's supposed to work out of the box with PHP 7.2 and mysqli. It's either a problem of configuration that I'm missing or some bug that's making Moodle still use mysql even though I have it set up to use mysqli.

I've just upgraded a Moodle 3.2 site to Moodle 3.6. The upgrade process has seemingly gone fine, however I can't log into the site, I get the following error:

Exception - Call to undefined function mysql_connect()

The old site used to run on PHP 5.6, but I've upgraded the server's PHP 7.2 and installed all the required modules. I'm aware that on PHP 7 mysql has been deprecated, and following indications found online I've changed the dbtype to mysqli before the upgrade, as explained here: https://moodle.org/mod/forum/discuss.php?d=370774. I've made this change both in the site's admin area for the external enrolment plugin (before the Moodle upgrade) and in the database (after the upgrade).

I have also set $CFG->dbtype = 'mysqli'; in config.php.

After doing the Moodle upgrade, the site loads fine, until I try to login, when I get the aforementioned error. The site uses external database authentication for students, but the admin user is in the same database as Moodle (not in the external one).

Any ideas of how I can fix this? Looks like the error comes from Moodle insisting in using mysql instead of mysqli, but I don't know what else to change to prevent that... I've also purged caches and restarted db services to no avail.

This is the debug output when trying to login as an admin:

Debug info: 
Error code: generalexceptionmessage
Stack trace: 
line 461 of /lib/adodb/drivers/adodb-mysql.inc.php: Error thrown
line 492 of /lib/adodb/drivers/adodb-mysql.inc.php: call to ADODB_mysql->_connect()
line 667 of /lib/adodb/adodb.inc.php: call to ADODB_mysql->_nconnect()
line 867 of /enrol/database/lib.php: call to ADOConnection->Connect()
line 144 of /enrol/database/lib.php: call to enrol_database_plugin->db_init()
line 245 of /lib/enrollib.php: call to enrol_database_plugin->sync_user_enrolments()
line 486 of /lib/classes/session/manager.php: call to enrol_check_plugins()
line 4528 of /lib/moodlelib.php: call to core\session\manager::login_user()
line 199 of /login/index.php: call to complete_user_login()


EDIT (SOLUTION):

I can't post a solution because despite my requests this question keeps being locked, even though it's obviously not a duplicate, but I guess some are too proud... Anyways, since this may help someone else in the future, this is the solution:

The problem itself is that despite having changed the auth_db setting in the Site admin (Authentication Plugin -> External database) to mysqli, for some reason that wasn't getting updated in the database.

The solution has been to manually change that record in the database:

Table: mdl_config_plugins

Row: auth_db -> type set to mysqli
Albert
  • 1,516
  • 3
  • 24
  • 55
  • 1
    You are using php 7 `mysql_*` functions are completely removed to the new php versions, use `pdo` or `mysqli_*` – Masivuye Cokile Jan 17 '19 at 08:53
  • ‘External database authentication’ ? You mean to say you have manually tried connecting to this database? If so, you need to update your SQL api to mysqli or pdo – Jaquarh Jan 17 '19 at 08:56
  • @MasivuyeCokile I have already set up Moodle to use mysqli and it's stil happening, am I missing any setting somewhere? – Albert Jan 17 '19 at 08:56
  • Can you not specify the SQL driver you want to use in your config? `$CFG->dbtype = 'mysqli';` – Jaquarh Jan 17 '19 at 09:00
  • @Jaquarh I already have that – Albert Jan 17 '19 at 09:02
  • 1
    @MasivuyeCokile this is not a duplicate, have you read my question? The other one doesn't even mention Moodle. This is an issue with Moodle, please change that because it's misleading. My server has all extensions installed, none of the answers there solve my problem – Albert Jan 17 '19 at 09:05
  • Did you look at `$CFG->dbtype`n in the config file – RiggsFolly Jan 17 '19 at 09:23
  • @RiggsFolly yeah I have it set to `mysqli` already – Albert Jan 17 '19 at 09:28
  • Nominating to reopen as it's clearly NOT a duplicate of the one being referenced. – Adam Cameron Jan 17 '19 at 12:24
  • @AdamCameron thank you I wish people read past the title of 2 posts to declare them as duplicates – Albert Jan 17 '19 at 17:39
  • @Albert I just wish I had something to offer by way of a solution. But sorry I don't mate. – Adam Cameron Jan 17 '19 at 22:57
  • @AdamCameron you know the best part? Is that I just found the solution, which has nothing to do with the "duplicate" post. It's very sad that I can't post it because of the shortsightedness of some – Albert Jan 17 '19 at 23:42

0 Answers0