Fix fatal error when CUSTOM_EMAIL_QUERY_FUNCTION returns void#431
Merged
jsuto merged 1 commit intojsuto:masterfrom Feb 20, 2026
Merged
Conversation
Since 1.4.8, checkLoginAgainstIMAP() assigns the return value of CUSTOM_EMAIL_QUERY_FUNCTION directly to $emails. If the custom function returns void/null (as older plugins do), this causes a fatal error: count(): Argument jsuto#1 must be of type Countable|array, null given This adds a defensive check so $emails keeps its original value array($username) when the custom function doesn't return a valid array. Fixes jsuto#430 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CUSTOM_EMAIL_QUERY_FUNCTIONincheckLoginAgainstIMAP()count(): Argument #1 must be of type Countable|array, null given) when custom auth plugins don't return an arrayBackground
Since 1.4.8,
auth.phpline 415 assigns the return value ofCUSTOM_EMAIL_QUERY_FUNCTIONdirectly to$emails:Custom auth plugins written for piler ≤ 1.4.4 (such as mailpiler-mailcow-integration) only modify the session and don't return the email array. This causes
$emailsto becomenull, leading to a fatal error on the subsequentcount()/array_merge()calls.Result: Users who authenticate via IMAP with a custom email query function see a blank page (HTTP 500) after login.
Fix
Store the return value in a temporary variable and only overwrite
$emailsif the result is a non-empty array:This is backwards compatible — old plugins that modify the session directly will continue to work, and new plugins that return the array will also work.
Related
🤖 Generated with Claude Code