Repository navigation
Optimize any request by eliminating redundant query for rootInfo and its contents - #27372
Conversation
|
@mrow4a, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975 and @PVince81 to be potential reviewers. |
|
Can you verify that there is no case that would not work here? |
c3757b9 to
1a22c23
Compare
|
Looks fine, I can't think of anything that could go wrong here 👍 CI will confirm |
| if (!is_null($userFolder)) { | ||
| $rootInfo = $userFolder->getFileInfo(); | ||
| } else { | ||
| $rootInfo = $view->getFileInfo(''); |
There was a problem hiding this comment.
Shouldnt we move this condition somewhere inside getUserFolder? This code is not too elegant now, I have been more interested if it was breaking something eventually, but my general idea was to move it inside the logic below @DeepDiver1975 @PVince81
There was a problem hiding this comment.
@PVince81 Some unit tests previously were not passing because userFolder was null, have no idea why it was returning null in some cases and we passed this null to other plugins, but calling $view->getFileInfo('') returns correctly
There was a problem hiding this comment.
WTF, ROOT calls get on itself which returns Folder, which then calls get which basicaly internaly calls return $this->root->get($this->getFullPath($path));, so basicaly root. It is very crazy or I am mistaken... It is like looking in the mirror holding another mirror
There was a problem hiding this comment.
Some unit tests previously were not passing because userFolder was null
Usually null is returned or PHPUnit mocks were one forgot to add an expectation and return value for a mocked method.
|
@PVince81 Hmm, actualy, I assume that if I understand that Or is it signaling that |
|
IIRC |
|
Maybe we should throw an exception when no user is logged in (or the user does not exist ... but that should trigger an exception in a different place - when trying to get the user object - anyway). After all you are not supposed to call getUserFolder() whon no user is logged in. That justifies an exception IMNSHO. It forces developers to use a try catch and think about what to do when no user folder can be obtained... |
|
@PVince81 What comments to add to this block, so it is transparent to the developer? Can you help here? |
|
I don't know |
|
I will do the test and throw an exception if we get null from somewhere else then user not logged in. If yes, we need to fix comments and maybe the code a little |
e7aac75 to
507e947
Compare
|
Yep, this is only possible if user is NULL and then it returns NULL. We can probably do it in try-catch or just leave as it is. |
704d41f to
d281e59
Compare
|
@DeepDiver1975 I think I need to refactor it to get rid of redundant queries from Folder/Directory logic |
d8c3689 to
5081670
Compare
|
Benchmark update on the new commit. Lets see if this passes all the existing unit/integration tests, and then I need to add few more to cover the code. |
cf444c2 to
eb6486a
Compare
|
@DeepDiver1975 @PVince81 Original implementation of https://github.com/owncloud/core/pull/27284/files SharesPlugin was using getDirectoryListing, duplicating number of the same queries. |
Call only getChildren to avoid excessive calls to DB
|
Any input on this PR? This not only gets rid of the redundant query for Root, but also avoid using |
|
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. |
#I found out that
\OC::$server->getUserFolder();will finish up calling$view->getFileInfo('');and storing this information in itsprotected $fileInfo;, so we can get rid of one redundant FileInfo query here.Effect of not calling

$view->getFileInfo('')once again:Non-shared:
With shared files of various types:


On my local machine all tests passed. @DeepDiver1975 @PVince81 @butonic @felixboehm