mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-77705 reportbuilder: avoid re-using field alias between entities.
Ensure that when the user entity is added multiple times to a report, when there are custom profile fields, each of those gets a unique table alias per-entity.
This commit is contained in:
parent
231c25e498
commit
ee3924702f
@ -115,11 +115,21 @@ class user_profile_fields {
|
||||
/**
|
||||
* Generate table alias for given profile field
|
||||
*
|
||||
* The entity name is used to ensure the alias differs when the entity is used multiple times within the same report, each
|
||||
* having their own table alias/join
|
||||
*
|
||||
* @param profile_field_base $profilefield
|
||||
* @return string
|
||||
*/
|
||||
private function get_table_alias(profile_field_base $profilefield): string {
|
||||
return "upfs{$profilefield->fieldid}";
|
||||
static $aliases = [];
|
||||
|
||||
$aliaskey = "{$this->entityname}_{$profilefield->fieldid}";
|
||||
if (!array_key_exists($aliaskey, $aliases)) {
|
||||
$aliases[$aliaskey] = database::generate_alias();
|
||||
}
|
||||
|
||||
return $aliases[$aliaskey];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user