Skip to content

fix(activesync): guard against null IMAP client in _getImapOb()#78

Merged
TDannhauer merged 4 commits into
FRAMEWORK_6_0from
fix/imap-getimapob-null-guard
Jul 8, 2026
Merged

fix(activesync): guard against null IMAP client in _getImapOb()#78
TDannhauer merged 4 commits into
FRAMEWORK_6_0from
fix/imap-getimapob-null-guard

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • _getImapOb() now throws Horde_Exception_AuthenticationFailure when the IMAP factory returns an empty client, instead of returning null.

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 like ping() call status() on null:

Error: Call to a member function status() on null
    .../Horde/ActiveSync/Imap/Adapter.php

Changes

  • Capture the factory result and, when empty, throw Horde_Exception_AuthenticationFailure (the same exception already used for the caught failure path).

Test plan

  • EAS client with mail sync where the IMAP client can be unavailable mid-session; confirm a clean auth failure/retry instead of a fatal.

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.
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🔍 CI Results

Overall: ❌ 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

PHP dev stable
8.0
8.1
8.2
8.3
8.4
8.5

Quality Metrics

  • PHPUnit: 16 failures, 20 errors out of 204 tests in 8 lanes ❌
    Per-test detail in the table below. Raw JUnit XML and JSON are uploaded as workflow artifacts.

    Which tests failed
    Type Test Lanes Message
    ❌ failure Horde\ActiveSync\AppointmentTest::testSetRecurrenceEas16SetsFirstDayOfWeek php8.2-dev, php8.2-stable, php8.3-dev, php8.3-stable, php8.4-dev, php8.4-stable, php8.5-dev, php8.5-stable [PHPUnit\Framework\ExpectationFailedException] Failed asserting that '' matches expected 0.
    ⚠️ error Horde\ActiveSync\Request\FindRequestTest::testMockDriverReturnsSuccessfulEmptyFindResults php8.2-dev, php8.2-stable, php8.3-dev, php8.3-stable, php8.4-dev, php8.4-stable, php8.5-dev, php8.5-stable [InvalidArgumentException] Missing required state object
    ❌ failure Horde\ActiveSync\Request\FindRequestTest::testParseFindRangeHonorsClientWindow php8.2-dev, php8.2-stable, php8.3-dev, php8.3-stable, php8.4-dev, php8.4-stable, php8.5-dev, php8.5-stable [PHPUnit\Framework\ExpectationFailedException] Failed asserting that 100 is identical to 101.
    ⚠️ error Horde\ActiveSync\SyncTimeBudgetTest::testGetSyncConfigDefaultsToEmptyArray php8.3-dev, php8.3-stable, php8.4-dev, php8.4-stable, php8.5-dev, php8.5-stable [Error] Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::getMockForAbstractClass()
    ⚠️ error Horde\ActiveSync\SyncTimeBudgetTest::testGetSyncConfigReturnsConfiguredValues php8.3-dev, php8.3-stable, php8.4-dev, php8.4-stable, php8.5-dev, php8.5-stable [Error] Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::getMockForAbstractClass()
  • PHPStan (advisory): 331 unique errors in 8 lanes ⚠️

  • PHP-CS-Fixer: 17 unique files with issues (of 197 checked) ⚠️

❌ Failed Lanes

php8.0-dev

  • PHPUnit: ❌ Setup failed (No result file found)
  • PHPStan: ❌ Setup failed (No result file found)

php8.0-stable

  • PHPUnit: ❌ Setup failed (Composer install failed in /tmp/horde-ci/lanes/php8.0-stable/ActiveSync: Your requirements could not be resolved to an installable set of packages.)
  • PHPStan: ❌ Setup failed (Composer install failed in /tmp/horde-ci/lanes/php8.0-stable/ActiveSync: Your requirements could not be resolved to an installable set of packages.)

php8.1-dev

  • PHPUnit: ❌ Setup failed (No result file found)
  • PHPStan: ❌ Setup failed (No result file found)

php8.1-stable

  • PHPUnit: ❌ Setup failed (No result file found)
  • PHPStan: ❌ Setup failed (No result file found)

php8.2-dev

  • PHPUnit: 2 failures, 1 error

php8.2-stable

  • PHPUnit: 2 failures, 1 error

php8.3-dev

  • PHPUnit: 2 failures, 3 errors

php8.3-stable

  • PHPUnit: 2 failures, 3 errors

php8.4-dev

  • PHPUnit: 2 failures, 3 errors
  • PHP-CS-Fixer: 17 files with issues

php8.4-stable

  • PHPUnit: 2 failures, 3 errors

php8.5-dev

  • PHPUnit: 2 failures, 3 errors

php8.5-stable

  • PHPUnit: 2 failures, 3 errors

CI powered by horde-componentsView full results

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_AuthenticationFailure when the IMAP factory returns an empty/null client.

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

Comment thread lib/Horde/ActiveSync/Imap/Adapter.php
Comment thread lib/Horde/ActiveSync/Imap/Adapter.php
Comment thread lib/Horde/ActiveSync/Imap/Adapter.php
@TDannhauer
TDannhauer merged commit 877187a into FRAMEWORK_6_0 Jul 8, 2026
ralflang added a commit that referenced this pull request Jul 8, 2026
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()
@TDannhauer
TDannhauer deleted the fix/imap-getimapob-null-guard branch July 10, 2026 11:02
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.

3 participants