Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
c6e47db5
Unverified
Commit
c6e47db5
authored
Oct 07, 2016
by
Thomas Müller
Browse files
App dependencies are now analysed on app enable as well - not only on app install.
parent
5cc4496f
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/private/App/DependencyAnalyzer.php
View file @
c6e47db5
...
...
@@ -223,6 +223,9 @@ class DependencyAnalyzer {
if
(
!
is_array
(
$libs
))
{
$libs
=
[
$libs
];
}
if
(
isset
(
$libs
[
'@value'
]))
{
$libs
=
[
$libs
];
}
foreach
(
$libs
as
$lib
)
{
$libName
=
$this
->
getValue
(
$lib
);
$libVersion
=
$this
->
platform
->
getLibraryVersion
(
$libName
);
...
...
lib/private/legacy/app.php
View file @
c6e47db5
...
...
@@ -329,6 +329,13 @@ class OC_App {
self
::
$enabledAppsCache
=
[];
// flush
if
(
!
Installer
::
isInstalled
(
$app
))
{
$app
=
self
::
installApp
(
$app
);
}
else
{
// check for required dependencies
$config
=
\
OC
::
$server
->
getConfig
();
$l
=
\
OC
::
$server
->
getL10N
(
'core'
);
$info
=
self
::
getAppInfo
(
$app
);
self
::
checkAppDependencies
(
$config
,
$l
,
$info
);
}
$appManager
=
\
OC
::
$server
->
getAppManager
();
...
...
@@ -1171,16 +1178,7 @@ class OC_App {
}
// check for required dependencies
$dependencyAnalyzer
=
new
DependencyAnalyzer
(
new
Platform
(
$config
),
$l
);
$missing
=
$dependencyAnalyzer
->
analyze
(
$info
);
if
(
!
empty
(
$missing
))
{
$missingMsg
=
join
(
PHP_EOL
,
$missing
);
throw
new
\
Exception
(
$l
->
t
(
'App "%s" cannot be installed because the following dependencies are not fulfilled: %s'
,
[
$info
[
'name'
],
$missingMsg
]
)
);
}
self
::
checkAppDependencies
(
$config
,
$l
,
$info
);
$config
->
setAppValue
(
$app
,
'enabled'
,
'yes'
);
if
(
isset
(
$appData
[
'id'
]))
{
...
...
@@ -1351,4 +1349,23 @@ class OC_App {
return
$data
;
}
/**
* @param $config
* @param $l
* @param $info
* @throws Exception
*/
protected
static
function
checkAppDependencies
(
$config
,
$l
,
$info
)
{
$dependencyAnalyzer
=
new
DependencyAnalyzer
(
new
Platform
(
$config
),
$l
);
$missing
=
$dependencyAnalyzer
->
analyze
(
$info
);
if
(
!
empty
(
$missing
))
{
$missingMsg
=
join
(
PHP_EOL
,
$missing
);
throw
new
\
Exception
(
$l
->
t
(
'App "%s" cannot be installed because the following dependencies are not fulfilled: %s'
,
[
$info
[
'name'
],
$missingMsg
]
)
);
}
}
}
tests/lib/App/DependencyAnalyzerTest.php
View file @
c6e47db5
...
...
@@ -9,7 +9,7 @@
namespace
Test\App
;
use
OC
;
use
OC
\App\DependencyAnalyzer
;
use
OC\App\Platform
;
use
OCP\IL10N
;
use
Test\TestCase
;
...
...
@@ -22,11 +22,11 @@ class DependencyAnalyzerTest extends TestCase {
/** @var IL10N */
private
$l10nMock
;
/** @var
\OC\App\
DependencyAnalyzer */
/** @var DependencyAnalyzer */
private
$analyser
;
public
function
setUp
()
{
$this
->
platformMock
=
$this
->
getMockBuilder
(
'\OC\App\
Platform
'
)
$this
->
platformMock
=
$this
->
getMockBuilder
(
Platform
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
platformMock
->
expects
(
$this
->
any
())
...
...
@@ -67,7 +67,7 @@ class DependencyAnalyzerTest extends TestCase {
return
vsprintf
(
$text
,
$parameters
);
}));
$this
->
analyser
=
new
\
OC\App\
DependencyAnalyzer
(
$this
->
platformMock
,
$this
->
l10nMock
);
$this
->
analyser
=
new
DependencyAnalyzer
(
$this
->
platformMock
,
$this
->
l10nMock
);
}
/**
...
...
@@ -101,6 +101,8 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @dataProvider providesDatabases
* @param $expectedMissing
* @param $databases
*/
public
function
testDatabases
(
$expectedMissing
,
$databases
)
{
$app
=
[
...
...
@@ -247,6 +249,8 @@ class DependencyAnalyzerTest extends TestCase {
[[
'@attributes'
=>
[
'min-version'
=>
'2.3'
,
'max-version'
=>
'2.3'
],
'@value'
=>
'curl'
]]],
[[],
[[
'@attributes'
=>
[
'min-version'
=>
'2'
,
'max-version'
=>
'2'
],
'@value'
=>
'curl'
]]],
[[],
[
'@attributes'
=>
[
'min-version'
=>
'2'
,
'max-version'
=>
'2'
],
'@value'
=>
'curl'
]],
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment