user_external icon indicating copy to clipboard operation
user_external copied to clipboard

getLogger() has been removed

Open Glandos opened this issue 6 months ago • 9 comments

See https://github.com/nextcloud/server/pull/47978

A potential solution has been implemented by https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/1056, it seems to be \OCP\Log\logger('user_external')

Solves #270

Glandos avatar Jun 19 '25 10:06 Glandos

As a quick test I changed line 74 in IMAP.php to read \OCP\Log\logger('user_external')->error( and it resolved the particular error i was experiencing on login. I'm guessing the error class initiator is used all over this package. If I get the time i'll try and go hunt them down and clean them up.

dbuerer avatar Jun 23 '25 00:06 dbuerer

Using server Nextcloud 31.0.6 with "External user authentication" 3.4.0 from NC repository (does not offer more recent update). This error message is still ocurring and it does not allow to authenticate IMAP users:

Exception Call to undefined method OC\Server::getLogger() in file '/srv/www/apps/user_external/lib/IMAP.php' line 125

narcisgarcia avatar Jul 21 '25 14:07 narcisgarcia

Replace all occurrences of OC\Server::getLogger() by \OCP\Log\logger('user_external') in /srv/www/apps/user_external/lib/IMAP.php

Glandos avatar Jul 21 '25 14:07 Glandos

Replace all occurrences of OC\Server::getLogger() by \OCP\Log\logger('user_external') in /srv/www/apps/user_external/lib/IMAP.php

Since I've tried this, non-email users can't login ( ERROR: IMAP Login failed via curl: Login denied ). How do I make normal users be able to login again with own username&password? At last I've applied changes from bugfix commit

narcisgarcia avatar Jul 21 '25 15:07 narcisgarcia

As of july 16th 3.5.9 version of this extension~app was released, but as of august 31th Nextcloud server 31.0.8 still has version 3.4.0 of External user authentication.

narcisgarcia avatar Aug 31 '25 06:08 narcisgarcia

As of july 16th 3.5.9 version of this extension~app was released, but as of august 31th Nextcloud server 31.0.8 still has version 3.4.0 of External user authentication.

Where did you see the release version 3.5.9? Here the last "release" was from 2021 and since than only taged version exist in the repository. It seems that this app is not maintained well any more. Sorry, if I am mistaken. There are no code changes since last year. Maybe it is not necessary but as an admin I am reluctant to use this app even though I really would like to.

dagobert avatar Sep 08 '25 09:09 dagobert

Work for me:

diff -ur user_external/lib/IMAP.php.orig user_external/lib/IMAP.php
--- user_external/lib/IMAP.php.orig
+++ user_external/lib/IMAP.php
@@ -8,6 +8,7 @@
  * See the COPYING-README file.
  */
 namespace OCA\UserExternal;
+use Psr\Log\LoggerInterface;

 /**
  * User authentication against an IMAP mail server
@@ -71,7 +72,7 @@
                                        $uid = $pieces[0];
                                }
                        } else {
-                               \OC::$server->getLogger()->error(
+                               \OC::$server->get(LoggerInterface::class)->error(
                                        'ERROR: User has a wrong domain! Expecting: '.$this->domain,
                                        ['app' => 'user_external']
                                );
@@ -111,7 +112,7 @@
                           $errorcode === 28) {
                        # This is not defined in PHP-8.x
                        # 28: CURLE_OPERATION_TIMEDOUT
-                       \OC::$server->getLogger()->error(
+                       \OC::$server->get(LoggerInterface::class)->error(
                                'ERROR: Could not connect to imap server via curl: ' .  curl_strerror($errorcode),
                                ['app' => 'user_external']
                        );
@@ -122,12 +123,12 @@
                        # 9: CURLE_REMOTE_ACCESS_DENIED
                        # 67: CURLE_LOGIN_DENIED
                        # 94: CURLE_AUTH_ERROR)
-                       \OC::$server->getLogger()->error(
+                       \OC::$server->get(LoggerInterface::class)->error(
                                'ERROR: IMAP Login failed via curl: ' .  curl_strerror($errorcode),
                                ['app' => 'user_external']
                        );
                } else {
-                       \OC::$server->getLogger()->error(
+                       \OC::$server->get(LoggerInterface::class)->error(
                        'ERROR: IMAP server returned an error: ' . $errorcode . ' / ' . curl_strerror($errorcode),
                                ['app' => 'user_external']
                        );

VVD avatar Sep 26 '25 23:09 VVD

Files:

user_external/lib/BasicAuth.php
user_external/lib/FTP.php
user_external/lib/SMB.php
user_external/lib/SSH.php
user_external/lib/WebDavAuth.php

need the same fix, but I'm using IMAP backend only.

VVD avatar Sep 27 '25 00:09 VVD

Fixed in https://github.com/nextcloud/user_external/commit/51feb76b47ab72d0746f43943c893257afa2ec8f.

VVD avatar Sep 27 '25 00:09 VVD