Moodle 3.5+ and H5P 1.17 SQL dmlreadexception

Hello,

since I have Moodle Version 3.5+ (Build: 20180621) with H5P mod_hvp Version 1.17 (2019031200) we can't save any H5P element.

On trying to save an element, we get this error message:

Debug info: SQLState: 42000<br>

Error Code: 102<br>

Message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Falsche Syntax in der Nähe von "LIMIT".<br>

 

SELECT id

FROM mdl_hvp_libraries

WHERE machine_name = N'H5P.CoursePresentation'

AND (major_version > '1'

OR (major_version = '1' AND minor_version > '20'))

LIMIT 1

[array (

0 => 'H5P.CoursePresentation',

1 => '1',

2 => '1',

3 => '20',

)] 

Error code: dmlreadexception

 

Stack trace:

line 486 of \lib\dml\moodle_database.php: dml_read_exception thrown

line 324 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()

line 431 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()

line 896 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()

line 972 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()

line 1571 of \lib\dml\moodle_database.php: call to sqlsrv_native_moodle_database->get_records_sql()

line 1644 of \lib\dml\moodle_database.php: call to moodle_database->get_record_sql()

line 1611 of \mod\hvp\classes\framework.php: call to moodle_database->get_field_sql()

line 291 of \mod\hvp\mod_form.php: call to mod_hvp\framework->libraryHasUpgrade()

line 332 of \mod\hvp\mod_form.php: call to mod_hvp_mod_form->validate_created()

line 590 of \lib\formslib.php: call to mod_hvp_mod_form->validation()

line 526 of \lib\formslib.php: call to moodleform->validate_defined_fields()

line 636 of \lib\formslib.php: call to moodleform->is_validated()

line 1096 of \course\moodleform_mod.php: call to moodleform->get_data()

line 390 of \mod\hvp\mod_form.php: call to moodleform_mod->get_data()

line 150 of \course\modedit.php: call to mod_hvp_mod_form->get_data()

 

Is it possible to fix?

Thank you an best regards.

Marcus

 

Tried same combination on clean installation of moodle an h5p and got same error from SQL Server. 

EDIT framework.php (inside clases) like that

 

public function libraryHasUpgrade($library) {

        global $DB;

 

        return !!$DB->get_field_sql(

                "SELECT TOP 1 id 

                  FROM {hvp_libraries}

                  WHERE machine_name = ?

                  AND (major_version > ?

                       OR (major_version = ? AND minor_version > ?))

                  ",

                array(

                  $library['machineName'],

                  $library['majorVersion'],

                  $library['majorVersion'],

                  $library['minorVersion']

                )

        );

    }

BV52's picture

Thank you for the suggestion luiscarlos.

Hello luiscarlos,

thank you very much.
This worked.

Hope, I will not get same failure at next update.

Best regards, Marcus

BV52's picture

Hi Marcus,

I'm glad it is working for you now.

-BV52