-
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
Implement AppManager::getAppPath #29871
Conversation
42c6a97
to
44b9f2a
Compare
lib/private/App/AppManager.php
Outdated
} | ||
|
||
/** | ||
* Get the directory for the given app. |
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.
Method description needs an update. (copy-pasted from method above but not yet modified)
24bccd0
to
1da9920
Compare
Codecov Report
@@ Coverage Diff @@
## master #29871 +/- ##
============================================
- Coverage 58.21% 58.19% -0.03%
+ Complexity 18512 18458 -54
============================================
Files 1093 1092 -1
Lines 63693 63619 -74
============================================
- Hits 37082 37025 -57
+ Misses 26611 26594 -17
Continue to review full report at Codecov.
|
1da9920
to
7532b0d
Compare
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.
👍 looks good to me.
Feel free to ignore the comments if they apply on old code you just moved to another location. If you do fix them, let's make sure there is no risk of regression.
lib/private/App/AppManager.php
Outdated
if (trim($appId) === '') { | ||
return false; | ||
} | ||
if (($appRoot = $this->findAppInDirectories($appId)) != 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.
!== false
?
same below
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.
feel free to leave it if it's just copy-pasted bad old code
lib/private/App/AppManager.php
Outdated
* @param string $appId | ||
* @return false|string[] | ||
*/ | ||
protected function findAppInDirectories($appId) { |
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.
double space between protected
and function
$versionToLoad = []; | ||
foreach ($possibleAppRoots as $possibleAppRoot) { | ||
$version = $this->getAppVersionByPath($possibleAppRoot['path'] . '/' . $appId); | ||
if (empty($versionToLoad) || version_compare($version, $versionToLoad['version'], '>')) { |
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.
empty()
, fortunately we don't have a version "0" which would qualify as true for empty("0")
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.
OMG! an evil app-developer can write an app that will never be loaded :)
Just kidding. this piece of sh code chooses the most recent app version from the appRoots.
$versionToLoad
is an array containing properties ['path', 'url', 'version'] of the winner so empty
is valid in this context.
empty($versionToLoad)
means there is no winner currently.
7532b0d
to
ccd4f5a
Compare
@PVince81 I changed comparison to be strict and removed double space. |
lib/public/App/IAppManager.php
Outdated
@@ -166,4 +166,26 @@ public function readAppPackage($path); | |||
* @since 10.0.3 | |||
*/ | |||
public function canInstall(); | |||
|
|||
/** | |||
* Get the directory for the given app. |
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.
mind adding a detail whether this is an absolute path or relative path (and relative to what)
* @return string|false | ||
* @since 10.0.5 | ||
*/ | ||
public function getAppWebPath($appId); |
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.
what's a web path ? maybe an example in PHPDoc will help clarify
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.
Please check the two clarifications (optional)
@PVince81 thanks, will do //Just for my reference as both comments are related to |
ccd4f5a
to
131e688
Compare
@PVince81 PHPDocs updated |
tests were green before, only PHP Doc changes, insta-merge |
@VicDeo please backport to stable10 |
Stable10: #30041 |
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
OC_App::getAppPath
andOC_App::getAppWebPath
are cut down to work via AppManager implementationRelated Issue
#25336
Motivation and Context
How Has This Been Tested?
\OC::$server->getAppManager()->getAppPath('customgroups');
\OC::$server->getAppManager()->getAppWebPath('customgroups');
where 'customgroups' is your favorite app. In a various configs including multiple app directories.
Types of changes
Checklist: