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

AllConfig setUserValue opt #1734

Merged
merged 2 commits into from
Oct 18, 2016
Merged

AllConfig setUserValue opt #1734

merged 2 commits into from
Oct 18, 2016

Conversation

rullzer
Copy link
Member

@rullzer rullzer commented Oct 13, 2016

I noticed that when we do a SetUser value we first do and insert and if that fails we do an update. This for example happens everytime we refresh the ldap cache for a user at least 5 times.

Since often we have the user config fetched anyways we should take advantage of it. And only update if needed and if needed just update.

CC: @LukasReschke @nickvergessen @MorrisJobke

@rullzer rullzer added enhancement 3. to review Waiting for reviews labels Oct 13, 2016
@rullzer rullzer added this to the Nextcloud 11.0 milestone Oct 13, 2016
@mention-bot
Copy link

@rullzer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @schiessle, @MorrisJobke and @nickvergessen to be potential reviewers.

@@ -215,6 +215,29 @@ public function setUserValue($userId, $appName, $key, $value, $preCondition = nu
// TODO - FIXME
$this->fixDIInit();

if (isset($this->userCache[$userId])) {
if (isset($this->userCache[$userId][$appName])) {
if (isset($this->userCache[$userId][$appName][$key])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those 3 if statements could be one ;) best would be each isset on a new line ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes fair enough. I was actually in the process of adding tests. Which is kind of impossible since we can't do proper DI here at the moment :S

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if (isset($this->userCache[$userId][$appName][$key])) { is sufficient, php checks parents first and doesnt fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fancy

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@codecov-io
Copy link

codecov-io commented Oct 13, 2016

Current coverage is 57.05% (diff: 85.71%)

Merging #1734 into master will increase coverage by 0.36%

@@             master      #1734   diff @@
==========================================
  Files          1064       1064          
  Lines         60396      60981   +585   
  Methods        6818       6937   +119   
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          34235      34791   +556   
- Misses        26161      26190    +29   
  Partials          0          0          

Sunburst

Diff Coverage File Path
•••••••• 85% lib/private/AllConfig.php

Powered by Codecov. Last update 8c760e9...6c5f7d5

@rullzer
Copy link
Member Author

rullzer commented Oct 14, 2016

@nickvergessen @MorrisJobke fixed :) please review.

@MorrisJobke
Copy link
Member

Somehow autocomplete for LDAP users doesn't work anymore for all users in my local instance with this :(

@blizzz
Copy link
Member

blizzz commented Oct 14, 2016

@rullzer what about a unit test?

@rullzer
Copy link
Member Author

rullzer commented Oct 14, 2016

I can't properly unit test because there is no proper DI

@rullzer
Copy link
Member Author

rullzer commented Oct 14, 2016

I'll look into the ldap issue

@rullzer
Copy link
Member Author

rullzer commented Oct 14, 2016

@MorrisJobke mmm ldap still works here. I don't get it.

@rullzer
Copy link
Member Author

rullzer commented Oct 14, 2016

We could split out the userconfig from AllConfig. So we can do proper DI there. then AllConfig is just the external wrapper. Then we could do fancy unit tests

@MorrisJobke
Copy link
Member

Tested and works 👍 Sorry - I mistyped the user and then the autocomplete didn't worked 😉

@LukasReschke
Copy link
Member

LGTM

@LukasReschke LukasReschke merged commit c55a737 into master Oct 18, 2016
@LukasReschke LukasReschke deleted the setvalue_opt branch October 18, 2016 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants