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
91 stars 158 forks source link

Error reading from DB Unknown column 'uf1d_1.data' in 'field list' #442

Open VictorBenet opened 3 years ago

VictorBenet commented 3 years ago

When reviewing the certificate for a given course is showing an error: image

With the debug mode we got the following:

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.department, u.country, uf1d_1.data AS profile_field_Organization, uf1d_2.data AS profile_field_Department, uf1d_3.data AS profile_field_Additional_Phone, uf1d_4.data AS profile_field_Additional_email, 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 => '1',
  1 => 11,
  2 => 9,
  3 => 3,
  4 => 13,
  5 => 10,
  6 => 15,
  7 => 16,
  8 => 4,
  9 => 2,
  10 => 4,
  11 => 6,
  )]
  Error code: dmlreadexception

Seems it is not getting the custom fields added to the profile

mdjnelson commented 3 years ago

Can you please provide replication steps?

mdjnelson commented 3 years ago

What version of Moodle and the plugin are you using?

mdjnelson commented 3 years ago

Just noting this may be due to https://github.com/mdjnelson/moodle-mod_customcert/issues/423.

VictorBenet commented 3 years ago

We're using moodle 3.11, to be precise: version 3.11+ (Build: 20210617) (2021051700.07) Whenever custom profile fields are added to the show user identity, the issue appears: image

When the fields are removed, the issue is no longer present, when enabling the debug mode developer we can see the query posted on top and you can see it misses the uf1d_1 table in the FROM clause and the proper join

mdjnelson commented 3 years ago

Thanks @VictorBenet, will take a look when I get the chance. If you can provide a patch that would be great.

mdjnelson commented 2 years ago

I tried to replicate this and it all works fine in 3.11, 3.10 and 3.9 which are the currently supported versions. Please update to resolve this.

mdjnelson commented 2 years ago

Reopened due to https://moodle.org/mod/forum/discuss.php?d=428088.

mdjnelson commented 2 years ago

Closing again. See https://github.com/mdjnelson/moodle-mod_customcert/issues/465 which has a solution.