aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 12:03:28 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-03 12:03:28 +0200
commitf8c04a4219ec5118b138b4a4676a59258b5402b7 (patch)
tree0c3872181672ed5c69c1520f5ce6d9fafff3a355
parent15a479fb9670e4695f8f23a6b9cc089a0c7c08a1 (diff)
parentcc1d948c2e9ca7be49a22358336f7a00f102d19a (diff)
downloadnextcloud-server-f8c04a4219ec5118b138b4a4676a59258b5402b7.tar.gz
nextcloud-server-f8c04a4219ec5118b138b4a4676a59258b5402b7.zip
Merge pull request #24392 from owncloud/declare-cron-jobs-in-info.xml
Declare cron jobs in info.xml
-rw-r--r--apps/dav/appinfo/application.php5
-rw-r--r--apps/dav/appinfo/info.xml3
-rw-r--r--apps/dav/appinfo/install.php1
-rw-r--r--apps/dav/appinfo/update.php1
-rw-r--r--lib/private/App/InfoParser.php11
-rw-r--r--lib/private/Installer.php3
-rw-r--r--lib/private/legacy/app.php8
-rw-r--r--tests/data/app/expected-info.json3
8 files changed, 23 insertions, 12 deletions
diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php
index c3811a40845..328f86c877f 100644
--- a/apps/dav/appinfo/application.php
+++ b/apps/dav/appinfo/application.php
@@ -153,11 +153,6 @@ class Application extends App {
return $this->getContainer()->query('SyncService');
}
- public function setupCron() {
- $jl = $this->getContainer()->getServer()->getJobList();
- $jl->add(new SyncJob());
- }
-
public function generateBirthdays() {
try {
/** @var BirthdayService $migration */
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index bb447c9a426..e2688e2f923 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -16,4 +16,7 @@
<dependencies>
<owncloud min-version="9.1" max-version="9.1" />
</dependencies>
+ <background-jobs>
+ <job>OCA\DAV\CardDAV\Sync\SyncJob</job>
+ </background-jobs>
</info>
diff --git a/apps/dav/appinfo/install.php b/apps/dav/appinfo/install.php
index fbd41d25f49..dbb23022b38 100644
--- a/apps/dav/appinfo/install.php
+++ b/apps/dav/appinfo/install.php
@@ -22,5 +22,4 @@
use OCA\Dav\AppInfo\Application;
$app = new Application();
-$app->setupCron();
$app->generateBirthdays();
diff --git a/apps/dav/appinfo/update.php b/apps/dav/appinfo/update.php
index fbd41d25f49..dbb23022b38 100644
--- a/apps/dav/appinfo/update.php
+++ b/apps/dav/appinfo/update.php
@@ -22,5 +22,4 @@
use OCA\Dav\AppInfo\Application;
$app = new Application();
-$app->setupCron();
$app->generateBirthdays();
diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php
index 21422d40603..e9456550206 100644
--- a/lib/private/App/InfoParser.php
+++ b/lib/private/App/InfoParser.php
@@ -89,6 +89,9 @@ class InfoParser {
if (!array_key_exists('uninstall', $array['repair-steps'])) {
$array['repair-steps']['uninstall'] = [];
}
+ if (!array_key_exists('background-jobs', $array)) {
+ $array['background-jobs'] = [];
+ }
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
foreach ($array['documentation'] as $key => $url) {
@@ -128,6 +131,9 @@ class InfoParser {
if (isset($array['repair-steps']['uninstall']['step']) && is_array($array['repair-steps']['uninstall']['step'])) {
$array['repair-steps']['uninstall'] = $array['repair-steps']['uninstall']['step'];
}
+ if (isset($array['background-jobs']['job']) && is_array($array['background-jobs']['job'])) {
+ $array['background-jobs'] = $array['background-jobs']['job'];
+ }
return $array;
}
@@ -147,10 +153,7 @@ class InfoParser {
if (!isset($array[$element])) {
$array[$element] = "";
}
- /**
- * @var \SimpleXMLElement $node
- */
-
+ /** @var \SimpleXMLElement $node */
// Has attributes
if ($attributes = $node->attributes()) {
$data = [
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index 8ecc92e134b..edc6306b8f1 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -133,6 +133,8 @@ class Installer {
}
}
+ \OC_App::setupBackgroundJobs($info['background-jobs']);
+
//run appinfo/install.php
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
self::includeAppScript($basedir . '/appinfo/install.php');
@@ -569,6 +571,7 @@ class Installer {
if (is_null($info)) {
return false;
}
+ \OC_App::setupBackgroundJobs($info['background-jobs']);
OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index fe590e4159e..dab4c1a70c7 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -1190,6 +1190,7 @@ class OC_App {
self::loadApp($appId, false);
include $appPath . '/appinfo/update.php';
}
+ self::setupBackgroundJobs($appData['background-jobs']);
//set remote/public handlers
if (array_key_exists('ocsid', $appData)) {
@@ -1240,6 +1241,13 @@ class OC_App {
$r->run();
}
+ public static function setupBackgroundJobs(array $jobs) {
+ $queue = \OC::$server->getJobList();
+ foreach ($jobs as $job) {
+ $queue->add($job);
+ }
+ }
+
/**
* @param string $appId
* @param string[] $steps
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json
index cef7a7fdaba..81de5341efa 100644
--- a/tests/data/app/expected-info.json
+++ b/tests/data/app/expected-info.json
@@ -74,5 +74,6 @@
"post-migration": [],
"live-migration": [],
"uninstall": []
- }
+ },
+ "background-jobs": []
}