mail icon indicating copy to clipboard operation
mail copied to clipboard

Upgrade to 1.14.0 on NC 24.0.6 yields BadFunctionCallException: authMethod is not a valid attribute

Open CacheMinimal opened this issue 4 years ago • 26 comments

Steps to reproduce

  1. Begin with an instance of NC 24.0.6 and Mail 1.13.9 installed
  2. Configure and test mail account to local IMAP server using mail app per user (as opposed to the global Groupware settings)
  3. Upgrade to Mail 1.14.0

Expected behavior

Mail should upgrade and continue to be functional via the web UI.

Actual behavior

Upon login to previously working user account the dashboard mail widget just spins and never shows any content. Attempting to click into the Mail app yields:

Internal Server Error
The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.

Technical details
Remote Address: <Removed for privacy>
Request ID: <Removed for privacy>

Mail app version

1.14.0

Mailserver or service

Local Dovecot IMAP/Postfix SMTP

Operating system

Ubuntu Server 20.04.5 LTS

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database

MySQL

Additional info

[index] Error: BadFunctionCallException: authMethod is not a valid attribute at <<closure>>

 0. /srv/www/nextcloud/lib/public/AppFramework/Db/Entity.php line 165
    OCP\AppFramework\Db\Entity->setter()
 1. /srv/www/nextcloud/lib/public/AppFramework/Db/Entity.php line 73
    OCP\AppFramework\Db\Entity->__call()
 2. /srv/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php line 322
    OCP\AppFramework\Db\Entity::fromRow()
 3. /srv/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php line 341
    OCP\AppFramework\Db\QBMapper->mapRowToEntity()
 4. /srv/www/nextcloud/apps/mail/lib/Db/MailAccountMapper.php line 98
    OCP\AppFramework\Db\QBMapper->findEntities()
 5. /srv/www/nextcloud/apps/mail/lib/Service/AccountService.php line 72
    OCA\Mail\Db\MailAccountMapper->findByUserId()
 6. /srv/www/nextcloud/apps/mail/lib/Controller/PageController.php line 129
    OCA\Mail\Service\AccountService->findByUserId()
 7. /srv/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\Mail\Controller\PageController->index()
 8. /srv/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController()
 9. /srv/www/nextcloud/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch()
10. /srv/www/nextcloud/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main()
11. /srv/www/nextcloud/lib/base.php line 1030
    OC\Route\Router->match()
12. /srv/www/nextcloud/index.php line 36
    OC::handleRequest()

GET /apps/mail/
from <Removed IP> by <Removed user> at 2022-10-11T09:07:19+00:00

CacheMinimal avatar Oct 11 '22 09:10 CacheMinimal

The same. After upgrading to v 1.14 mail app collapsed. Page displays system error - contact to admin. Logs are the same. App is fun but now the app is useless.

jejusek avatar Oct 11 '22 10:10 jejusek

The migration didn't run.

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

https://github.com/nextcloud/mail/blob/stable1.14/lib/Migration/Version1140Date20220701103556.php is the migration. Could you please check if your table oc_mail_accounts has a column auth_method?

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

The migration didn't run.

I guessed something like that due to the new authentication methods mentioned in the release notes. Is there anything I can provide to help you work out why it did not run? Is there a way I can force it to re-run?

Nothing special was done on my system. Simply logged into the UI as admin and ran the upgrade from the App store.

CacheMinimal avatar Oct 11 '22 10:10 CacheMinimal

https://github.com/nextcloud/mail/blob/stable1.14/lib/Migration/Version1140Date20220701103556.php is the migration. Could you please check if your table oc_mail_accounts has a column auth_method?

Yes, it does as the last column. It is set to "password" for all my rows.

CacheMinimal avatar Oct 11 '22 10:10 CacheMinimal

https://github.com/nextcloud/mail/blob/stable1.14/lib/Db/MailAccount.php#L117 attribute exists on the entity model

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

https://github.com/nextcloud/mail/blob/stable1.14/lib/Db/MailAccount.php#L117 attribute exists on the entity model

Is that a statement or question? If the latter, could you expand a little so that I can check what you are asking?

CacheMinimal avatar Oct 11 '22 10:10 CacheMinimal

Statement. I'm checking possible causes for the problem.

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

This doesn't make sense at the moment. Could oyu check your apps/mail/lib/Db/MailAccount.php for the private $authMethod property?

If it's there then your server is using a cached version of the file in the opcache.

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

I'm spinning up a 24 Docker instance to see if it happens with vanilla nextcloud

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

Nope, new installation of 24 and Mail v1.14.0 is fine. So this must be specific to installations that upgraded from an earlier version.

ChristophWurst avatar Oct 11 '22 10:10 ChristophWurst

This doesn't make sense at the moment. Could oyu check your apps/mail/lib/Db/MailAccount.php for the private $authMethod property?

In apps/mail/lib/Db/MailAccount.php on my server the declaration is there but it is protected rather than private:

class MailAccount extends Entity {
        protected $userId;
        protected $name;
        protected $email;
        protected $inboundHost;
        protected $inboundPort;
        protected $inboundSslMode;
        protected $inboundUser;
        protected $inboundPassword;
        protected $outboundHost;
        protected $outboundPort;
        protected $outboundSslMode;
        protected $outboundUser;
        protected $outboundPassword;
        protected $signature;
        protected $lastMailboxSync;
        protected $editorMode;
        protected $order;
        protected $showSubscribedOnly;
        protected $personalNamespace;
        protected $authMethod;

If it's there then your server is using a cached version of the file in the opcache.

That was it! I'm running PHP FPM. Restarting the PHP FPM service on the server made it read the new code and mail once again works fine.

Thanks for your assistance in tracing this anomaly. Any ideas why this should have happened with this update to Mail when I have been following the same procedure to upgrade the app for several years without the need to restart FPM?

CacheMinimal avatar Oct 11 '22 11:10 CacheMinimal

I believe a call to https://www.php.net/manual/en/function.opcache-reset.php after Nextcloud updates any app could help.

For larger installations we always instruct to restart the web servers after an upgrade https://docs.nextcloud.com/server/stable/admin_manual/maintenance/manual_upgrade.html.

Any ideas why this should have happened with this update to Mail when I have been following the same procedure to upgrade the app for several years without the need to restart FPM?

Luck, or PHP wasn't as aggressive with caching before. It's hard to tell.

ChristophWurst avatar Oct 11 '22 11:10 ChristophWurst

Check https://stackoverflow.com/questions/34260252/opcache-clears-too-quickly and your opcache settings.

ChristophWurst avatar Oct 11 '22 11:10 ChristophWurst

Check https://stackoverflow.com/questions/34260252/opcache-clears-too-quickly and your opcache settings.

Thanks for this. I checked my PHP opcache settings and found that I had followed the server tuning guide at:

https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache

I had 'opcache.validate_timestamps = 0', which clearly applies to all PHP scripts and not just config.php as the document could be read to suggest. No idea how I have got away with things working during previous upgrades!

I have updated the PHP opcache settings on another server with mirror settings and can confirm I was able to update from mail 1.13.9 to 1.14.0 without any issues or needing to restart anything. Sorry to have bothered you with the troubleshooting due to a configuration misunderstanding on my behalf.

CacheMinimal avatar Oct 11 '22 12:10 CacheMinimal

I experience the same problem.

The thing is, on one server I have the opcache.validate_timestamps "tuning", on another I don't, and both failed to work after the update to 14.0. Restarting the php-fpm service helped both.

So, @CacheMinimal I think it is not a "configuration" problem on your behalf"

Samonitari avatar Oct 11 '22 13:10 Samonitari

So, @CacheMinimal I think it is not a "configuration" problem on your behalf"

Mind sharing your insights on what else caused this missing opcache invalidation despite source file changes?

ChristophWurst avatar Oct 12 '22 09:10 ChristophWurst

So, @CacheMinimal I think it is not a "configuration" problem on your behalf"

Mind sharing your insights on what else caused this missing opcache invalidation despite source file changes?

I wish I'd knew something useful, but I can only write something to indicate I've read your request, and I'd gladly help.

I checked multiple times with rg (ripgrep), no validate_timestamps which evaluate to 0 neither in the /etc/php7/ nor in the nextcloud folder (except the doc txt in the latter) in one of my nextcloud servers. Nevertheless, I needed to restart the php-fpm service.

Samonitari avatar Oct 13 '22 10:10 Samonitari

Try php --info | grep opcache to find your current configuration

ChristophWurst avatar Oct 13 '22 11:10 ChristophWurst

If CLI and web server don't use the same php.ini you might need to invoke php differently.

ChristophWurst avatar Oct 13 '22 11:10 ChristophWurst