Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-03-26 00:45:05 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-03-26 00:45:05 +0400
commit70cd91b23791a2cb25accd9f21f15099fb1be24e (patch)
tree5998c1135bae43d843b57bd72111493de9d1e7b0
parent4c810a92e683ce1505e9fe55188ef769bde8871d (diff)
refs #4903 added cli command to trigger archiving
-rw-r--r--core/CronArchive.php2
-rw-r--r--plugins/CoreConsole/Commands/CoreArchiver.php56
-rw-r--r--plugins/CoreConsole/CoreConsole.php1
3 files changed, 58 insertions, 1 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php
index f14545ee01..24f1acad87 100644
--- a/core/CronArchive.php
+++ b/core/CronArchive.php
@@ -1150,7 +1150,7 @@ Notes:
private function logFatalErrorUrlExpected()
{
- $this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ "
+ $this->logFatalError("archive.php expects the argument 'url' to be set to your Piwik URL, for example: url=http://example.org/piwik/ "
. "\n--help for more information", $backtrace = false);
}
diff --git a/plugins/CoreConsole/Commands/CoreArchiver.php b/plugins/CoreConsole/Commands/CoreArchiver.php
new file mode 100644
index 0000000000..a60da70f3a
--- /dev/null
+++ b/plugins/CoreConsole/Commands/CoreArchiver.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+namespace Piwik\Plugins\CoreConsole\Commands;
+
+use Piwik\CliMulti;
+use Piwik\CronArchive;
+use Piwik\Plugin\ConsoleCommand;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class CoreArchiver extends ConsoleCommand
+{
+ protected function configure()
+ {
+ $this->setName('core:archive');
+ $this->setDescription('Runs the CLI archiver');
+ $this->addArgument('config', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Any parameters supported by the CronArchiver. Eg ./console core:archive url=http://example.org/piwik', array());
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->initEnv();
+
+ $archiving = new CronArchive();
+ try {
+ $archiving->init();
+ $archiving->run();
+ $archiving->runScheduledTasks();
+ $archiving->end();
+ } catch (\Exception $e) {
+ $archiving->logFatalError($e->getMessage());
+ }
+ }
+
+ private function initEnv()
+ {
+ if (!defined('PIWIK_ENABLE_ERROR_HANDLER')) {
+ define('PIWIK_ENABLE_ERROR_HANDLER', false);
+ }
+
+ if (!defined('PIWIK_ENABLE_SESSION_START')) {
+ define('PIWIK_ENABLE_SESSION_START', false);
+ }
+
+ if (!defined('PIWIK_ENABLE_DISPATCH')) {
+ define('PIWIK_ENABLE_DISPATCH', false);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/CoreConsole/CoreConsole.php b/plugins/CoreConsole/CoreConsole.php
index 1644c5fe93..c821359328 100644
--- a/plugins/CoreConsole/CoreConsole.php
+++ b/plugins/CoreConsole/CoreConsole.php
@@ -25,6 +25,7 @@ class CoreConsole extends \Piwik\Plugin
public function addConsoleCommands(&$commands)
{
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\CodeCoverage';
+ $commands[] = 'Piwik\Plugins\CoreConsole\Commands\CoreArchiver';
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\GenerateApi';
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\GenerateController';
$commands[] = 'Piwik\Plugins\CoreConsole\Commands\GeneratePlugin';