mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
fix log session in edit
This commit is contained in:
@@ -336,9 +336,10 @@ class EditController extends Controller
|
||||
return $this->app->json(['message' => '', 'error' => false]);
|
||||
}
|
||||
|
||||
$sessionLogId = $this->getDataboxLogger($databox)->get_id();
|
||||
// order the worker to save values in fields
|
||||
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::MDS_TYPE, $request->request->get('mds'), $databox->get_sbas_id())
|
||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::MDS_TYPE, $request->request->get('mds'), $databox->get_sbas_id(), $sessionLogId)
|
||||
);
|
||||
|
||||
return $this->app->json(['success' => true]);
|
||||
@@ -362,10 +363,12 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
$databoxId = reset($sbasIds);
|
||||
$databox = $this->findDataboxById($databoxId);
|
||||
$sessionLogId = $this->getDataboxLogger($databox)->get_id();
|
||||
|
||||
// order the worker to save values in fields
|
||||
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::JSON_TYPE, $request->getContent(), $databoxId)
|
||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::JSON_TYPE, $request->getContent(), $databoxId, $sessionLogId)
|
||||
);
|
||||
|
||||
return $this->app->json(['success' => true]);
|
||||
|
@@ -12,13 +12,14 @@ class RecordEditInWorkerEvent extends SfEvent
|
||||
private $dataType;
|
||||
private $data;
|
||||
private $databoxId;
|
||||
private $sessionLogId;
|
||||
|
||||
|
||||
public function __construct($dataType, $data, $databoxId)
|
||||
public function __construct($dataType, $data, $databoxId, $sessionLogId)
|
||||
{
|
||||
$this->dataType = $dataType;
|
||||
$this->data = $data;
|
||||
$this->databoxId = $databoxId;
|
||||
$this->sessionLogId = $sessionLogId;
|
||||
}
|
||||
|
||||
public function getDataType()
|
||||
@@ -34,4 +35,9 @@ class RecordEditInWorkerEvent extends SfEvent
|
||||
{
|
||||
return $this->databoxId;
|
||||
}
|
||||
|
||||
public function getSessionLogId()
|
||||
{
|
||||
return $this->sessionLogId;
|
||||
}
|
||||
}
|
||||
|
@@ -161,7 +161,6 @@ class AlchemyWorkerServiceProvider implements PluginProviderInterface
|
||||
$app['alchemy_worker.type_based_worker_resolver']->addFactory(MessagePublisher::EDIT_RECORD_TYPE, new CallableWorkerFactory(function () use ($app) {
|
||||
return (new EditRecordWorker($app['repo.worker-running-job'], $app['dispatcher'], $app['alchemy_worker.message.publisher']))
|
||||
->setApplicationBox($app['phraseanet.appbox'])
|
||||
->setDataboxLoggerLocator($app['phraseanet.logger'])
|
||||
;
|
||||
}));
|
||||
}
|
||||
|
@@ -293,7 +293,8 @@ class RecordSubscriber implements EventSubscriberInterface
|
||||
'type' => MessagePublisher::EDIT_RECORD_TYPE, // used to specify the final Q to publish message
|
||||
'dataType' => $event->getDataType(),
|
||||
'data' => $event->getData(),
|
||||
'databoxId' => $event->getDataboxId()
|
||||
'databoxId' => $event->getDataboxId(),
|
||||
'sessionLogId' => $event->getSessionLogId()
|
||||
]
|
||||
];
|
||||
|
||||
|
@@ -17,7 +17,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
class EditRecordWorker implements WorkerInterface
|
||||
{
|
||||
use ApplicationBoxAware;
|
||||
use DataboxLoggerAware;
|
||||
|
||||
private $repoWorker;
|
||||
private $dispatcher;
|
||||
@@ -75,6 +74,7 @@ class EditRecordWorker implements WorkerInterface
|
||||
$workerRunningJob = new WorkerRunningJob();
|
||||
$workerRunningJob
|
||||
->setDataboxId($payload['databoxId'])
|
||||
->setRecordId($payload['record_id'])
|
||||
->setWork(MessagePublisher::EDIT_RECORD_TYPE)
|
||||
->setWorkOn("record")
|
||||
->setPublished($date->setTimestamp($payload['published']))
|
||||
@@ -136,11 +136,11 @@ class EditRecordWorker implements WorkerInterface
|
||||
$record->write_metas();
|
||||
|
||||
if ($statbits != '') {
|
||||
$this->getDataboxLogger($databox)
|
||||
\Session_Logger::loadById($databox, $payload['sessionLogId'])
|
||||
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
||||
}
|
||||
if ($editDirty) {
|
||||
$this->getDataboxLogger($databox)
|
||||
\Session_Logger::loadById($databox, $payload['sessionLogId'])
|
||||
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
||||
}
|
||||
} else {
|
||||
|
@@ -37,6 +37,7 @@ class MainQueueWorker implements WorkerInterface
|
||||
$payloadData = array_map(function($singleMessage) use ($payload) {
|
||||
$singleMessage['databoxId'] = $payload['databoxId'];
|
||||
$singleMessage['dataType'] = $payload['dataType'];
|
||||
$singleMessage['sessionLogId'] = $payload['sessionLogId'];
|
||||
|
||||
return $singleMessage;
|
||||
}, $payload['data']);
|
||||
@@ -45,6 +46,7 @@ class MainQueueWorker implements WorkerInterface
|
||||
|
||||
$payloadData = array_map(function($singleMessage) use ($payload, $data) {
|
||||
$singleMessage['databoxId'] = $payload['databoxId'];
|
||||
$singleMessage['sessionLogId'] = $payload['sessionLogId'];
|
||||
$singleMessage['dataType'] = $payload['dataType'];
|
||||
$singleMessage['actions'] = $data['actions'];
|
||||
unset($singleMessage['sbas_id']);
|
||||
|
@@ -170,6 +170,27 @@ class Session_Logger
|
||||
return new self($databox, $row['id']);
|
||||
}
|
||||
|
||||
public static function loadById($databox, $logId)
|
||||
{
|
||||
$sql = 'SELECT id, site FROM log
|
||||
WHERE id = :log_id ';
|
||||
|
||||
$params = [
|
||||
':log_id' => $logId
|
||||
];
|
||||
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (!$row) {
|
||||
throw new Exception_Session_LoggerNotFound('Logger not found');
|
||||
}
|
||||
|
||||
return new self($databox, $logId);
|
||||
}
|
||||
|
||||
public static function updateClientInfos(Application $app, $appId)
|
||||
{
|
||||
if (!$app->getAuthenticator()->isAuthenticated()) {
|
||||
|
Reference in New Issue
Block a user