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

Undefined offset: 3 at \/Users\/lreschke\/Programming\/core\/apps\/files\/controller\/apicontroller.php#105" #14277

Closed
LukasReschke opened this issue Feb 16, 2015 · 8 comments · Fixed by #14278

Comments

@LukasReschke
Copy link
Member

On current master when going to the Favourites sidebar:

{"reqId":"36b9928bf99ddbdbe5e7b8a4a5fdd065","remoteAddr":"::1","app":"PHP","message":"Undefined offset: 3 at /Users/lreschke/Programming/core/apps/files/controller/apicontroller.php#105","level":3,"time":"2015-02-16T23:04:37+00:00"}

@PVince81

@PVince81
Copy link
Contributor

Strange, I haven't seen this error before. Need to check if it happens on stable8 too.

@PVince81
Copy link
Contributor

I wonder if you have broken/bad entries in your DB that would make $parts[3] not exist.
I've seen this happen before but couldn't reproduce it.
Basically, you should only be able to tag files under "$user/files". But if somehow some bug managed to tag a file outside of that (ex: in trashbin).

If you still have that setup, can you do the following:
select * from oc_vcategory. Pick the id of the one with "favorites" in it.
select * from oc_filecache fc, oc_vcategory_to_object t where t.categoryid=$THECATEGORYID and t.objid=fc.fileid; (replace $THECATEGORYID with the one from the favorite tag)

@LukasReschke
Copy link
Member Author

Steps to reproduce:

  1. Setup a new ownCloud master instance
  2. Star the file "welcome.txt"
  3. Go to "Favorites"
  4. Experience the error message ;-)

DB:

sqlite> select * from oc_vcategory;
id|uid|type|category
1|admin|files|_$!<Favorite>!$_
sqlite> select * from oc_filecache fc, oc_vcategory_to_object t where t.categoryid=1 and t.objid=fc.fileid;
fileid|storage|path|path_hash|parent|name|mimetype|mimepart|size|mtime|storage_mtime|encrypted|unencrypted_size|etag|permissions|objid|categoryid|type
4|1|files/welcome.txt|c49a144e772727f51b75705170e88a43|3|welcome.txt|4|3|163|1424130986|1424130986|0|0|0cf0d17aca263970f182d8775e72e138|27|4|1|files

@PVince81
Copy link
Contributor

Huh... that seems to be correct. Unless the format of the path has changed.
If I remember well the reason why it has three parts is because it splits "$user/files/thirdpart" into "$user", "files" and "thirdpart" and picks "thirdpart" alone.

I'll see if I can reproduce it and debug inside.

Do you see the file shown correctly in the favorites list ?

@LukasReschke
Copy link
Member Author

Do you see the file shown correctly in the favorites list ?

Yes.

@PVince81
Copy link
Contributor

Okay got it... there is a leading slash in the path: "/user/files/thirdpart" becomes "", "user", "files" and "thirdpart" ...

Let me find out whether this was introduced recently.

@LukasReschke
Copy link
Member Author

🙈

@PVince81
Copy link
Contributor

Seems I always missed it...

If the favorite file is in the root, then $parts[3] is not defined, but the path is still correct ("/")
If the file is in a subdir, then $parts[3] is defined.

So basically this magically still worked properly.

Let's use your PR that fixes the warning then.

LukasReschke added a commit that referenced this issue Feb 17, 2015
This checks if the offset exists before accessing it and also adds unit tests to this function which would have catched this before 🙈

Fixes #14277
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants