mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
90 stars 158 forks source link

Error thrown when we have custom profile fields #512

Closed codigo-iot closed 1 year ago

codigo-iot commented 2 years ago

This problem has reappeared in version 4.0+

_Originally posted by @codigo-iot in https://github.com/mdjnelson/moodle-mod_customcert/issues/465#issuecomment-1221224353_

Información de depuración: Unknown column 'uf1d_1.data' in 'field list' SELECT u.id, u.picture, u.firstname, u.lastname, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.imagealt, u.email, u.username, u.idnumber, u.phone1, u.phone2, u.department, u.institution, u.city, u.country, uf1d_1.data AS profile_field_telefono, ci.id as issueid, ci.code, ci.timecreated FROM mdl_user u INNER JOIN mdl_customcert_issues ci ON u.id = ci.userid WHERE u.deleted = 0 AND ci.customcertid = ? AND NOT u.id IN (?,?,?,?,?,?,?,?,?,?) ORDER BY CONCAT(firstname, ' ', lastname) LIMIT 0, 50 -- line 291 of /mod/customcert/classes/certificate.php: call to mysqli_native_moodle_database->get_records_sql() -- line 204 of /mod/customcert/classes/report_table.php: call to mod_customcert\certificate::get_issues() -- line 2132 of /lib/tablelib.php: call to mod_customcert\report_table->query_db() -- line 158 of /mod/customcert/view.php: call to table_sql->out() [array ( 0 => '7', 1 => 3388, 2 => 128, 3 => 3515, 4 => 3509, 5 => 3513, 6 => 275, 7 => 2, 8 => 275, 9 => 320, 10 => 3522, )] Error code: dmlreadexception

i-am-sheep commented 2 years ago

I've had the same issue with version 4.0.2 in moodle 4

Debug info: Unknown column 'uf1d_1.data' in 'field list' SELECT u.id, u.picture, u.firstname, u.lastname, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.imagealt, u.email, u.username, uf1d_1.data AS profile_field_attendancedate, ci.id as issueid, ci.code, ci.timecreated FROM mdl_user u INNER JOIN mdl_customcert_issues ci ON u.id = ci.userid WHERE u.deleted = 0 AND ci.customcertid = ? AND NOT u.id IN (?,?) ORDER BY CONCAT(firstname, ' ', lastname) LIMIT 0, 50 [array ( 0 => '52', 1 => 4, 2 => 2, )] Error code: dmlreadexception

alihamas575 commented 1 year ago

I also upgraded to moodle 4.0.3 and am having similar problems. The location of all parts is recorded in the private certificate.

I enter the edit area, the certificate edit screen looks broken.

The save button does not appear, I move the parts, it does not record because the save button does not appear.

mdjnelson commented 1 year ago

Does anyone have a fix for 4.0 for this one?

leonstr commented 1 year ago

I'm not sure there is a Moodle 4.0-specific issue here.

The original Moodle 3.11 issue was reported as #465 and fixed in 2a9640b.

This issue says "This problem has reappeared in version 4.0+" but includes a back trace showing:

⋮
line 291 of /mod/customcert/classes/certificate.php: call to mysqli_native_moodle_database->get_records_sql()
⋮

But in the fixed (2a9640b) version this call is now on line 296. So I think @codigo-iot is using mod_customcert version 2021051701 from the plugins directory not the one with the fix.

P.S. I think @kelsoncm's subsequent patch (#517) is cleaner than the original fix (2a9640b) -- although the brackets for the join criteria look extraneous:

                            INNER JOIN {customcert_issues} ci ON (u.id = ci.userid)
mdjnelson commented 1 year ago

Thanks @leonstr, closing this. Will look at @kelsoncm's patch later.

mdjnelson commented 1 year ago

Looking at the patch now. Shouldn't have closed this before I pushed upstream. Sorry.

mdjnelson commented 1 year ago

Ugh, so this is what happens when you dont have the time to look at your open source project. Closing again as this bug is fixed and the suggested patch is a better implementation but right now users are not getting an error.

mdjnelson commented 1 year ago

@leonstr in https://github.com/mdjnelson/moodle-mod_customcert/issues/520 you suggest this is still an issue in 4.0. I am going to confirm now.

leonstr commented 1 year ago

@mdjnelson I think I was incorrect. I think I based my comment in #520 on this initial report stating "This problem has reappeared in version 4.0+" which I don't think is true (as per this comment).

mdjnelson commented 1 year ago

I tested with the updated patch from @kelsoncm which works and is a neater approach and will push that for 4.0.