diff --git a/lib/Alchemy/Phrasea/Application/Admin.php b/lib/Alchemy/Phrasea/Application/Admin.php
index b71d1de72e..a1d0fded99 100644
--- a/lib/Alchemy/Phrasea/Application/Admin.php
+++ b/lib/Alchemy/Phrasea/Application/Admin.php
@@ -27,6 +27,7 @@ use Alchemy\Phrasea\Controller\Admin\Subdefs;
use Alchemy\Phrasea\Controller\Admin\Users;
use Alchemy\Phrasea\Controller\Admin\Tasks;
use Alchemy\Phrasea\Controller\Admin\Task;
+use Alchemy\Phrasea\Controller\Admin\TaskManager;
use Alchemy\Phrasea\Controller\Admin\Scheduler;
use Alchemy\Phrasea\Controller\Utils\ConnectionTest;
use Alchemy\Phrasea\Controller\Utils\PathFileTest;
@@ -44,9 +45,11 @@ return call_user_func(
$app->mount('/sphinx', new Sphinx());
$app->mount('/connected-users', new ConnectedUsers());
- $app->mount('/tasks', new Tasks());
- $app->mount('/task', new Task());
- $app->mount('/scheduler', new Scheduler());
+ $app->mount('/task-manager', new TaskManager());
+
+// $app->mount('/tasks', new Tasks());
+// $app->mount('/task', new Task());
+// $app->mount('/scheduler', new Scheduler());
$app->mount('/publications', new Publications());
$app->mount('/users', new Users());
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Scheduler.php b/lib/Alchemy/Phrasea/Controller/Admin/Scheduler.php
deleted file mode 100644
index ad2031b095..0000000000
--- a/lib/Alchemy/Phrasea/Controller/Admin/Scheduler.php
+++ /dev/null
@@ -1,131 +0,0 @@
-get('/start', $this->call('startScheduler'));
-
- /*
- * route /admin/scheduler/stop
- */
- $controllers->get('/stop', function(Application $app, Request $request) use ($app, $appbox) {
- try {
- $task_manager = new \task_manager($appbox);
-
- $task_manager->setSchedulerState(\task_manager::STATE_TOSTOP);
-
- return $app->json(true);
- } catch (Exception $e) {
-
- }
-
- return $app->json(false);
- });
-/*
- $controllers->before(function(Application $app) {
-
- // todo : check sceduler key
-
- $scheduler_key = \phrasea::scheduler_key();
-
-
-
- $user = $app['phraseanet.core']->getAuthenticatedUser();
- if ( ! $user || ! $user->ACL()->has_right('task_manager')) {
- throw new AccessDeniedHttpException('User can not access task manager');
- }
- });
-*/
- return $controllers;
- }
-
- public function startScheduler(Application $app, Request $request)
- {
-
- set_time_limit(0);
- session_write_close();
- ignore_user_abort(true);
-
- $app['task-manager']->getSchedulerProcess()->run();
-
-// $nullfile = '/dev/null';
-//
-// if (defined('PHP_WINDOWS_VERSION_BUILD')) {
-// $nullfile = 'NUL';
-// }
-//
-// $phpcli = $registry->get('GV_cli');
-//
-// $cmd = $phpcli . ' -f ' . $registry->get('GV_RootPath') . "bin/console scheduler:start";
-//
-// $descriptors[1] = array("file", $nullfile, "a+");
-// $descriptors[2] = array("file", $nullfile, "a+");
-//
-// $pipes = null;
-// $cwd = $registry->get('GV_RootPath') . "bin/";
-// $proc = proc_open($cmd, $descriptors, $pipes, $cwd, null, array('bypass_shell' => true));
-//
-// $pid = NULL;
-// if (is_resource($proc)) {
-// $proc_status = proc_get_status($proc);
-// if ($proc_status['running'])
-// $pid = $proc_status['pid'];
-// }
-// if ($pid !== NULL) {
-// $msg = sprintf("scheduler '%s' started (pid=%s)", $cmd, $pid);
-// // my_syslog(LOG_INFO, $msg);
-// } else {
-// @fclose($pipes[1]);
-// @fclose($pipes[2]);
-// @proc_close($process);
-//
-// $msg = sprintf("scheduler '%s' failed to start", $cmd);
-// // my_syslog(LOG_INFO, $msg);
-// }
-
- return $app->json(true);
- }
-
- /**
- * Prefix the method to call with the controller class name
- *
- * @param string $method The method to call
- * @return string
- */
- private function call($method)
- {
- return sprintf('%s::%s', __CLASS__, $method);
- }
-}
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Task.php b/lib/Alchemy/Phrasea/Controller/Admin/Task.php
deleted file mode 100644
index 2194ca24f2..0000000000
--- a/lib/Alchemy/Phrasea/Controller/Admin/Task.php
+++ /dev/null
@@ -1,334 +0,0 @@
-_XMLErrMessage;
- }
-
- public function __construct($xml)
- {
- set_error_handler(array($this, "errorHandler"));
- $dom = new \DomDocument('1.0', 'UTF-8');
- @$dom->loadXML($xml);
- restore_error_handler();
- $this->message = "XML Parse Error";
- parent::__construct();
- }
-
- public function errorHandler($errno, $errstr, $errfile, $errline)
- {
-// var_dump($errno, $errstr, $errfile, $errline);
-// $pos = strpos($errstr,"]:") ;
-// if ($pos) {
-// $errstr = substr($errstr,$pos+ 2);
-// }
- $this->_XMLErrMessage = $errstr;
- }
-}
-
-/**
- *
- * @license http://opensource.org/licenses/gpl-3.0 GPLv3
- * @link www.phraseanet.com
- */
-class Task implements ControllerProviderInterface
-{
-
- public function connect(Application $app)
- {
-
- $controllers = $app['controllers_factory'];
-
- /*
- * route /admin/task/{id}/log
- * show logs of a task
- */
- $controllers->get('/{id}/log', function(Application $app, Request $request, $id) {
- $appbox = \appbox::get_instance($app['phraseanet.core']);
- $registry = $appbox->get_registry();
- $logdir = \p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
-
- $rname = '/task_' . $id . '((\.log)|(-.*\.log))$/';
-
- $finder = new Finder();
- $finder
- ->files()->name($rname)
- ->in($logdir)
- // ->date('> now - 1 days')
- ->sortByModifiedTime();
-
- $found = false;
- foreach ($finder->getIterator() as $file) {
- // printf("%s
\n", ($file->getRealPath()));
- if ($request->get('clr') == $file->getFilename()) {
- file_put_contents($file->getRealPath(), '');
- $found = true;
- }
- }
- if ($found) {
- return $app->redirect(sprintf("/admin/task/%s/log", urlencode($id)));
- }
-
- return $app->stream(
- function() use ($finder, $id) {
- foreach ($finder->getIterator() as $file) {
- printf("
\n"); - print(htmlentities(file_get_contents($file->getRealPath()))); - print("\n"); - - ob_flush(); - flush(); - } - }); - }); - - /* - * route /admin/task/{id}/delete - * delete a task - */ - $controllers->get('/{id}/delete', function(Application $app, Request $request, $id) { -// $appbox = \appbox::get_instance($app['phraseanet.core']); -// $task_manager = new \task_manager($appbox); - - try { - $task = $app['task-manager']->getTask($id); - $task->delete(); - - return $app->redirect('/admin/tasks/'); - } catch (\Exception $e) { - - /* - * todo : add a message back - */ - return $app->redirect('/admin/tasks/'); - } - }); - - /* - * route /admin/task/{id}/start - * set a task to 'tostart' - */ - $controllers->get('/{id}/tostart', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - - $ret = false; - try { - $task = $task_manager->getTask($id); - $pid = (int) ($task->getPID()); - if ( ! $pid) { - $task->setState(\task_abstract::STATE_TOSTART); - $ret = true; - } - } catch (Exception $e) { - - } - - return $app->json($ret); - }); - - /* - * route /admin/task/{id}/stop - * set a task to 'tostop' - */ - $controllers->get('/{id}/tostop', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - - $ret = false; - try { - $task = $task_manager->getTask($id); - $pid = $task->getPID(); - $signal = $request->get('signal'); - $task->setState(\task_abstract::STATE_TOSTOP); - - if ((int) $pid > 0 && (int) $signal > 0 && function_exists('posix_kill')) { - posix_kill((int) $pid, (int) $signal); - } - - $ret = true; - } catch (Exception $e) { - - } - - return $app->json($ret); - }); - - /* - * route /admin/task/{id}/resetcrashcounter - * return json - */ - $controllers->get('/{id}/resetcrashcounter/', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - - try { - $task = $task_manager->getTask($id); - - $task->resetCrashCounter(); - - return $app->json(true); - } catch (\Exception $e) { - - return $app->json(false); - } - }); - - /* - * route /admin/task/{id}/save - * return json - */ - $controllers->post('/{id}/save/', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->strictErrorChecking = true; - try { - if ( ! @$dom->loadXML($request->get('xml'))) { - throw new XMLParseErrorException($request->get('xml')); - } - - - } catch (XMLParseErrorException $e) { - return new Response( - $e->getXMLErrMessage(), - 412 // Precondition Failed - ); - } - - try { - $task = $task_manager->getTask($id); - - $task->setTitle($request->get('title')); - $task->setActive(\p4field::isyes($request->get('active'))); - $task->setSettings($request->get('xml')); - - return $app->json(true); - - } catch (\Exception $e) { - - return new Response( - 'Bad task ID', - 404 // Not Found - ); - } - - }); - - /* - * route /admin/task/{id}/facility/ - * call callback(s) of a task, for ex. to transform gui(form) to xml settings - */ - $controllers->post('/{id}/facility/', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - $ret = ''; - try { - $task = $task_manager->getTask($id); - } catch (\Exception $e) { - return new Response( - 'Bad task ID', - 404 // Not Found - ); - } - - switch ($request->get('__action')) { - case 'FORM2XML': - if (@simplexml_load_string($request->get('__xml'))) { - $ret = $task->graphic2xml($request->get('__xml')); - } else { - $ret = new Response( - 'Bad XML', - 412 // Precondition Failed - ); - } - break; - case null: - // no __action, so delegates to the task (call method "facility") - if(method_exists($task, 'facility')) - { - $ret = $task->facility(); - } - break; - default: - $ret = new Response( - 'Bad action', - 404 // Not Found - ); - break; - } - return $ret; - }); - - /* - * route /admin/task/{id} - * render a task editing interface - */ - $controllers->get('/{id}', function(Application $app, Request $request, $id) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - $task = $task_manager->getTask($id); - - /* @var $twig \Twig_Environment */ - $twig = $app['phraseanet.core']->getTwig(); - $template = 'admin/task.html.twig'; - return $twig->render($template, array( - 'task' => $task, - 'view' => 'XML' - )); - }); - - /* - * route /admin/task/checkxml/ - * check if the xml is valid - */ - $controllers->post('/checkxml/', function(Application $app, Request $request) { - $ret = array('ok' => true, 'err' => null); - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->strictErrorChecking = true; - try { - if ( ! @$dom->loadXML($request->get('xml'))) { - throw new XMLParseErrorException($request->get('xml')); - } - $ret = $app->json($ret); - } catch (XMLParseErrorException $e) { - $ret = new Response( - $e->getXMLErrMessage(), - 412 // Precondition Failed - ); - } - return $ret; - }); - - return $controllers; - } -} diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php new file mode 100644 index 0000000000..d99daee4d1 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -0,0 +1,512 @@ +get('/', function(Application $app, Request $request) { + + return $app->redirect('/admin/task-manager/tasks/'); + }); + + + + /* + * route /admin/task-manager/tasks/ + * tasks status in json + * or + * task manager page in html + */ + $controllers->get('/tasks/', function(Application $app, Request $request) { + $task_manager = new \task_manager($app['phraseanet.appbox']); + + if ($request->getContentType() == 'json') { + + return $app->json($task_manager->toArray()); + } else { + + $template = 'admin/tasks/list.html.twig'; + /* @var $twig \Twig_Environment */ + $twig = $app['phraseanet.core']->getTwig(); + + return $twig->render($template, array( + 'task_manager' => $task_manager, + 'scheduler_key' => \phrasea::scheduler_key() + )); + } + }); + + /** + * route /admin/task-manager/tasks/create + */ + $controllers->post('/tasks/create/', function(Application $app, Request $request) { + $appbox = $app['phraseanet.appbox']; + $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); + + $tcl = $request->get('tcl'); + if( $tcl ) + { + $task = \task_abstract::create($appbox, $tcl); + $tid = $task->getId(); + + return $app->redirect('/admin/task-manager/task/'.$tid); + // return $tid; + } + + return $app->redirect('/admin/task-manager/'); + }); + + + + + + + + + + + + + + + + /* + * route /admin/taskmanager/scheduler/start + */ + $controllers->get('/scheduler/start', $this->call('startScheduler')); + + /* + * route /admin/scheduler/stop + */ + $controllers->get('/scheduler/stop', function(Application $app, Request $request) use ($app) { + try { + $task_manager = new \task_manager($app['phraseanet.appbox']); + + $task_manager->setSchedulerState(\task_manager::STATE_TOSTOP); + + return $app->json(true); + } catch (Exception $e) { + + } + + return $app->json(false); + }); + + $controllers->get('/scheduler/log', function(Application $app, Request $request) { + $appbox = $app['phraseanet.appbox']; + $registry = $appbox->get_registry(); + $logdir = \p4string::addEndSlash($registry->get('GV_RootPath') . 'logs'); + + $rname = '/scheduler((\.log)|(-.*\.log))$/'; + + $finder = new Finder(); + $finder + ->files()->name($rname) + ->in($logdir) + // ->date('> now - 1 days') + ->sortByModifiedTime(); + + $found = false; + foreach ($finder->getIterator() as $file) { + // printf("%s
\n"); + print(htmlentities(file_get_contents($file->getRealPath()))); + print("\n"); + + ob_flush(); + flush(); + } + }); + }); + + + + + + + /* + $controllers->before(function(Application $app) { + + // todo : check sceduler key + + $scheduler_key = \phrasea::scheduler_key(); + + + + $user = $app['phraseanet.core']->getAuthenticatedUser(); + if ( ! $user || ! $user->ACL()->has_right('task_manager')) { + throw new AccessDeniedHttpException('User can not access task manager'); + } + }); +*/ + + + + + + + + + + + + + $controllers->get('/task/{id}/log', function(Application $app, Request $request, $id) { + $appbox = $app['phraseanet.appbox']; + $registry = $appbox->get_registry(); + $logdir = \p4string::addEndSlash($registry->get('GV_RootPath') . 'logs'); + + $rname = '/task_' . $id . '((\.log)|(-.*\.log))$/'; + + $finder = new Finder(); + $finder + ->files()->name($rname) + ->in($logdir) + // ->date('> now - 1 days') + ->sortByModifiedTime(); + + $found = false; + foreach ($finder->getIterator() as $file) { + // printf("%s
\n"); + print(htmlentities(file_get_contents($file->getRealPath()))); + print("\n"); + + ob_flush(); + flush(); + } + }); + }); + + /* + * route /admin/task-manager/task/{id}/delete + * delete a task + */ + $controllers->get('/task/{id}/delete', function(Application $app, Request $request, $id) { + + try { + $task = $app['task-manager']->getTask($id); + $task->delete(); + + return $app->redirect('/admin/task-manager/tasks/'); + } catch (\Exception $e) { + + /* + * todo : add a message back + */ + return $app->redirect('/admin/task-manager/tasks/'); + } + }); + + /* + * route /admin/task-manager/task/{id}/start + * set a task to 'tostart' + */ + $controllers->get('/task/{id}/tostart', function(Application $app, Request $request, $id) { + $task_manager = new \task_manager($app['phraseanet.appbox']); + + $ret = false; + try { + $task = $task_manager->getTask($id); + $pid = (int) ($task->getPID()); + if ( ! $pid) { + $task->setState(\task_abstract::STATE_TOSTART); + $ret = true; + } + } catch (Exception $e) { + + } + + return $app->json($ret); + }); + + /* + * route /admin/task-manager/task/{id}/stop + * set a task to 'tostop' + */ + $controllers->get('/task/{id}/tostop', function(Application $app, Request $request, $id) { + + $task_manager = new \task_manager($app['phraseanet.appbox']); + + $ret = false; + try { + $task = $task_manager->getTask($id); + $pid = $task->getPID(); + $signal = $request->get('signal'); + $task->setState(\task_abstract::STATE_TOSTOP); + + if ((int) $pid > 0 && (int) $signal > 0 && function_exists('posix_kill')) { + posix_kill((int) $pid, (int) $signal); + } + + $ret = true; + } catch (Exception $e) { + + } + + return $app->json($ret); + }); + + /* + * route /admin/task-manager/task/{id}/resetcrashcounter + * return json + */ + $controllers->get('/task/{id}/resetcrashcounter/', function(Application $app, Request $request, $id) { + $task_manager = new \task_manager($app['phraseanet.appbox']); + + try { + $task = $task_manager->getTask($id); + + $task->resetCrashCounter(); + + return $app->json(true); + } catch (\Exception $e) { + + return $app->json(false); + } + }); + + /* + * route /admin/task-manager/task/{id}/save + * return json + */ + $controllers->post('/task/{id}/save/', function(Application $app, Request $request, $id) { + + $task_manager = new \task_manager($app['phraseanet.appbox']); + + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->strictErrorChecking = true; + try { + if ( ! @$dom->loadXML($request->get('xml'))) { + throw new XMLParseErrorException($request->get('xml')); + } + } catch (XMLParseErrorException $e) { + return new Response( + $e->getXMLErrMessage(), + 412 // Precondition Failed + ); + } + + try { + $task = $task_manager->getTask($id); + + $task->setTitle($request->get('title')); + $task->setActive(\p4field::isyes($request->get('active'))); + $task->setSettings($request->get('xml')); + + return $app->json(true); + } catch (\Exception $e) { + + return new Response( + 'Bad task ID', + 404 // Not Found + ); + } + }); + + /* + * route /admin/task-manager/task/{id}/facility/ + * call callback(s) of a task, for ex. to transform gui(form) to xml settings + */ + $controllers->post('/task/{id}/facility/', function(Application $app, Request $request, $id) { + + $task_manager = new \task_manager($app['phraseanet.appbox']); + $ret = ''; + try { + $task = $task_manager->getTask($id); + } catch (\Exception $e) { + return new Response( + 'Bad task ID', + 404 // Not Found + ); + } + + switch ($request->get('__action')) { + case 'FORM2XML': + if (@simplexml_load_string($request->get('__xml'))) { + $ret = $task->graphic2xml($request->get('__xml')); + } else { + $ret = new Response( + 'Bad XML', + 412 // Precondition Failed + ); + } + break; + case null: + // no __action, so delegates to the task (call method "facility") + if (method_exists($task, 'facility')) { + $ret = $task->facility(); + } + break; + default: + $ret = new Response( + 'Bad action', + 404 // Not Found + ); + break; + } + return $ret; + }); + + /* + * route /admin/task-manager/task/{id} + * render a task editing interface + */ + $controllers->get('/task/{id}', function(Application $app, Request $request, $id) { + + $task_manager = new \task_manager($app['phraseanet.appbox']); + $task = $task_manager->getTask($id); + + /* @var $twig \Twig_Environment */ + $twig = $app['phraseanet.core']->getTwig(); + $template = 'admin/task.html.twig'; + return $twig->render($template, array( + 'task' => $task, + 'view' => 'XML' + )); + }); + + /* + * route /admin/task/checkxml/ + * check if the xml is valid + */ + $controllers->post('/task/checkxml/', function(Application $app, Request $request) { + $ret = array('ok' => true, 'err' => null); + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->strictErrorChecking = true; + try { + if ( ! @$dom->loadXML($request->get('xml'))) { + throw new XMLParseErrorException($request->get('xml')); + } + $ret = $app->json($ret); + } catch (XMLParseErrorException $e) { + $ret = new Response( + $e->getXMLErrMessage(), + 412 // Precondition Failed + ); + } + return $ret; + }); + + return $controllers; + } + + public function startScheduler(Application $app, Request $request) + { + + set_time_limit(0); + session_write_close(); + ignore_user_abort(true); + + $app['task-manager']->getSchedulerProcess()->run(); + +// $nullfile = '/dev/null'; +// +// if (defined('PHP_WINDOWS_VERSION_BUILD')) { +// $nullfile = 'NUL'; +// } +// +// $phpcli = $registry->get('GV_cli'); +// +// $cmd = $phpcli . ' -f ' . $registry->get('GV_RootPath') . "bin/console scheduler:start"; +// +// $descriptors[1] = array("file", $nullfile, "a+"); +// $descriptors[2] = array("file", $nullfile, "a+"); +// +// $pipes = null; +// $cwd = $registry->get('GV_RootPath') . "bin/"; +// $proc = proc_open($cmd, $descriptors, $pipes, $cwd, null, array('bypass_shell' => true)); +// +// $pid = NULL; +// if (is_resource($proc)) { +// $proc_status = proc_get_status($proc); +// if ($proc_status['running']) +// $pid = $proc_status['pid']; +// } +// if ($pid !== NULL) { +// $msg = sprintf("scheduler '%s' started (pid=%s)", $cmd, $pid); +// // my_syslog(LOG_INFO, $msg); +// } else { +// @fclose($pipes[1]); +// @fclose($pipes[2]); +// @proc_close($process); +// +// $msg = sprintf("scheduler '%s' failed to start", $cmd); +// // my_syslog(LOG_INFO, $msg); +// } + + return $app->json(true); + } + + /** + * Prefix the method to call with the controller class name + * + * @param string $method The method to call + * @return string + */ + private function call($method) + { + return sprintf('%s::%s', __CLASS__, $method); + } + + + + +} diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Tasks.php b/lib/Alchemy/Phrasea/Controller/Admin/Tasks.php deleted file mode 100644 index 8a858e3ade..0000000000 --- a/lib/Alchemy/Phrasea/Controller/Admin/Tasks.php +++ /dev/null @@ -1,80 +0,0 @@ -get('/', function(Application $app, Request $request) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $task_manager = new \task_manager($appbox); - - if ($request->getContentType() == 'json') { - - return $app->json($task_manager->toArray()); - } else { - - $template = 'admin/tasks/list.html.twig'; - /* @var $twig \Twig_Environment */ - $twig = $app['phraseanet.core']->getTwig(); - - return $twig->render($template, array( - 'task_manager' => $task_manager, - 'scheduler_key' => \phrasea::scheduler_key() - )); - } - }); - - /** - * route /admin/tasks/create - */ - $controllers->post('/create/', function(Application $app, Request $request) { - $appbox = \appbox::get_instance($app['phraseanet.core']); - $user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); - - $tcl = $request->get('tcl'); - if( $tcl ) - { - $task = \task_abstract::create($appbox, $tcl); - $tid = $task->getId(); - - return $app->redirect('/admin/task/'.$tid); - // return $tid; - } - - return $app->redirect('/admin/publications/list/'); - }); - - return $controllers; - } -} diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php index 99df82261a..f52ee7621e 100644 --- a/lib/classes/module/console/taskrun.class.php +++ b/lib/classes/module/console/taskrun.class.php @@ -102,12 +102,13 @@ class module_console_taskrun extends Command if ($input->getOption('verbose')) { $handler = new Handler\StreamHandler(fopen('php://stdout', 'a')); - $this->container['monolog']->pushHandler($handler); + $this->container['phraseanet.core']['monolog']->pushHandler($handler); } $logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log'; $handler = new Handler\RotatingFileHandler($logfile, 10); - $this->container['monolog']->pushHandler($handler); + $this->container['phraseanet.core']['monolog']->pushHandler($handler); + $logger = $this->container['phraseanet.core']['monolog']; $this->task = $task_manager->getTask($task_id, $logger); register_tick_function(array($this, 'tick_handler'), true); diff --git a/lib/classes/task/period/cindexer.class.php b/lib/classes/task/period/cindexer.class.php index 543e83b086..63be789b22 100755 --- a/lib/classes/task/period/cindexer.class.php +++ b/lib/classes/task/period/cindexer.class.php @@ -196,7 +196,7 @@ class task_period_cindexer extends task_abstract socket.value = xml.find("socket").text(); password.value = xml.find("password").text(); clng.value = xml.find("clng").text(); - use_sbas.checked = isyes(xml.find("use_sbas").text()); + use_sbas.checked = true | isyes(xml.find("use_sbas").text()); nolog.checked = isyes(xml.find("nolog").text()); winsvc_run.checked = isyes(xml.find("winsvc_run").text()); charset.value = xml.find("charset").text(); @@ -207,6 +207,8 @@ class task_period_cindexer extends task_abstract var cmd = ''; with(document.forms['graphicForm']) { + use_sbas.checked = true; + cmd += binpath.value + "/"; if(host.value) cmd += " -h=" + host.value; @@ -222,7 +224,7 @@ class task_period_cindexer extends task_abstract cmd += " --socket=" + socket.value; if(charset.value) cmd += " --default-character-set=" + charset.value; - if(use_sbas.checked) + if(1 || use_sbas.checked) cmd += " -o"; if(nolog.checked) cmd += " -n"; @@ -286,7 +288,7 @@ class task_period_cindexer extends task_abstract :