-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Move Interface Definitions to the ServerContainer #3901
Conversation
@rullzer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @BernhardPosselt, @MorrisJobke and @nickvergessen to be potential reviewers. |
lib/private/ServerContainer.php
Outdated
@@ -79,7 +79,7 @@ public function query($name) { | |||
$segments = explode('\\', $name); | |||
$appContainer = $this->getAppContainer(strtolower($segments[1])); | |||
try { | |||
return $appContainer->query($name); | |||
return $appContainer->query($name, false); |
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.
Why is the false here needed? Shouldn't it try the server container from the app container and done?
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.
To avoid possible endless loops. Like if you request a non existing class.
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.
Is there a way to maybe fix this by overriding the method in the server container instead?
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 is in the servercontainer. The thing is that once we call the query method of the servercontainer we don't know which container called that.
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.
ok, lol my bad :D
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.
Ah right, i mean the method above which is defined in the DIContainer
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.
Ah got it, the inerhitance hierarchy is borked. The DIContainer is the base container for apps, however the server container also uses it.
Then I'd say simply subclass it and replace it here: https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/App.php#L68
So 1 thing I did think of is: Assume that in the server there is a registeredService Now if an app Mmmm. let me set this back to develop to think some more. |
I'll see if I can come up with some tests to check the behavior we want. Should make discussing a bit easier. |
lib/private/ServerContainer.php
Outdated
@@ -79,7 +79,7 @@ public function query($name) { | |||
$segments = explode('\\', $name); | |||
$appContainer = $this->getAppContainer(strtolower($segments[1])); | |||
try { | |||
return $appContainer->query($name); | |||
return $appContainer->query($name, false); |
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.
ok, lol my bad :D
lib/private/ServerContainer.php
Outdated
@@ -79,7 +79,7 @@ public function query($name) { | |||
$segments = explode('\\', $name); | |||
$appContainer = $this->getAppContainer(strtolower($segments[1])); | |||
try { | |||
return $appContainer->query($name); | |||
return $appContainer->query($name, false); |
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.
Ah right, i mean the method above which is defined in the DIContainer
lib/private/ServerContainer.php
Outdated
@@ -79,7 +79,7 @@ public function query($name) { | |||
$segments = explode('\\', $name); | |||
$appContainer = $this->getAppContainer(strtolower($segments[1])); | |||
try { | |||
return $appContainer->query($name); | |||
return $appContainer->query($name, false); |
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.
Ah got it, the inerhitance hierarchy is borked. The DIContainer is the base container for apps, however the server container also uses it.
Then I'd say simply subclass it and replace it here: https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/App.php#L68
try { | ||
return parent::query($name); | ||
} catch (QueryException $e) { | ||
if ($checkServerContainer === false) { |
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.
if (strpos(OC\App::buildAppNamespace($this->query('AppName')), $name) !== 0) {
return $this->getServer()->query($name);
}
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 forwards the request to the server container if the classes lie somewhere else. If you swap out interfaces from the server in your own container it wont hit the server container since you don't hit the catch block
try { | ||
return parent::query($name); | ||
} catch (QueryException $e) { | ||
if ($checkServerContainer === false) { |
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 forwards the request to the server container if the classes lie somewhere else. If you swap out interfaces from the server in your own container it wont hit the server container since you don't hit the catch block
Codecov Report
@@ Coverage Diff @@
## master #3901 +/- ##
============================================
- Coverage 54.28% 54.27% -0.02%
- Complexity 21147 21156 +9
============================================
Files 1304 1304
Lines 80805 80793 -12
Branches 1282 1282
============================================
- Hits 43867 43852 -15
- Misses 36938 36941 +3
Continue to review full report at Codecov.
|
.htaccess
Outdated
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE #### | ||
|
||
ErrorDocument 403 /core/templates/403.php | ||
ErrorDocument 404 /core/templates/404.php |
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.
😱
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.
yeah yeah fixed. It just still sucks that I can't just do a git commit -a
because I ran the testsuite.
lib/private/Server.php
Outdated
@@ -477,7 +494,7 @@ public function __construct($webRoot, \OC\Config $config) { | |||
$this->registerService('CredentialsManager', function (Server $c) { | |||
return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); | |||
}); | |||
$this->registerService('DatabaseConnection', function (Server $c) { | |||
$this->registerService(IDBConnection::class, function (Server $c) { |
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.
Needs adjustments in the unit tests as well
Line 141 in b62b82c
\OC::$server->registerService('DatabaseConnection', function () { |
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.
PS its multiple times.
6c92710
to
38068ed
Compare
Looks good I think 👍 |
@rullzer Could you have a look why that many integration tests fail? |
@MorrisJobke yes on it. It is because doing it half isn't going to work ;) |
To align with #2043 (comment) This would mean that AppContainers only hold the AppSpecific services Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
* Moved some interface definitions to Server.php (more to come) * Build/Query only for existing classes in the AppContainer * Build/Query only for classes of the App in the AppContainer * Offload other stuff to the servercontainer Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
Signed-off-by: Roeland Jago Douma <[email protected]>
💥 causes infinite recursion in DI for me 💥 |
Seems to be caused by apps where there namespace is not equal to their app id ( |
@icewind1991 mmm fuck. yeah of course that could happen. Let me fix a PR for that. I think we have a way around it. |
As stated in #3901 (comment) appid's don't have to match the namespace. Work around this Signed-off-by: Roeland Jago Douma <[email protected]>
Followup of #3897
Implementation of #2043 (comment)
This should allow us to the interface defintions to the servercontainer. So we don't duplicate everything for each App.