Skip to content

fix(taskprocessing): handle deleted users in checkGuestAccess - #67670

Open
kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-taskprocessing-guest-access-67535
Open

kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-taskprocessing-guest-access-67535

Conversation

@kukanggg89

Copy link
Copy Markdown
Contributor

Resolves: #67535

Summary

Manager::checkGuestAccess() resolved the user with IUserManager::get() and called getBackend() on the result without checking it. For a deleted user id that returns null, so processing or rescheduling a task of a deleted account ended in Call to a member function getBackend() on null when the guests app was installed and ai.taskprocessing_guests was off.

This adds an explicit null check: a missing user now gets no guest access. getAvailableTaskTypes() returns an empty list for that user id, and scheduling or running one of their tasks throws the existing PreConditionNotMetException instead of an Error.

Two tests in tests/lib/TaskProcessing/TaskProcessingTest.php cover it: no task types are listed for a deleted user id, and scheduling a task for one throws with the guest-access message.

I did not run the tests locally, there is no PHP toolchain in this environment, so the repo CI has to confirm they pass. The guests app is not installed in the server unit test environment, so the tests assert the fixed behavior (empty list, clean exception) rather than reproducing the original fatal error with the guests backend loaded.

TODO

  • ...

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes (n/a: no front-end change)
  • Documentation (manuals or wiki) has been updated or is not required (n/a: no user-facing behavior to document)
  • Backports requested where applicable (ex: critical bugfixes) (n/a: backport decision is for maintainers after merge)
  • Labels added where applicable (ex: bug/enhancement, 1. to review, feature component) (n/a: set by maintainers)
  • Milestone added for target branch/version (ex: 32.x for stable32) (n/a: set by maintainers)

AI (if applicable)

Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.

IUserManager::get() returns null for a deleted user id, and
checkGuestAccess() passed that null straight into
getBackend(), ending in `Call to a member function
getBackend() on null` whenever a task of a deleted account
was processed or rescheduled. Return false for a missing
user instead, so scheduling and running such a task fails
with a plain PreConditionNotMetException and
getAvailableTaskTypes() returns an empty list. Covered by
two tests: no task types are listed for a deleted user id,
and scheduling a task for one throws.

Fixes nextcloud#67535

Signed-off-by: parel <farelalfarizi89@gmail.com>

Assisted-by: Muse:Muse Spark 1.3

This branch has not been deployed

No deployments
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.

TaskProcessing checkGuestAccess() fails with an Error for a deleted user id

1 participant