Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUTH_OIDC customicon: Error when setting or deleting custom icon file for OIDC Login #2793

Open
GeraldST opened this issue Feb 20, 2025 · 1 comment · May be fixed by #2794, #2795, #2796 or #2797
Open

AUTH_OIDC customicon: Error when setting or deleting custom icon file for OIDC Login #2793

GeraldST opened this issue Feb 20, 2025 · 1 comment · May be fixed by #2794, #2795, #2796 or #2797
Assignees
Labels
Issue type - bug Bugs in existing code that needs to be fixed. Plugin - auth_oidc Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release.
Milestone

Comments

@GeraldST
Copy link

I recently upgraded from Moodle 3.9 to LTS Version 4.5.1. I now have installed OpenID Connect Plugin version 4.5.0 2024100700.
Problem: Whenever I try to change oder delete the customicon for OIDC Authentication in Moodle Settings an error is thrown.

Uploading an icon file in OIDC settings (auth_oidc | customicon) and saving settings:
Error: Call to a member function copy_content_to() on bool
Debug-Info:
Error code: generalexceptionmessage
Stack trace:
• line 115 of /auth/oidc/lib.php: Error thrown
• line 10715 of /lib/adminlib.php: call to auth_oidc_initialize_customicon()
• line 8990 of /lib/adminlib.php: call to admin_setting_configstoredfile->post_write_settings()
• line 59 of /admin/settings.php: call to admin_write_settings()

Result: New icon file is uploaded and shown in OIDC settings (it is saved and can be downloaded afterwards) but it is not displayed in the OIDC login window. Instead the old customicon file ist displayed and does not change.
Checking the filebase the already existing icon file was not overwritten: moodledata/pix_plugins/auth/oidc/0/customicon.jpg

Expected behavior: Provider-Icon should also change in frontend in the login window.

Deleting the icon file in OIDC settings (auth_oidc | customicon) and saving settings:
Error: Call to a member function is_directory() on string
Debug-Info:
Error code: generalexceptionmessage
Stack trace:
• line 101 of /auth/oidc/lib.php: Error thrown
• line 10715 of /lib/adminlib.php: call to auth_oidc_initialize_customicon()
• line 8990 of /lib/adminlib.php: call to admin_setting_configstoredfile->post_write_settings()
• line 59 of /admin/settings.php: call to admin_write_settings()

Result: Icon file was deleted from OIDC settings and in the login window now the standard icon is displayed.

Suggestions:
When looking into the code it seems that the function $file = $fs->get_file_by_hash(sha1($fullpath) somehow seems to fail and does not deliver a valid file handle. So the methods $file->copy_content_t and $file->is_directory are also failing. Btw. the code seems not quite accurate because I think the function should return with "false" in this case and not throw a PHP error.

> Link to Github

Looking for the file in the database:
SELECT * FROM 'mdl_files' where 'component' = 'auth_oidc';
gives the following result:
Image

Please help and advise what I could check furthermore. I originally suspected file permission problems but could not find an issue.

@weilai-irl weilai-irl self-assigned this Feb 21, 2025
@weilai-irl weilai-irl added this to the 2025-01 milestone Feb 21, 2025
@weilai-irl weilai-irl added Issue type - bug Bugs in existing code that needs to be fixed. Plugin - auth_oidc Status - PR ready / pending release Dev is done and PR ready. Will be included in the next release. labels Feb 21, 2025
@GeraldST
Copy link
Author

Hi @weilai-irl , I saw you already worked on this issue.

I just want to confirm that I already manually tried the changes from your pull request and it worked fine for me.
Thank you for your very fast response and great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment