Optimize resolveGroupShare#27434
Conversation
|
@DeepDiver1975 @SergioBertolinSG @PVince81 Do we have integration for this scenario of moving group share to other folder, group share folder, fed share whatever? Unit test cover the changes already. |
| * Resolve a group share to a user specific share | ||
| * Thus if the user moved their group share make sure this is properly reflected here. | ||
| * Resolve a group shares to a user specific share. | ||
| * Returns in the array both the updated share if one was found and for not found in DB passing predicate, the original shares. |
There was a problem hiding this comment.
mind clarifying what you mean with "updated share" and "original share" ?
Do you mean that "original share" is the actual group share and "updated share" is the user-specific special entry ?
There was a problem hiding this comment.
Hmm, ok, I should say resolved :>
There was a problem hiding this comment.
an the line is too long - 80 chars please
|
@mrow4a There are quite a few int. tests about sharing, perhaps the test you are looking for is this one https://github.com/owncloud/core/blob/master/tests/integration/features/sharing-v1.feature#L522 . If you miss some specific case, please tell me / open a ticket in QA repo. |
| * Resolve a group share to a user specific share | ||
| * Thus if the user moved their group share make sure this is properly reflected here. | ||
| * Resolve a group shares to a user specific share. | ||
| * Returns in the array both the updated share if one was found and for not found in DB passing predicate, the original shares. |
There was a problem hiding this comment.
an the line is too long - 80 chars please
| $qb = $this->dbConn->getQueryBuilder(); | ||
|
|
||
| $stmt = $qb->select('*') | ||
| $shareParentIds = array_keys($parentIdToShareMap); |
bb6291e to
63b95a4
Compare
There was a problem hiding this comment.
Rename to shareIdToShareMap or simply sharesMap ? Because it seems that's what it is.
It can of course be used to resolve parents but that's only one possibility
The "parent" bit confused me.
There was a problem hiding this comment.
I have trouble understanding the chunking part, it seems this array stores chunks so call it something with "chunk" in its name. See comment below to possibly avoid saying "parent".
There was a problem hiding this comment.
Can you explain the chunking part with code comments ?
It seems it's basically just building a chunked array of share ids ?
The "parent" part in the name makes it more confusing, I suggest removing it.
$parentId is just $shareId.
There was a problem hiding this comment.
yep, it just optimised for this case array_chunk, avoiding unnecessary loops.
|
@mrow4a code looks good. Took me a while due to the variable names confusing me. |
63b95a4 to
1b4520c
Compare
There was a problem hiding this comment.
Move this to another function so we can unittest it?
There was a problem hiding this comment.
TO unit tests it is to have >100 shares
There was a problem hiding this comment.
There was a problem hiding this comment.
This part of code involves chunking the shares list, which isn't related to the DB access that the rest of the function perform. That another reason to extract this piece out.
There was a problem hiding this comment.
I have no idea what you want to achieve here, I need to contruct $shareIdToShareMap and $chunkedShareIds, and this is what the loop is doing. I need that to avoid unnecesairly loops over shares
There was a problem hiding this comment.
I need to contruct $shareIdToShareMap and $chunkedShareIds
My point is that another private function could take care of the chunking in order to make this function to focus on fetching the data from the DB. It's fine if this function calls the "chunking function" and then fetch the data.
There was a problem hiding this comment.
This function would need to return 2 arrays...
There was a problem hiding this comment.
Ok, will try it and see how it looks like. I get your point.
There was a problem hiding this comment.
@jvillafanez Addressed this in the commit, wrote function chunkSharesToMaps()
There was a problem hiding this comment.
is the array_values needed?
There was a problem hiding this comment.
Hmm good question, how array merge will handle it in upper layer. This is basicaly converting from map to classical array, which is used in upper layer
There was a problem hiding this comment.
$shareId = $data['parent']; I guess this won't be unqiue, will it? But if it won't be unique, the check above (if (isset($shareIdToShareMap[$shareId]))) could be problematic.... I need some light there.
There was a problem hiding this comment.
but there could be several entries with the same parent.... that's what worries me.
There was a problem hiding this comment.
I am discussing this with @cdamken lets see what comes out
There was a problem hiding this comment.
Ok we tried things and seems impossible
There was a problem hiding this comment.
If consider the parent will be unique, I think it's better to make the consideration all the way through, so if the assumption is wrong 💥 and 🚑 , otherwise it will be a pain to debug what's going on.
So, the key of the $shareIdToShareMap map will be unique and the array_merge (without the array_values) shouldn't be a problem. The only question is if those keys are used in any other place, if not we could ignore the array_values
There was a problem hiding this comment.
I think we need array_values... the other array in upper layer is not a map
There was a problem hiding this comment.
ok, fair enough. Maybe something to check in the future. Anyway 👍
There was a problem hiding this comment.
Any other better exception that we could throw here? I'm not fan of throwing plain exceptions
There was a problem hiding this comment.
We already throw this exception in this class, and this error is basicaly WTF error which should not happen -> if developer later touches this and breaks, he will know immedietaly :> Other alternative is just to throw IndexError as default, but it will probably confuse
3297113 to
a14d271
Compare
There was a problem hiding this comment.
@jvillafanez I think this should be what you wanted to achieve
a14d271 to
d195262
Compare
|
The code is fine for me, just #27434 (review) , but unless there is any other change I don't think it's worthy. |
d195262 to
c64f0e4
Compare
|
I think I addressed the reviewed code @DeepDiver1975 any ideas? |
|
👍 from me as well, code is way more readable now. |
|
Not sure if we should backport this, it's a huge change and a bit risky. Needs proper retesting. Thoughts ? |
|
Long story short: The patch was sent to the customer because it looks like the fixes the issue. I'm not sure if cherry pick will work, but anyhow the solution works for master and 9.1.4 too. |
|
Agreed to not backport due to the risk. Advise to update to 10 or can provide this patch to other customers on 9.1.4 if they really want - with the risk that comes with it. |
|
Ok, I asked to upgrade to 10. |
|
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. |

This optimizes the case in which you do PROPFIND to some folder, in which you had group share, and that share was moved to another folder (generaly people reorganise stuff from root folder to their required folders)
Below is what happens when you move file
testgrshare.txtwhich has some group shares receiver/send to another folder and then propfind the "old" root folder: