-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[master] Add emitters for user preferences #31307
Conversation
0bd8bad
to
c85685c
Compare
Codecov Report
@@ Coverage Diff @@
## master #31307 +/- ##
============================================
+ Coverage 62.85% 62.86% +0.01%
+ Complexity 18375 18373 -2
============================================
Files 1151 1151
Lines 69067 69091 +24
Branches 1260 1260
============================================
+ Hits 43412 43434 +22
- Misses 25286 25288 +2
Partials 369 369
Continue to review full report at Codecov.
|
Backport PR: #31266 |
c85685c
to
0e34e6c
Compare
Add emitters for user preferences and unit tests Co-authored-by: Sujith H <sharidasan@owncloud.com> Signed-off-by: Vincent Petry <pvince81@owncloud.com> Signed-off-by: Sujith H <sharidasan@owncloud.com>
0e34e6c
to
3476362
Compare
*/ | ||
public function deleteAllUserValues($userId) { | ||
// TODO - FIXME | ||
$this->fixDIInit(); | ||
|
||
$arguments = ['uid' => $userId]; | ||
$this->eventDispatcher->dispatch('userpreferences.beforeDeleteUser', new GenericEvent(null, $arguments)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one day we need to use query builder everywhere .....
protected function getConfig($systemConfig = null, $connection = null) { | ||
$this->eventDispatcher = new EventDispatcher(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have a used a mock here .... no need to run all the event dispatcher logic
and there is one space too much ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's easier to use the real object instead of mocking all its methods (I tried to mock this one in another PR and gave up). To note is that we use a standalone dispatcher and not the real \OC::$server->getEventDispatcher()
because that would register and trigger events for the whole system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one method needs to me mocked and the assertion code is much less - see below
@@ -60,8 +67,45 @@ public function testSetUserValue() { | |||
$selectAllSQL = 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?'; | |||
$config = $this->getConfig(); | |||
|
|||
$calledBeforeUserPrefSetVal = []; | |||
$this->eventDispatcher->addListener('userpreferences.beforeSetValue', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should read much easier using a mock
$this->eventDispatcher->expects($this->once())->method('dispatch')->with('userpreferences.beforeDeleteApp', new GenericEvent(null, [....]))
@sharidas when backporting or forward porting please make sure it is clear. When reading this PR it looks like this is the original PR but it isn't. The original PR is the stable10 one and this one here is a forward port. And now you're getting review change requests for something that is just a port. |
@DeepDiver1975 considering that this is a master port (wasn't clear from the first post), I'd rather keep the code as is. If you think this code must absolutely be changed then we shall do so in a separate PR that we will backport again to stable10. |
Sorry for the confusion created. This PR is a forward port from #31266 ( which is merged ). |
The challenge with forward-ports is that extra CI in |
@phil-davis ok that makes sense. The original stable10 PR was created on said branch to save some time back then in case it was needed quickly. You pointed out good reasons to continue starting with master first. |
yes - agreed
I'd really like this to be changed @sharidas please have a look if time permits and @PVince81 agrees as well |
this is the prime rule for many years - whenever we broke this rule - code broke as well. |
@sharidas has the requested changes ready, please push to a separate master PR which we will backport after review. Thanks |
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. |
Description
Add events for user preference changes
Related Issue
Fixes #31264
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: