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

Call to a member function file_exists() on a non-object in owncloud/lib/private/files/filesystem.php on line 688 #18499

Closed
andersruneson opened this issue Aug 23, 2015 · 35 comments · Fixed by #21854

Comments

@andersruneson
Copy link

Steps to reproduce

This started at "random" two days ago but now occurs every 1h 15min.

Expected behaviour

Actual behaviour

Cron sends me a mail every 1h 15min (even though the cron job is run every 15min) with this content:
PHP Fatal error: Call to a member function file_exists() on a non-object in /var/www/owncloud/lib/private/files/filesystem.php on line 688

Server configuration

Operating system:
Ubuntu 14.04.3 LTS

Web server:
Apache2 (2.4.7-1ubuntu4.5)

Database:
MySQL (5.5.44-0ubuntu0.14.04.1)

PHP version:
PHP5 (5.5.9+dfsg-1ubuntu4.11)

ownCloud version: (see ownCloud admin page)
8.1.1-1

Updated from an older ownCloud or fresh install:
Updated since OC5 I think

List of activated apps:
Enabled:

  • activity: 2.0.1
  • external: 1.2
  • files: 1.1.10
  • files_pdfviewer: 0.7
  • files_sharing: 0.6.2
  • files_texteditor: 0.4
  • files_trashbin: 0.6.3
  • files_versions: 1.0.6
  • files_videoviewer: 0.1.3
  • firstrunwizard: 1.1
  • gallery: 0.6.0
  • user_ldap: 0.6.1
    Disabled:
  • appframework
  • encryption
  • files_external
  • files_locking
  • provisioning_api
  • templateeditor
  • user_external
  • user_webdavauth

The content of config/config.php:

$CONFIG = array (
  'instanceid' => 'MASKED',
  'passwordsalt' => 'MASKED',
  'datadirectory' => '/mnt/oc-data/oc-data',
  'dbtype' => 'mysql',
  'version' => '8.1.1.3',
  'dbname' => 'owncloud',
  'dbhost' => 'mysql',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'MASKED',
  'dbpassword' => 'MASKED',
  'overwritehost' => 'MASKED',
  'overwriteprotocol' => 'https',
  'overwritewebroot' => '/',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'forcessl' => true,
  'theme' => 'myowntheme',
  'maintenance' => false,
  'trusted_domains' => 
  array (
    0 => 'MASKED',
  ),
  'mail_from_address' => 'noreply',
  'mail_smtpmode' => 'php',
  'mail_domain' => 'MASKED',
  'secret' => 'MASKED',
  'loglevel' => '3',
);

Are you using external storage, if yes which one: local/smb/sftp/...
No

Are you using encryption: yes/no
No

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
Active Directory

LDAP configuration (delete this part if not used)

+-------------------------------+-------------------------------------------------------------------------------------------------+
| Configuration                 | s01                                                                                             |
+-------------------------------+-------------------------------------------------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                                                               |
| hasPagedResultSupport         |                                                                                                 |
| homeFolderNamingRule          | attr:sAMAccountName                                                                             |
| lastJpegPhotoLookup           | 0                                                                                               |
| ldapAgentName                 | CN=MASKED,OU=Service Accounts,DC=MASKED,DC=se                                                   |
| ldapAgentPassword             | ***                                                                                             |
| ldapAttributesForGroupSearch  |                                                                                                 |
| ldapAttributesForUserSearch   |                                                                                                 |
| ldapBackupHost                |                                                                                                 |
| ldapBackupPort                |                                                                                                 |
| ldapBase                      | dc=MASKED,dc=se                                                                                 |
| ldapBaseGroups                | ou=Projects,ou=Groups,dc=MASKED,dc=se                                                           |
| ldapBaseUsers                 | ou=User accounts,dc=MASKED,dc=se;ou=User accounts 2,dc=MASKED,dc=se;ou=Extranet,dc=MASKED,dc=se |
| ldapCacheTTL                  | 1200                                                                                            |
| ldapConfigurationActive       | 1                                                                                               |
| ldapEmailAttribute            | mail                                                                                            |
| ldapExperiencedAdmin          | 0                                                                                               |
| ldapExpertUUIDGroupAttr       |                                                                                                 |
| ldapExpertUUIDUserAttr        |                                                                                                 |
| ldapExpertUsernameAttr        | sAMAccountName                                                                                  |
| ldapGroupDisplayName          | cn                                                                                              |
| ldapGroupFilter               | (&(|(objectclass=group)))                                                                       |
| ldapGroupFilterGroups         |                                                                                                 |
| ldapGroupFilterMode           | 0                                                                                               |
| ldapGroupFilterObjectclass    | group                                                                                           |
| ldapGroupMemberAssocAttr      | member                                                                                          |
| ldapHost                      | ldap.MASKED.se                                                                                  |
| ldapIgnoreNamingRules         |                                                                                                 |
| ldapLoginFilter               | (&(&(|(objectclass=person)))(samaccountname=%uid))                                              |
| ldapLoginFilterAttributes     |                                                                                                 |
| ldapLoginFilterEmail          | 0                                                                                               |
| ldapLoginFilterMode           | 0                                                                                               |
| ldapLoginFilterUsername       | 1                                                                                               |
| ldapNestedGroups              | 1                                                                                               |
| ldapNoCase                    | 1                                                                                               |
| ldapOverrideMainServer        | 0                                                                                               |
| ldapPagingSize                | 500                                                                                             |
| ldapPort                      | 389                                                                                             |
| ldapQuotaAttribute            |                                                                                                 |
| ldapQuotaDefault              |                                                                                                 |
| ldapTLS                       | 0                                                                                               |
| ldapUserDisplayName           | cn                                                                                              |
| ldapUserFilter                | (&(|(objectclass=person)))                                                                      |
| ldapUserFilterGroups          |                                                                                                 |
| ldapUserFilterMode            | 0                                                                                               |
| ldapUserFilterObjectclass     | person                                                                                          |
| ldapUuidGroupAttribute        | auto                                                                                            |
| ldapUuidUserAttribute         | auto                                                                                            |
| turnOffCertCheck              | 0                                                                                               |
| useMemberOfToDetectMembership | 1                                                                                               |
+-------------------------------+-------------------------------------------------------------------------------------------------+

Logs

Web server error log

Nothing relevant at the time of the error either in the access log or the error log.

ownCloud log (data/owncloud.log)

Call to a member function file_exists() on a non-object at /var/www/owncloud/lib/private/files/filesystem.php#688 
@ghost
Copy link

ghost commented Aug 23, 2015

Might be related to #16740

@PVince81
Copy link
Contributor

@andersruneson can you post your "oc_jobs" table so we can see what cron jobs you have ?

It could also help if you could enable XDebug temporarily, it will hopefully provide a stack trace along with the error message that could help pinpoint which cron job is causing trouble.

@andersruneson
Copy link
Author

id  class                                               argument                last_run    
1   OC\BackgroundJob\Legacy\RegularJob                  ["\\OC\\Files\\Cache\\BackgroundWatcher","checkNext"]   1440405901
2   OCA\user_ldap\lib\Jobs                              null                    1440404102
133 OCA\Activity\BackgroundJob\EmailNotification        null                    1440405001
134 \OCA\User_LDAP\Jobs\CleanUp                         null                    1440405001
135 OCA\Activity\BackgroundJob\ExpireActivities         null                    1440383402
136 OCA\Files_sharing\Lib\DeleteOrphanedSharesJob       null                    1440405002

Not sure I know how to XDebug, especially a cron job?

@andersruneson
Copy link
Author

By the timestamp of last run (when checking the oc_jobs table 20 min after I got the mail) I'm guessing the issue comes from OCA\user_ldap\lib\Jobs

I have enabled XDebug, I assume all what's needed is to install php5-xdebug and restart apache service and wait for next run for that job.

@andersruneson
Copy link
Author

PHP Fatal error:  Call to a member function file_exists() on a non-object in /var/www/owncloud/lib/private/files/filesystem.php on line 688
PHP Stack trace:
PHP   1. {main}() /var/www/owncloud/cron.php:0
PHP   2. OC\BackgroundJob\TimedJob->execute() /var/www/owncloud/cron.php:130
PHP   3. OC\BackgroundJob\Job->execute() /var/www/owncloud/lib/private/backgroundjob/timedjob.php:53
PHP   4. OCA\user_ldap\lib\Jobs->run() /var/www/owncloud/lib/private/backgroundjob/job.php:52
PHP   5. OCA\user_ldap\lib\Jobs::updateGroups() /var/www/owncloud/apps/user_ldap/lib/jobs.php:47
PHP   6. OCA\user_ldap\lib\Jobs::handleKnownGroups() /var/www/owncloud/apps/user_ldap/lib/jobs.php:63
PHP   7. OCP\Util::emitHook() /var/www/owncloud/apps/user_ldap/lib/jobs.php:101
PHP   8. OC_Hook::emit() /var/www/owncloud/lib/public/util.php:472
PHP   9. call_user_func() /var/www/owncloud/lib/private/hook.php:103
PHP  10. OC\Share\Hooks::post_addToGroup() /var/www/owncloud/lib/private/hook.php:103
PHP  11. OC\Share\Helper::generateTarget() /var/www/owncloud/lib/private/share/hooks.php:66
PHP  12. OC_Share_Backend_File->generateTarget() /var/www/owncloud/lib/private/share/helper.php:68
PHP  13. OCA\Files_Sharing\Helper::getShareFolder() /var/www/owncloud/apps/files_sharing/lib/share/file.php:74
PHP  14. OC\Files\Filesystem::file_exists() /var/www/owncloud/apps/files_sharing/lib/helper.php:285

@PVince81
Copy link
Contributor

@blizzz any idea ?

@andersruneson
Copy link
Author

Is there any way I can debug this futher?

@andersruneson
Copy link
Author

I guess the error means there is no object \OC\Files\Filesystem ?
But the line just before is
$shareFolder = \OC\Files\Filesystem::normalizePath($shareFolder);
Using that same object, \OC\Files\Filesystem ?

I've tried follow the call stack to see any obvious errors but I'm really not that skilled.
It looks like an existing user has been added to a new group and I guess the code makes all shares to this group is also shared to this user.

@PVince81
Copy link
Contributor

Maybe a setupFS() call or something is missing in the background job. @icewind1991 any idea ?

@andersruneson
Copy link
Author

Since yesterday the issue disappeared, since I added some debug output to the scripts I got a last mail from cron where I can see that the php error did not occur but instead all tasks was done.

@cdamken
Copy link
Contributor

cdamken commented Sep 29, 2015

Hi, Here is my XDEBUG error String:

PHP Fatal error: Call to a member function file_exists() on a non-object in /var/www/owncloud/lib/private/files/filesystem.php on line 688
PHP Stack trace:
PHP 1. {main}() /var/www/owncloud/cron.php:0
PHP 2. OC\BackgroundJob\TimedJob->execute() /var/www/owncloud/cron.php:130
PHP 3. OC\BackgroundJob\Job->execute() /var/www/owncloud/lib/private/backgroundjob/timedjob.php:53
PHP 4. OCA\user_ldap\lib\Jobs->run() /var/www/owncloud/lib/private/backgroundjob/job.php:52
PHP 5. OCA\user_ldap\lib\Jobs::updateGroups() /var/www/owncloud/apps/user_ldap/lib/jobs.php:47
PHP 6. OCA\user_ldap\lib\Jobs::handleKnownGroups() /var/www/owncloud/apps/user_ldap/lib/jobs.php:63
PHP 7. OCP\Util::emitHook() /var/www/owncloud/apps/user_ldap/lib/jobs.php:101
PHP 8. OC_Hook::emit() /var/www/owncloud/lib/public/util.php:472
PHP 9. call_user_func() /var/www/owncloud/lib/private/hook.php:103
PHP 10. OC\Share\Hooks::post_addToGroup() /var/www/owncloud/lib/private/hook.php:103
PHP 11. OC\Share\Helper::generateTarget() /var/www/owncloud/lib/private/share/hooks.php:66
PHP 12. OC_Share_Backend_File->generateTarget() /var/www/owncloud/lib/private/share/helper.php:68
PHP 13. OCA\Files_Sharing\Helper::getShareFolder() /var/www/owncloud/apps/files_sharing/lib/share/file.php:74
PHP 14. OC\Files\Filesystem::file_exists() /var/www/owncloud/apps/files_sharing/lib/helper.php:285

Since this weekend we get an error nearly every hour.

@PVince81 @blizzz @MorrisJobke Any clue here? Do you need my whole server architecture?

00003832

@cdamken cdamken reopened this Sep 29, 2015
@MorrisJobke
Copy link
Contributor

@cdamken What version is this server instance on?

@MorrisJobke
Copy link
Contributor

@PVince81 I think the init on the filesystem is missing here somehow.

$defaultInstance is null here: https://github.com/owncloud/core/blob/fbe296df17f4d97fde4b7148198cde11c29fb8b7/lib/private/files/filesystem.php#L688-688

@schiesbn Could this be the cause? Is the filesystem set up in the hooks or do you rely on a properly setup filesystem for post_addToGroup hook of OC_User?

@cdamken
Copy link
Contributor

cdamken commented Sep 29, 2015

@MorrisJobke {"installed":"true","version":"7.0.5.2","versionstring":"7.0.5","edition":"enterprise"}

@MorrisJobke
Copy link
Contributor

@schiesbn Ping

@MorrisJobke
Copy link
Contributor

@MorrisJobke {"installed":"true","version":"7.0.5.2","versionstring":"7.0.5","edition":"enterprise"}

This seems to be a 8.1.1 instance where this error happened. @schiesbn Can you have a look at my question?

@isgsoftware
Copy link

I am seeing this issue on newly installed 8.2.1. I created a custom external authentication app which authenticates users against a web service (similar to IMAP or SMB), but it also adds them to an existing OC group (if they are not already in it, such as first time logging in) so they can see some already shared files.

When I make the call to Group->addUser(), the server crashes with this same stack trace and error, but only if the group already has some files shared to it.

If I remove all shares to the group, the Group->addUser() succeeds.

I'm hoping this may add some info to help track down the root cause of the issue. Let me know if I can provide other details.

@isgsoftware
Copy link

I was able to address this issue, at least for my use case. When adding the user to a group that already has shares assigned to it, the user's home directory needs to be initialized first in order for $defaultInstance to not be null. I added a call "\OC\Files\Filesystem::init($uid, $userDir);" just before the user is added to the group and it seems to be working well.

@bboule bboule added this to the 9.0-current milestone Dec 28, 2015
@bboule
Copy link

bboule commented Dec 28, 2015

@MorrisJobke in @schiesbn absence is there someone else that could help on this issue as it seems to be stuck?

@andersruneson
Copy link
Author

Sounds like it could be the same issue for ldap, maybe the user was never
logged in, and after he did the issue disappeared.
On 28 Dec 2015 17:48, "bboule" [email protected] wrote:

@MorrisJobke https://github.com/MorrisJobke in @schiesbn
https://github.com/schiesbn absence is there someone else that could
help on this issue as it seems to be stuck?


Reply to this email directly or view it on GitHub
#18499 (comment).

@bboule
Copy link

bboule commented Jan 6, 2016

@cmonteroluque any thoughts on how to move this forward? @cdamken can you confirm that this is a Blue Ticket?

@MorrisJobke
Copy link
Contributor

@blizzz Is it possible that this is fixed by the latest LDAP fixes for fetching the user info not on login but once the user object is needed?

@cdamken Do they use LDAP?

@MorrisJobke
Copy link
Contributor

I can at least verify @pellaeon's description:

  • install registration app
  • create a group
  • share a file to this group
  • setup this group as default group for registered users
  • register a new user

@MorrisJobke
Copy link
Contributor

stack trace right in the method where the problem occurs:

{"reqId":"omRUXsS4APlfxB\/9EzZe","remoteAddr":"::1","app":"no app in context","message":"Exception: {\"Exception\":\"Exception\",\"Message\":\"/\",\"Code\":0,\"Trace\":\"
#0 apps/files_sharing/lib/helper.php(283): OC\Files\Filesystem::file_exists('/')
#1 apps/files_sharing/lib/share/file.php(79): OCA\Files_Sharing\Helper::getShareFolder()
#2 lib/private/share/helper.php(68): OC_Share_Backend_File->generateTarget('19', 'asdas')
#3 lib/private/share/hooks.php(86): OC\Share\Helper::generateTarget('folder', '19', 0, 'asdas', 'def', NULL, NULL)
#4 [internal function]: OC\Share\Hooks::pre_addToGroup(Array)
#5 lib/private/hook.php(104): call_user_func(Array, Array)
#6 lib/private/server.php(194): OC_Hook::emit('OC_Group', 'pre_addToGroup', Array)
#7 [internal function]: OC\Server->OC\{closure}(Object(OC\Group\Group), Object(OC\User\User))
#8 lib/private/hooks/emittertrait.php(98): call_user_func_array(Object(Closure), Array)
#9 lib/private/hooks/publicemitter.php(32): OC\Hooks\BasicEmitter->emit('\OC\Group', 'preAddUser', Array)
#10 lib/private/group/group.php(136): OC\Hooks\PublicEmitter->emit('\OC\Group', 'preAddUser', Array)
#11 apps/registration/controller/registercontroller.php(216): OC\Group\Group->addUser(Object(OC\User\User))
#12 [internal function]: OCA\Registration\Controller\RegisterController->createAccount('BnucCqM3ZDle4OU...')
#13 lib/private/appframework/http/dispatcher.php(159): call_user_func_array(Array, Array)
#14 lib/private/appframework/http/dispatcher.php(89): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Registration\Controller\RegisterController), 'createAccount')
#15 lib/private/appframework/app.php(110): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Registration\Controller\RegisterController), 'createAccount')
#16 lib/private/appframework/routing/routeactionhandler.php(45): OC\AppFramework\App::main('RegisterControl...', 'createAccount', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#17 [internal function]: OC\AppFramework\routing\RouteActionHandler->__invoke(Array)
#18 lib/private/route/router.php(273): call_user_func(Object(OC\AppFramework\routing\RouteActionHandler), Array)
#19 lib/base.php(864): OC\Route\Router->match('/apps/registrat...')
#20 index.php(39): OC::handleRequest()
#21 {main}\",\"File\":\"lib/private/files/filesystem.php\",\"Line\":693}","level":3,"time":"2016-01-22T12:52:42+00:00"}

MorrisJobke added a commit that referenced this issue Jan 22, 2016
* sets up the filesystem of the user that is added to a group
  to properly accept shares
* fixes #18499
@MorrisJobke
Copy link
Contributor

Possible fix: #21854

@ghost
Copy link

ghost commented Feb 24, 2016

We have competing PR's and neither of them seems to work #21854 and #22421

Moving to 8.2.4 anyway

@ghost ghost modified the milestones: 8.2.4-next-maintenance, 9.0-current Feb 24, 2016
@MorrisJobke MorrisJobke modified the milestones: 9.0-current, 8.2.4-next-maintenance Feb 25, 2016
MorrisJobke added a commit that referenced this issue Feb 25, 2016
* sets up the filesystem of the user that is added to a group
  to properly accept shares
* fixes #18499
@MorrisJobke MorrisJobke removed their assignment Mar 1, 2016
@greenled
Copy link

Hi. Just upgraded from 8 to 9 and I am getting PHP Fatal error: Call to a member function file_exists() on a non-object in /var/www/owncloud/lib/private/files/filesystem.php on line 693 too, but after running occ dav:migrate-addressbooks.

@oliveirart
Copy link

oliveirart commented Apr 20, 2016

I'm getting the same error on line 693 when trying to share a folder using link and password:

"[Wed Apr 20 18:11:12.422915 2016] [:error] [pid 12224] [client 200.202.168.159:34176] PHP Fatal error: Call to a member function file_exists() on a non-object in /var/www/html/owncloud/lib/private/files/filesystem.php on line 693"

  • File sharing with/without password is ok!
  • Folder sharing without password is ok!

Any ideas?

@trourance
Copy link

Still getting the same error message in 9.0.2

Error PHP Call to a member function file_exists() on a non-object at /var/www/fluance.net/owncloud/lib/private/files/filesystem.php#696 2016-05-25T13:02:53+02:00

@wpoely86
Copy link

wpoely86 commented Jun 2, 2016

I can confirm. Just like @fluancefg we see it too on 9.0.2.

@steffen-moser
Copy link

We are seeing this problem for LDAP users and who have never logged in before receiving a share in OC 9.0.2 on Apache 2.4.12 and PHP-5.6.8 (on Solaris 11.3), too. The fixes discussed here and in previous bug reports regarding this issue have already been applied to 9.0.2 or didn't help for me (like #22664).

There seems to be a new bug report related to this issue under #24423 which addresses it explicitly in 9.0.2.

@ghost
Copy link

ghost commented Jul 13, 2016

@steffen-moser According to #24423 (comment) its now fixed in oC 9.0.3

@lock
Copy link

lock bot commented Aug 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.