-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
3.2
-
None
-
MOODLE_32_STABLE
Context :
I'm on a course, trying to get a scorm (It's a geogebra exercice)
Error :
Error: mdb->get_record() found more than one record!
- line 1563 of /lib/dml/moodle_database.php: call to debugging()
- line 1523 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
- line 1502 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
- line 1896 of /mod/scorm/locallib.php: call to moodle_database->get_record()
- line 932 of /mod/scorm/locallib.php: call to scorm_get_toc()
- line 176 of /mod/scorm/view.php: call to scorm_print_launch()
Problem :
So here is the line that trigger the error :
$organizationsco = $DB->get_record('scorm_scoes', array('scorm' => $scorm->id, 'identifier' => $currentorg)); |
When I looked at the database (table scorm_scoes) to see what was the problem, I saw that concat(scorm, '-', identifier) do have double, wich makes sense since that's the error I was getting yay
Here is the (simple) query I used to see what were the lines affected (you may want to add a limit):
select concat(scorm, '-', identifier), count(concat(scorm, '-', identifier)) from mdl_scorm_scoes group by concat(scorm, '-', identifier) order by count(concat(scorm, '-', identifier)) desc |
For each scorms that have the problem, there is two lines in mdl_scorm_scoes :
- first :
- parent = '/'
- identifier = 'main'
- launch = ''
- scormtype = ''
- title = 'GeoGebra Applet'
- second :
- parent = 'main'
- identifier = 'MAIN'
- launch = '<some-address>'
- scormtype = 'sco'
- title = '<some-title>'
Since MySQL is not case sensitive, the 'main' and 'MAIN' identifier are considered as the same and we have multiple rows that correspond to the search.
Fix :
I replaced the get_record with a get_record_sql doing a supplementary check on the 'launch' :
$organizationsco = $DB->get_record_sql('select * from {scorm_scoes} where scorm = :scormid and identifier = :identifier and launch = \'\'', array('scormid' => $scorm->id, 'identifier' => $currentorg));
|
Next :
I don't know if testing the emptyness of 'launch' is really a good idea, it may create other bugs, but right now it fixed the problem for me.
I hope I gave enough clues
- duplicates
-
MDL-38060 Warn the user when uploading a package that uses identifiers not uniquely defined in imsmanifest.xml
- Closed