photos icon indicating copy to clipboard operation
photos copied to clipboard

Cannot add photo to album (`Call to undefined method OCA\Photos\Sabre\Album\AlbumRoot::getPath`)

Open p5n opened this issue 2 years ago • 16 comments

To Reproduce

  • Select album
  • press add photo
  • select photo
  • Call to undefined method OCA\Photos\Sabre\Album\AlbumRoot::getPath

Expected behavior Added photo

Desktop (please complete the following information):

  • OS: ArchLinux
  • firefox 108.0.1-1

Was able to fix it by adding following function to https://github.com/nextcloud/photos/blob/master/lib/Sabre/Album/AlbumRoot.php

$ diff AlbumRoot.php.bak AlbumRoot.php 
84a85,88
> 	public function getPath() {
> 		return $this->rootFolder->getUserFolder($this->userId)->getPath();
> 	}
> 

Not sure if it is correct solution but photo was added somehow.

p5n avatar Dec 27 '22 20:12 p5n

I somehow cannot reproduce this with master from both NC and Photos.

simonspa avatar Jan 21 '23 19:01 simonspa

With nextcloud 25.0.3 it adds without this patch, but error appeared in top right corner that it failed to add photo. Also it looks like adding photo from shared read-only folder affects. Own photo was added without error.

p5n avatar Jan 21 '23 19:01 p5n

I indeed cannot add a photo to an album if the photo is shared with me. I also get the 'Failed to add...' message in the top right corner.

siccovansas avatar May 16 '23 15:05 siccovansas

I indeed cannot add a photo to an album if the photo is shared with me. I also get the 'Failed to add...' message in the top right corner.

I see the same thing, and it's even more amusing because it happens when I upload a photo to a directory shared with me, and then try to add that photo to an album. I don't see any errors in the logs, just a failed message in the corner.

chmeeedalf avatar Jun 25 '23 17:06 chmeeedalf

Can anyone experiencing this provide the log entry (i.e. the full stack trace) from their nextcloud.log? That will help in getting this issue looked at more closely.

joshtrichards avatar Jul 06 '23 18:07 joshtrichards

Here are my entries from nextcloud.log when trying to add a photo from a shared folder:

{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Maps\\Hooks\\FileHooks::$lockingProvider is deprecated at /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php#46","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"kOBSiSuAOXbscsdOwCve","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"webdav","method":"COPY","url":"/remote.php/dav/files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","message":"Can't add file to album, only files from XXXXUSER can be added","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","exception":{"Exception":"Sabre\\DAV\\Exception\\Forbidden","Message":"Can't add file to album, only files from XXXXUSER can be added","Code":0,"Trace":[{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php","line":132,"function":"copyInto","class":"OCA\\Photos\\Sabre\\Album\\AlbumRoot","type":"->","args":["XXXXFILE.JPG","files/XXXXUSER/XXXXPATH/XXXXFILE.JPG",["OCA\\DAV\\Connector\\Sabre\\File"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":659,"function":"copy","class":"Sabre\\DAV\\Tree","type":"->","args":["files/XXXXUSER/XXXXPATH/XXXXFILE.JPG","photos/XXXXUSER/albums/XXXSHAREDALBUM/XXXXFILE.JPG"]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpCopy","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["method:COPY",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":366,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":172,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php","Line":167,"message":"Can't add file to album, only files from XXXXUSER can be added","exception":{},"CustomMessage":"Can't add file to album, only files from XXXXUSER can be added"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Maps\\Hooks\\FileHooks::$lockingProvider is deprecated at /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php#46","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}
{"reqId":"8hYhXy5WHSy3uGIBZwWn","level":0,"time":"2023-07-07T11:15:17+00:00","remoteAddr":"XXX.XXX.XXX.XXX","user":"XXXXUSER","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/photos/XXXXUSER/albums/XXXXSHAREDALBUM/","message":"Creation of dynamic property OCA\\Photos\\Sabre\\Album\\AlbumRoot::$userConfigService is deprecated at /var/www/html/apps/photos/lib/Sabre/Album/AlbumRoot.php#58","userAgent":"XXXXXXXXXXXXXXXXX","version":"26.0.3.2","data":{"app":"PHP"}}

Line 6 seems to hold a clue: Can't add file to album, only files from XXXXUSER can be added :) (Note: XXXXUSER is a substitute for my username; so it says that I can only add my own files to the album).

As a user I would expect all photos that I can select from the 'Add photos to this album' popup picker to be addable to the album. Given that shared photos are shown in the picker I should be able to add them to the album.

siccovansas avatar Jul 07 '23 11:07 siccovansas

I still have this issue. Pictures from shared folders can't be added to shared albums. Is there any progress on this? Or does anyone know a workaround?

ubrfkr avatar Dec 18 '23 03:12 ubrfkr

The error/issue is there: https://github.com/nextcloud/photos/blob/4c7c00ea3f5686c3b2d6158d6b23cfb3f7fe6de8/lib/Sabre/Album/AlbumRoot.php#L167 But I guess there is a reason why we can not do it ...

titilambert avatar Jan 13 '24 20:01 titilambert

But I guess there is a reason why we can not do it ...

This behavior makes sense in many cases, however there are other use cases in which adding a picture to an album should be possible even though the picture was shared with the user adding it. For example Alice shares a folder and an Album with Bob, Bob should then be allowed to add Alice's pictures to Alice's album.

StefanAbl avatar Jan 15 '24 14:01 StefanAbl

Hi all, I have two user on my nexcloud 1=boss 2=employee. All pictures are uploaded by boss and the folder is shared with employee. Boss creates now an album and shared this with employee.

Employee can display this album and can remove pictures but he can not add pictures even if they are uploaded by himselfe. For me this is a cleare bug and stops me to use nextcloud with multiple users.

So please - can someone provide a fix for that? I also tried the app groupfolder but this is not really working with memories

HolgerDoerrschuck avatar Feb 07 '24 06:02 HolgerDoerrschuck

Same problem here, on 15 differents nextclouds. If the photo added into an album does not belong to the user, it fails with message "Can't add file to album, only files from...". Very disturbing since the user can see all images shared with him...

nderambure avatar Mar 01 '24 23:03 nderambure

I also have the same issue. To me this is also clearly a bug and really limits my usability of nextcloud. Maybe it comes from the issue what to do with the album, if sharing is ended. But to me it should maybe just be a show list of files not accessible anymore, once the permission is revoked.

sbrems avatar Apr 01 '24 15:04 sbrems

I have the same issue. Only the owner sharing the folder can add photos to albums. No matter who uploaded the photos or created the album. But everyone the album is shared with can delete photos from it.

I also tried to create a group as admin and share a folder with this group. No one in the group can use photos from this folder then. Transferring the ownership of a folder does not help either.

I would expect the same behavior when the share is revoked as if they were deleted: placeholder thumbs.

Steps to reproduce:

  • Log in as Bob
  • Create and share a folder with Anna
  • Add a photo to folder
  • Log in as Anna
  • Create an album
  • Add photo to album

Or Bob can create an album an add Anna as collaborator, same result.

pixelpunk-DE avatar Apr 06 '24 10:04 pixelpunk-DE

Same problem here, with the "photo" application or the "memories" one. I can't share a folder and an album with my wife where we could choose which picture we want to show in this album :(

dab0u avatar Aug 05 '24 10:08 dab0u

wow .. it is now such a long time ago where a lot of people report this bug and nothing happend.

HolgerDoerrschuck avatar Aug 05 '24 10:08 HolgerDoerrschuck

The OP in this thread stated this is the error: Call to undefined method OCA\Photos\Sabre\Album\AlbumRoot::getPath

Most of you sound like you're not experiencing that, but #2095. So please make sure you're looking at the correct issue.

@HolgerDoerrschuck You're welcome to jump in, diagnose the root cause, and submit a bug fix in a PR.

joshtrichards avatar Aug 05 '24 12:08 joshtrichards