When I look at the subscribers of a certain forum, I get warnings like the one below, repeated as many times as the number of subscribers:
Did you remember to make the first column something unique in your call to get_records? Duplicate value '4548' found in column 'id'.
line 1184 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
line 455 of /mod/forum/classes/subscriptions.php: call to mysqli_native_moodle_database->get_records_sql()
line 114 of /mod/forum/subscribers.php: call to mod_forum\subscriptions::fetch_subscribed_users()
The debug level is DEVELOPER.
The system is Debian Stretch (9.7), PHP 188.8.131.52.9.1, mariadb (5.5.5-10.1.37-MariaDB-0+deb9u1). The code is clean (new Git) Moodle 3.1.15+ (Build: 20181120).
The story behind the site is a bit complicated. It is a test migration and upgrade of a 2.5.2+ (Build: 20130927) from a site on a Siteground shared hosting plan. I transferred the data first on to a Debian Wheezy (7.11) and upgraded to 2.7. Then transferred that to the current server Debian Stretch and upgraded to 3.1.
One thing I did not notice was that $CFG->dbtype was 'mysql' the whole time. I believe on Wheezy it should have been 'mysqli' and on Stretch 'mariadb'. I changed it to 'mariadb' only after the two migrations and upgrades. My first question is whether that could be the cause and how to find these duplicates?
The forum which gives these warnings is in a course which I restored from a course backup I made somewhere during the upgrade march. It is the same course a later version. Restored with users. This course has another forum, with the same subscribers. But that does not throw these warnings. How could that be explained?
As that's quite a complicated function, I would start by getting the exact SQL that was executed and see what it looks at. As all the fields come from the 'user' table then having a duplicate id value seems very odd. You may want to check that table and make sure it is properly indexed. The id field should be unique.
...the easiest thing is to enable it just before the offending database call.