Skip to content

Refactor IMAP class for type safety and logging#293

Open
kaellego wants to merge 1 commit intonextcloud:masterfrom
kaellego:patch-2
Open

Refactor IMAP class for type safety and logging#293
kaellego wants to merge 1 commit intonextcloud:masterfrom
kaellego:patch-2

Conversation

@kaellego
Copy link
Copy Markdown

@kaellego kaellego commented Apr 2, 2026

Refactor IMAP class properties and constructor for type safety. Update error handling and logging for IMAP authentication.

Fixes #

Changes proposed in this pull request:

  • Fix IMAP auth

Refactor IMAP class properties and constructor for type safety. Update error handling and logging for IMAP authentication.

Signed-off-by: Wellington Moraes <guiton.acre@gmail.com>
@miaulalala miaulalala self-requested a review April 15, 2026 13:47
Comment thread lib/IMAP.php
Comment on lines +51 to +56
private function logger(): ILogger {
/** @var ILogger $logger */
$logger = \OC::$server->get(ILogger::class);
return $logger;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed - $this->logger is a property of the parent class and injected via DI

Suggested change
private function logger(): ILogger {
/** @var ILogger $logger */
$logger = \OC::$server->get(ILogger::class);
return $logger;
}

Comment thread lib/IMAP.php
Comment on lines +85 to +86
$this->logger()->error(
'User has a wrong domain. Expected: ' . $this->domain,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->logger()->error(
'User has a wrong domain. Expected: ' . $this->domain,
$this->logger->error(
'User has a wrong domain. Expected: ' . $this->domain,

Comment thread lib/IMAP.php

$ch = curl_init();
if ($ch === false) {
$this->logger()->error(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->logger()->error(
$this->logger->error(

Comment thread lib/IMAP.php
$errorcode === CURLE_SSL_CONNECT_ERROR ||
$errorcode === CURLE_OPERATION_TIMEDOUT
) {
$this->logger()->error(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->logger()->error(
$this->logger->error(

Comment thread lib/IMAP.php
$errorcode === CURLE_LOGIN_DENIED ||
(defined('CURLE_AUTH_ERROR') && $errorcode === CURLE_AUTH_ERROR)
) {
$this->logger()->warning(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->logger()->warning(
$this->logger->warning(

Comment thread lib/IMAP.php
} else {
$this->logger->error(
'ERROR: IMAP server returned an error: ' . $errorcode . ' / ' . curl_strerror($errorcode),
$this->logger()->error(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->logger()->error(
$this->logger->error(

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.

2 participants