fix(activesync): guard against null IMAP client in _getImapOb()#78
Conversation
Horde_ActiveSync_Imap_Adapter::_getImapOb() returned the result of $this->_imap->getImapOb() directly. When the factory yields an empty client (e.g. no established IMAP session on a stateless or long-running request), callers such as ping() invoked status() on null and produced a fatal error. Treat an empty client like the failure path and throw Horde_Exception_AuthenticationFailure so the sync layer handles it gracefully instead of fataling.
🔍 CI ResultsOverall: ❌ 12/12 lanes failed TL;DR: ❌ Quality issues: PHPUnit: 36 tests failed; PHPStan: 331 unique errors in 8 lanes; PHP-CS-Fixer: 17 files. Summary by PHP Version
Quality Metrics
❌ Failed Lanesphp8.0-dev
php8.0-stable
php8.1-dev
php8.1-stable
php8.2-dev
php8.2-stable
php8.3-dev
php8.3-stable
php8.4-dev
php8.4-stable
php8.5-dev
php8.5-stable
CI powered by horde-components • View full results |
There was a problem hiding this comment.
Pull request overview
This PR hardens the ActiveSync IMAP adapter by ensuring _getImapOb() never returns an empty IMAP client, preventing downstream fatal errors (e.g., calling status() on null) and instead surfacing a consistent authentication failure that callers can handle.
Changes:
- Store the IMAP factory result in a local variable instead of returning it directly.
- Throw
Horde_Exception_AuthenticationFailurewhen the IMAP factory returns an empty/null client.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Release version 3.0.2 Merge pull request #79 from horde/fix/foldersync-empty-folderlist-guard fix(activesync): report no folder changes when getFolderList() is false Merge pull request #78 from horde/fix/imap-getimapob-null-guard test(activesync): cover null IMAP client ping failure fix(activesync): preserve IMAP auth exception context Update _getImapOb() docblock @throws to Horde_Exception_AuthenticationFailure fix(activesync): guard against null IMAP client in _getImapOb() fix(activesync): handle invalid appointment timezone blobs in getTimezone()
Summary
_getImapOb()now throwsHorde_Exception_AuthenticationFailurewhen the IMAP factory returns an empty client, instead of returningnull.Motivation
_getImapOb()returned$this->_imap->getImapOb()directly. If that yields an empty client (no established IMAP session on a stateless or long-running request), downstream callers likeping()callstatus()onnull:Changes
Horde_Exception_AuthenticationFailure(the same exception already used for the caught failure path).Test plan