Skip to content

Improve photo and timezone sync scheduled task#3211

Open
weilai-irl wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-130227-m502
Open

Improve photo and timezone sync scheduled task#3211
weilai-irl wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-130227-m502

Conversation

@weilai-irl

Copy link
Copy Markdown
Collaborator
  • Better support for site not using UPN as username,
  • Reduce DB queries.

Copilot AI review requested due to automatic review settings June 4, 2026 09:38
@weilai-irl weilai-irl self-assigned this Jun 4, 2026
@weilai-irl weilai-irl added this to the 2026-03 milestone Jun 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the scheduled photo/timezone sync task by making photo fetches more robust on sites where stored usernames aren’t valid Graph UPNs, and by reducing per-user database lookups during batch processing.

Changes:

  • Switch photo sync lookups from o365name (UPN) to objectid (AAD GUID) when calling Graph batch photo APIs.
  • Reduce DB queries by pre-aggregating local_o365_appassign via a single LEFT JOIN and by batch-fetching user_preferences photo hashes.
  • Optimize photo application by skipping process_new_icon() when the incoming raw photo hash matches the stored hash, and refining photo-change detection in apply_photo() via file content hashes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
local/o365/classes/task/photoandtimezonesync.php Uses objectid for photo batch requests, avoids duplicate rows via aggregated join, and adds hash-based short-circuiting to reduce unnecessary image processing/DB work.
local/o365/classes/feature/usersync/main.php Updates photo-apply logic to more reliably determine “content changed” vs “ID changed”, and makes apply_photo_public() return a boolean change indicator.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread local/o365/classes/task/photoandtimezonesync.php
Comment thread local/o365/classes/task/photoandtimezonesync.php
Comment thread local/o365/classes/task/photoandtimezonesync.php Outdated
Comment thread local/o365/classes/task/photoandtimezonesync.php
…r site not using UPN as username, reduce DB queries
@weilai-irl weilai-irl changed the title Improve photo sync in scheduled task Improve photo and timezone sync scheduled task Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants