Commit e8d02087 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove profile icon from session on delete (see bug #805742)

Commit 0c9774b9

 added a foreign key constraint on the profile icon
field of the user table.  But when a profile icon is deleted, this
field isn't updated in the global $USER object, unless the icon is
deleted from the profile icons page, so the bad profileicon can hang
around in the session, and then cause an sql error the next time the
usr table is updated from $USER.

This change will fix that problem when a user deletes their own
profile icon, however it may still be possible for the error to occur
if for example the user is logged in twice.

Change-Id: I2f8792fcd392be351b8ee9ac77337fd41b046a3d
Signed-off-by: default avatarRichard Mansfield <>
parent 16b7cfab
......@@ -1734,6 +1734,24 @@ class ArtefactTypeImage extends ArtefactTypeFile {
class ArtefactTypeProfileIcon extends ArtefactTypeImage {
public function delete() {
global $USER;
if ($USER->get('profileicon') == $this->id) {
$USER->profileicon = null;
public static function bulk_delete($artefactids) {
global $USER;
if (in_array($USER->get('profileicon'), $artefactids)) {
$USER->profileicon = null;
public static function get_links($id) {
$wwwroot = get_config('wwwroot');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment