core icon indicating copy to clipboard operation
core copied to clipboard

OC 8 Alpha 1: Fatal error in node.php .. getId() .. when scanning for music via OCC

Open derkostka opened this issue 11 years ago • 28 comments

Steps to reproduce

Call occ music:scan --debug --all

Expected behaviour

Music DB for all users shall be updated

Actual behaviour

Process failes with an fatal error after some files

Server configuration

Operating system: Ubuntu 14.04
Web server: apache2
Database: mySQL
PHP version: PHP 5.5.9-1ubuntu4.5
ownCloud version: Owncloud 8 Alpha 1
Updated from an older ownCloud or fresh install: update from master from 18.12.
Are you using external storage: yes, local file system

Are you using encryption: no

Logs

root@odroid:/var/www/owncloud# ./occ music:scan --debug --all
Start scan for admin
Start scan for sanny
PHP Fatal error:  Call to a member function getId() on a non-object in /var/www/owncloud/lib/private/files/node/node.php on line 144

trace:

"PHP","message":"Call to a member function getId() on a non-object at \/var\/www\/owncloud\/lib\/private\/files\/node\/node.php#144","level":3,"time":"January 04, 2015 18:14:30"}

derkostka avatar Jan 04 '15 17:01 derkostka

Sorry, i forgot that i already reported this one in the music repository: https://github.com/owncloud/music/issues/331

Which is the right place ?

derkostka avatar Jan 05 '15 21:01 derkostka

Which is the right place ?

This seems to be an issue in core - this is the right place - THX

DeepDiver1975 avatar Jan 05 '15 21:01 DeepDiver1975

@icewind1991 can you please have a look? THX

DeepDiver1975 avatar Jan 07 '15 14:01 DeepDiver1975

@derkostka can you test this with #13317

icewind1991 avatar Jan 14 '15 12:01 icewind1991

@icewind1991 : i tested using the view.php from #13317, but the error remains: PHP Fatal error: Call to a member function getId() on a non-object in /var/www/owncloud/lib/private/files/node/node.php on line 144

derkostka avatar Jan 14 '15 20:01 derkostka

Hmmm I can neither reproduce the original issue (before the fix) nor after the fix.

Is there anything special in that music collection ? Are there part files laying around for that user ? Are there music files with special characters ?

PVince81 avatar Jan 16 '15 11:01 PVince81

Ah! I tried it again with the following steps:

  1. Enable music app
  2. mount -t cifs -o ro,username=vincent //localhost/shared /srv/www/htdocs/ocdata
  3. Enable external storage app
  4. Mount external storage "local" as system-wide mount "/music" using the dir "/srv/www/htdocs/ocdata"
  5. Run ./occ music:scan --debug --all

Am also getting this:

Start scan for root
PHP Fatal error:  Call to a member function getId() on boolean in /srv/www/htdocs/owncloud/lib/private/files/node/node.php on line 144
PHP Stack trace:
PHP   1. {main}() /srv/www/htdocs/owncloud/occ:0
PHP   2. require_once() /srv/www/htdocs/owncloud/occ:11
PHP   3. Symfony\Component\Console\Application->run() /srv/www/htdocs/owncloud/console.php:58
PHP   4. Symfony\Component\Console\Application->doRun() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:124
PHP   5. Symfony\Component\Console\Application->doRunCommand() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:193
PHP   6. Symfony\Component\Console\Command\Command->run() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:889
PHP   7. OCA\Music\Command\Scan->execute() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Command/Command.php:252
PHP   8. OCA\Music\Utility\Scanner->rescan() /srv/www/htdocs/owncloud/apps3/music/command/scan.php:89
PHP   9. OC\Files\Node\Node->getId() /srv/www/htdocs/owncloud/apps3/music/utility/scanner.php:368

Fatal error: Call to a member function getId() on boolean in /srv/www/htdocs/owncloud/lib/private/files/node/node.php on line 144

Call Stack:
    0.0000     228816   1. {main}() /srv/www/htdocs/owncloud/occ:0
    0.0002     245080   2. require_once('/srv/www/htdocs/owncloud/console.php') /srv/www/htdocs/owncloud/occ:11
    0.1067   14574296   3. Symfony\Component\Console\Application->run() /srv/www/htdocs/owncloud/console.php:58
    0.1089   14952160   4. Symfony\Component\Console\Application->doRun() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:124
    0.1090   14953048   5. Symfony\Component\Console\Application->doRunCommand() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:193
    0.1090   14953520   6. Symfony\Component\Console\Command\Command->run() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Application.php:889
    0.1092   14958176   7. OCA\Music\Command\Scan->execute() /srv/www/htdocs/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Command/Command.php:252
    0.1477   19770488   8. OCA\Music\Utility\Scanner->rescan() /srv/www/htdocs/owncloud/apps3/music/command/scan.php:89
    0.1514   20047288   9. OC\Files\Node\Node->getId() /srv/www/htdocs/owncloud/apps3/music/utility/scanner.php:368

Happens both before and after the fix. Possibly related to the read-only SMB mount.

PVince81 avatar Jan 16 '15 11:01 PVince81

Nice ! As commented in the related issue (in music app) I started exactly like that, with a read only, Linux mounted samba share. Now, I changed it into a rw share but still .. Something must hang there.

Please ping me if I can help somewhere !

derkostka avatar Jan 16 '15 12:01 derkostka

Am debugging this now. Very strange: file_exists returns false in $view->getFileInfo(). Digging deeper...

PVince81 avatar Jan 16 '15 12:01 PVince81

Ok, I got some clues. I uploaded the music in: /srv/www/htdocs/ocdata/music but mounted the folder /srv/www/htdocs/ocdata.

So whenever the scanner tries to read the file, it should be /srv/www/htdocs/ocdata/music/thefile.mp3. However what I observe is that it's trying to read the file in /srv/www/htdocs/ocdata/thefile.mp3.

PVince81 avatar Jan 16 '15 12:01 PVince81

It's a bug in the Node API's Folder's searchByMime. It actually finds two results:

  1. /srv/www/htdocs/ocdata/thefile.mp3
  2. /srv/www/htdocs/ocdata/music/thefile.mp3

It is supposed to first search files in the root storage. But in that case it shouldn't find 1) And then it searches for files in every mounted storage.

PVince81 avatar Jan 16 '15 12:01 PVince81

Hmmmm no...

I did a mistake, I mounted the external folder onto an existing folder which already contained music. This confused the search method.

Here are the steps again:

  1. Enable music app
  2. mount -t cifs -o ro,username=vincent //localhost/shared /srv/www/htdocs/ocdata
  3. Enable external storage app
  4. Create a folder "music"
  5. Upload a file "hiddenmusic.mp3" into "music"
  6. Mount external storage "local" as system-wide mount "/music" using the dir "/srv/www/htdocs/ocdata". This will overlap the existing music folder
  7. Run ./occ music:scan --debug --all

This is where I get the error because the scanner is confused by the overlapping folders. In the future this should be avoided with https://github.com/owncloud/core/issues/11794

@derkostka can you check in the "data" folder and see whether the buggy user has a folder with the same name like the mount point ? This would confirm that it's the same bug we're talking about.

There might be a way to fix the scanner / searchByMime to not be confused by such situations.

PVince81 avatar Jan 16 '15 12:01 PVince81

In the spirit of "test first development" I wrote unit tests to trigger the issue about searching in overlapped folders: https://github.com/owncloud/core/pull/13415

PVince81 avatar Jan 16 '15 13:01 PVince81

@DeepDiver1975 @karlitschek removing the showstopper tag as this only happens with this special case:

  1. ext storage is used
  2. ext storage is mounted over an existing folder (or at least one user had a folder with that name, thus name conflicts...)

PVince81 avatar Jan 16 '15 15:01 PVince81

I'm not happy with the fix in https://github.com/owncloud/core/pull/13415 as it will impair performance. Best would be to fix the core issue here and auto-rename folders on conflict: https://github.com/owncloud/core/issues/11794 (but even that one is quite tricky to fix)

PVince81 avatar Jan 16 '15 15:01 PVince81

@PVince81 sorry to tell but the issue is not fixed in my case. i checked the user, he has no "shadow" mount - still: root@odroid:/var/www/owncloud# ./occ music:scan --debug --all Start scan for admin Start scan for sanny PHP Fatal error: Call to a member function getId() on a non-object in /var/www/owncloud/lib/private/files/node/node.php on line 144

how can i take a trace to debug further ?

derkostka avatar Jan 16 '15 16:01 derkostka

It happens also for a second user. Here are some more infos: in /etc/fstab i mounted my iTunes library (from a nas) //192.168.6.1/iTunes /media/iTunes cifs username=media,password=media,rw,sec=ntlmv2 0 0 in owncloud, i redirect this folder as lokal file share named "iTunesMusic" to exactly two users, for whom the scan failes...

my owncloud data lies in /media/data/owncloud/data -> There, i cannot find the folder "iTunesMusic" neither in files nor in files_external

derkostka avatar Jan 16 '15 16:01 derkostka

Okay, then it's probably yet another issue :frowning:

Let's try something: open "music/utility/scanner.php" of the music app. After line 324 here https://github.com/owncloud/music/blob/master/utility/scanner.php#L325

Add the following code:

        foreach(array_merge($audio, $ogg) as $file) {
            \OC_Log::write('debug', $file->getPath(), \OC_Log::DEBUG);
        }

Then run the command again and check "owncloud.log". There should now be a few lines with "debug" that show all scanned file names. And maybe try and see if it's scanning anything that doesn't exist / isn't accessible from the web UI.

PVince81 avatar Jan 16 '15 17:01 PVince81

Here is the Trace, i will look if the File actually is readable meanwhile ... {"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"debug","message":"/sanny/files/iTunesMusic/iTunes Media/Music/Quant/Chill Out In Paris 5 Introduces Kings Of Lounge/05 Tryin.mp3","level":0,"time":"January 16, 2015 18:15:51","method":"--","url":"--"} {"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"debug","message":"/sanny/files/iTunesMusic/iTunes Media/Music/Quant/Chill Out In Paris 5 Introduces Kings Of Lounge/.AppleDouble/05 Tryin.mp3","level":0,"time":"January 16, 2015 18:15:51","method":"--","url":"--"} {"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"PHP","message":"Call to a member function getId() on a non-object at /var/www/owncloud/lib/private/files/node/node.php#144","level":3,"time":"January 16, 2015 18:15:51","method":"--","url":"--"}

An Option to skip these .AppleDouble files would be awesome by the way :-)

derkostka avatar Jan 16 '15 17:01 derkostka

okay i deleted the file (on the nas itself, not via owncloud) to see if i get more of these errors. now i am flooded by deprecated method messages - note: the file is not there anymore, seems like owncloud did not get this (are external file sources not observed for changes ?)

{"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"debug","message":"/sanny/files/iTunesMusic/iTunes Media/Music/Quant/Chill Out In Paris 5 Introduces Kings Of Lounge/05 Tryin.mp3","level":0,"time":"January 16, 2015 18:15:51","method":"--","url":"--"} {"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"debug","message":"/sanny/files/iTunesMusic/iTunes Media/Music/Quant/Chill Out In Paris 5 Introduces Kings Of Lounge/.AppleDouble/05 Tryin.mp3","level":0,"time":"January 16, 2015 18:15:51","method":"--","url":"--"} {"reqId":"7c87b8bf5c958ea6b929f98a32c275c5","remoteAddr":"","app":"PHP","message":"Call to a member function getId() on a non-object at /var/www/owncloud/lib/private/files/node/node.php#144","level":3,"time":"January 16, 2015 18:15:51","method":"--","url":"--"}

then (i guess this has nothing to do with this one)

{"reqId":"a5420c485d4ed135e92e56e974cbaae5","remoteAddr":"2a02:2450:102d:1fd:9ef3:87ff:feb2:3d02","app":"no app in context","message":"Accessing the server container is deprecated. Use type annotations to inject core services instead!","level":0,"time":"January 16, 2015 19:51:12","method":"PROPFIND","url":"/remote.php/webdav/"}

derkostka avatar Jan 16 '15 18:01 derkostka