Skip to content

Conversation

@r0xd4n3t
Copy link

Summary

This PR updates the IMAP backend in the user_external app to use the PSR-3 LoggerInterface service, replacing the deprecated \OC::$server->getLogger() method. This change resolves a fatal error when using the IMAP authentication method on recent Nextcloud versions (e.g., 31.0.x).

Details

  • Replaced all direct calls to \OC::$server->getLogger() with $this->logger, which is initialized using the PSR-3 compatible service from Nextcloud's server container.
  • Added a private logger property to the IMAP class to store the injected logger instance.
  • Ensured all logger calls are routed through this property.

This aligns the app with the current Nextcloud logging system and maintains compatibility moving forward.

Related Error

Exception: Call to undefined method OC\Server::getLogger() File: /var/www/nextcloud/apps/user_external/lib/IMAP.php Line: 125

Testing

  • Verified login with valid/invalid IMAP credentials
  • Confirmed logs are properly written
  • Compatible with Nextcloud 31.0.3

…terface

This patch updates the `OCA\UserExternal\IMAP` class to use the modern PSR-3 LoggerInterface via dependency injection container instead of the deprecated `OC::$server->getLogger()` call. The change ensures compatibility with Nextcloud 21+ and avoids runtime exceptions like:

  Call to undefined method OC\Server::getLogger()

The following lines were updated:
- All instances of `\OC::$server->getLogger()->error(...)` are now replaced with `\OC::$server->get(\Psr\Log\LoggerInterface::class)->error(...)`

This update resolves login failures due to outdated method calls and restores correct logging behavior for IMAP authentication failures.

Tested successfully on Nextcloud 31.0.3.


Signed-off-by: r0xd4n3t <125836836+r0xd4n3t@users.noreply.github.com>
r0xd4n3t referenced this pull request Apr 17, 2025
@brknkfr brknkfr mentioned this pull request Aug 7, 2025
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.

1 participant