Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoloader issue in lib/private/Files/Storage/DAV.php #3771

Closed
klada opened this issue Mar 8, 2017 · 5 comments
Closed

Autoloader issue in lib/private/Files/Storage/DAV.php #3771

klada opened this issue Mar 8, 2017 · 5 comments

Comments

@klada
Copy link

klada commented Mar 8, 2017

During the development of a proof-of-concept NextCloud auth backend I've stumbled across a weird issue with automatic class loading in the NextCloud core.

Although I can work around this issue I think there is something broken in the core, which unfortunately is kind of hard to reproduce. First of all, this is the error I am getting:

[ERROR] GET /index.php/login
[ERROR] User: 'otto'@'134.109.200.113'
[ERROR] Exception: Class 'OC\MemCache\ArrayCache' not found
[ERROR] Trace:
 #0 /var/www/html/nextcloud/apps/files_sharing/lib/External/Storage.php(93): OC\Files\Storage\DAV->__construct(Array)
#1 /var/www/html/nextcloud/lib/private/Files/Mount/MountPoint.php(146): OCA\Files_Sharing\External\Storage->__construct(Array)
#2 /var/www/html/nextcloud/lib/private/Files/Mount/MountPoint.php(171): OC\Files\Mount\MountPoint->createStorage()
#3 /var/www/html/nextcloud/lib/private/Files/Config/UserMountCache.php(93): OC\Files\Mount\MountPoint->getStorage()
#4 [internal function]: OC\Files\Config\UserMountCache->OC\Files\Config\{closure}(Object(OCA\Files_Sharing\External\Mount))
#5 /var/www/html/nextcloud/lib/private/Files/Config/UserMountCache.php(94): array_filter(Array, Object(Closure))
#6 /var/www/html/nextcloud/lib/private/Files/Config/MountProviderCollection.php(134): OC\Files\Config\UserMountCache->registerMounts(Object(OC\User\User), Array)
#7 /var/www/html/nextcloud/lib/private/Files/Filesystem.php(449): OC\Files\Config\MountProviderCollection->registerMounts(Object(OC\User\User), Array)
#8 /var/www/html/nextcloud/lib/private/Files/Filesystem.php(375): OC\Files\Filesystem::initMountPoints('otto')
#9 /var/www/html/nextcloud/lib/private/legacy/util.php(235): OC\Files\Filesystem::init('otto', '/otto/files')
#10 /var/www/html/nextcloud/lib/private/legacy/user.php(188): OC_Util::setupFS('otto')
#11 /var/www/html/nextcloud/lib/private/legacy/user.php(219): OC_User::loginWithApache(Object(OCA\ServerAuth\ServerAuthBackend))
#12 /var/www/html/nextcloud/apps/user_serverauth/appinfo/app.php(14): OC_User::handleApacheAuth()
#13 /var/www/html/nextcloud/lib/private/legacy/app.php(214): require_once('/var/www/html/n...')
#14 /var/www/html/nextcloud/lib/private/legacy/app.php(155): OC_App::requireAppFile('user_serverauth')
#15 /var/www/html/nextcloud/lib/private/legacy/app.php(125): OC_App::loadApp('user_serverauth')
#16 /var/www/html/nextcloud/lib/private/legacy/user.php(128): OC_App::loadApps(Array)
#17 /var/www/html/nextcloud/lib/base.php(745): OC_User::setupBackends()
#18 /var/www/html/nextcloud/lib/base.php(1092): OC::init()
#19 /var/www/html/nextcloud/index.php(38): require_once('/var/www/html/n...')
#20 {main}

Error in /var/www/html/nextcloud/lib/private/Files/Storage/DAV.php:90

The weird thing is that it only happens under very rare circumstances. I was able to reproduce it with the following steps:

  1. An authentication backend which implements the public IApacheBackend is used
  2. OC_User::handleApacheAuth() is called when setting up a new session
  3. The user logs in (new session)
  4. The user has a remote share in his toplevel dir (federated share)

What bugs me is that only sometimes the ArrayCache class cannot be loaded in lib/private/Files/Storage/DAV.php. So I came to the conclusion that this must be an issue with the classloader somewhere deep inside NextCloud's guts.

I can work around this in my app by manually requiring lib/private/Memcache/ArrayCache.php, but this does not seem like the right solution. That's why I thought I'll let you guys know about this because I suspect this might point to a bigger issue.

This is the demo app which can be used to trigger that behavior: https://github.com/klada/nextcloud-user-serverauth. Since the backend uses only public interfaces it should work... Or am I missing something?

// BTW: OpCache was my first suspect, so I have disabled it

klada added a commit to klada/nextcloud-user-serverauth that referenced this issue Mar 8, 2017
@rullzer
Copy link
Member

rullzer commented Mar 8, 2017

For the core classes we use the composer autoloader which is very well tested and used.

Sometimes not finding it seems odd indeed. I'm not able to reproduce the bug with your app. So that makes debugging even harder.

@klada
Copy link
Author

klada commented Mar 9, 2017

Thanks for testing @rullzer. I had already implemented a workaround for this issue, did you try it with or without that workaround?

I'll revert the workaround on the master branch for now and keep it in a separate branch.

@rullzer
Copy link
Member

rullzer commented Mar 9, 2017

Yes I tried without the work around

@nickvergessen
Copy link
Member

Try without <prelogin/> as app type: https://github.com/klada/nextcloud-user-serverauth/blob/master/user_serverauth/appinfo/info.xml#L14
It seems like that might cause the issue. the user_saml app also doesn't need this. and there the same other calls happen. So should be fine without?

@klada
Copy link
Author

klada commented Mar 14, 2017

@nickvergessen this was a perfect guess, without <prelogin/> the error can no longer be triggered. Nice one 👍

I don't know why I used <prelogin/> anyway. Maybe because user_external uses it.

But in the end there might still be an issue with <prelogin/> in combination with OC_User::handleApacheAuth(). I don't need this any more, but you guys need to decide if you would still like to dig into this (or maybe just document it?) or if you'll just close the bug. From my side, this was more like a just letting you guys know, just in case bug, as I had a workaround in place anyway.

thx

klada added a commit to klada/nextcloud-user-serverauth that referenced this issue Mar 14, 2017
This seems like the proper workaround for
nextcloud/server#3771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants