summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-19 12:19:39 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-22 08:38:41 +0200
commitd0030aad6cb108bbf4ca729d0e11f3438145aba9 (patch)
treeb67c516648a5aaced4598e889c93f85db3adb957
parentded84bf571dd51798904823405f673e16ca5eff4 (diff)
downloadnextcloud-server-d0030aad6cb108bbf4ca729d0e11f3438145aba9.tar.gz
nextcloud-server-d0030aad6cb108bbf4ca729d0e11f3438145aba9.zip
Remove deprecated HTTPHelper from InfoParser
-rw-r--r--core/register_command.php2
-rw-r--r--lib/private/App/InfoParser.php34
-rw-r--r--lib/private/app.php2
-rw-r--r--tests/data/app/expected-info.json4
-rw-r--r--tests/lib/app/codechecker/infocheckertest.php2
-rw-r--r--tests/lib/app/infoparser.php16
6 files changed, 33 insertions, 27 deletions
diff --git a/core/register_command.php b/core/register_command.php
index 90a54233e66..0b1a019f993 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -32,7 +32,7 @@
/** @var $application Symfony\Component\Console\Application */
$application->add(new OC\Core\Command\Status);
$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
-$infoParser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator());
+$infoParser = new \OC\App\InfoParser(\OC::$server->getURLGenerator());
$application->add(new OC\Core\Command\App\CheckCode($infoParser));
$application->add(new OC\Core\Command\L10n\CreateJs());
$application->add(new \OC\Core\Command\Integrity\SignApp(
diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php
index c33e5349f3b..1616bf6a02b 100644
--- a/lib/private/App/InfoParser.php
+++ b/lib/private/App/InfoParser.php
@@ -27,22 +27,14 @@ namespace OC\App;
use OCP\IURLGenerator;
class InfoParser {
- /**
- * @var \OC\HTTPHelper
- */
- private $httpHelper;
- /**
- * @var IURLGenerator
- */
+ /** @var IURLGenerator */
private $urlGenerator;
/**
- * @param \OC\HTTPHelper $httpHelper
* @param IURLGenerator $urlGenerator
*/
- public function __construct(\OC\HTTPHelper $httpHelper, IURLGenerator $urlGenerator) {
- $this->httpHelper = $httpHelper;
+ public function __construct(IURLGenerator $urlGenerator) {
$this->urlGenerator = $urlGenerator;
}
@@ -79,12 +71,21 @@ class InfoParser {
if (!array_key_exists('types', $array)) {
$array['types'] = array();
}
+ if (!array_key_exists('repair-steps', $array)) {
+ $array['repair-steps'] = array();
+ }
+ if (!array_key_exists('pre-migration', $array['repair-steps'])) {
+ $array['repair-steps']['pre-migration'] = array();
+ }
+ if (!array_key_exists('post-migration', $array['repair-steps'])) {
+ $array['repair-steps']['post-migration'] = array();
+ }
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
foreach ($array['documentation'] as $key => $url) {
// If it is not an absolute URL we assume it is a key
// i.e. admin-ldap will get converted to go.php?to=admin-ldap
- if (!$this->httpHelper->isHTTPURL($url)) {
+ if (!$this->isHTTPURL($url)) {
$url = $this->urlGenerator->linkToDocs($url);
}
@@ -103,7 +104,12 @@ class InfoParser {
$array['types'] = array();
}
}
-
+ if (isset($array['repair-steps']['pre-migration']['step']) && is_array($array['repair-steps']['pre-migration']['step'])) {
+ $array['repair-steps']['pre-migration'] = $array['repair-steps']['pre-migration']['step'];
+ }
+ if (isset($array['repair-steps']['post-migration']['step']) && is_array($array['repair-steps']['post-migration']['step'])) {
+ $array['repair-steps']['post-migration'] = $array['repair-steps']['post-migration']['step'];
+ }
return $array;
}
@@ -161,4 +167,8 @@ class InfoParser {
return $array;
}
+
+ private function isHTTPURL($url) {
+ return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0;
+ }
}
diff --git a/lib/private/app.php b/lib/private/app.php
index 8a8b97d2cd4..cf0ccbb2272 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -626,7 +626,7 @@ class OC_App {
$file = $appPath . '/appinfo/info.xml';
}
- $parser = new \OC\App\InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator());
+ $parser = new \OC\App\InfoParser(\OC::$server->getURLGenerator());
$data = $parser->parse($file);
if (is_array($data)) {
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json
index d86ffed482b..e05d02f7641 100644
--- a/tests/data/app/expected-info.json
+++ b/tests/data/app/expected-info.json
@@ -67,5 +67,9 @@
"max-version": "8"
}
}
+ },
+ "repair-steps": {
+ "pre-migration": [],
+ "post-migration": []
}
}
diff --git a/tests/lib/app/codechecker/infocheckertest.php b/tests/lib/app/codechecker/infocheckertest.php
index b31c5fe3a7a..c6df5a715a1 100644
--- a/tests/lib/app/codechecker/infocheckertest.php
+++ b/tests/lib/app/codechecker/infocheckertest.php
@@ -43,7 +43,7 @@ class InfoCheckerTest extends TestCase {
protected function setUp() {
parent::setUp();
- $infoParser = new InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator());
+ $infoParser = new InfoParser(\OC::$server->getURLGenerator());
$this->infoChecker = new InfoChecker($infoParser);
}
diff --git a/tests/lib/app/infoparser.php b/tests/lib/app/infoparser.php
index 1e5257abec3..cb89dd0131c 100644
--- a/tests/lib/app/infoparser.php
+++ b/tests/lib/app/infoparser.php
@@ -10,35 +10,27 @@
namespace Test\App;
use OC;
+use OCP\IURLGenerator;
use Test\TestCase;
class InfoParser extends TestCase {
- /**
- * @var \OC\App\InfoParser
- */
+ /** @var \OC\App\InfoParser */
private $parser;
public function setUp() {
- $config = $this->getMockBuilder('\OCP\IConfig')
- ->disableOriginalConstructor()->getMock();
- $clientService = $this->getMock('\OCP\Http\Client\IClientService');
- $httpHelper = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs([$config, $clientService])
- ->setMethods(['getHeaders'])
- ->getMock();
$urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
->disableOriginalConstructor()
->getMock();
- //linkToDocs
+ /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject $urlGenerator */
$urlGenerator->expects($this->any())
->method('linkToDocs')
->will($this->returnCallback(function ($url) {
return "https://docs.example.com/server/go.php?to=$url";
}));
- $this->parser = new \OC\App\InfoParser($httpHelper, $urlGenerator);
+ $this->parser = new \OC\App\InfoParser($urlGenerator);
}
/**