mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
update php-amqplib
This commit is contained in:
@@ -134,7 +134,7 @@
|
||||
"box/spout": "^2.7",
|
||||
"paragonie/random-lib": "^2.0",
|
||||
"czproject/git-php": "^3.17",
|
||||
"php-amqplib/php-amqplib": "2.9"
|
||||
"php-amqplib/php-amqplib": "^2.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikey179/vfsstream": "~1.5",
|
||||
|
35
composer.lock
generated
35
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1fda2bd48bdb1ad3a2cf0bfca723d775",
|
||||
"content-hash": "d986d21a2ad9125f83251d4c3943ffd7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alchemy-fr/tcpdf-clone",
|
||||
@@ -5147,22 +5147,26 @@
|
||||
},
|
||||
{
|
||||
"name": "php-amqplib/php-amqplib",
|
||||
"version": "v2.9.0",
|
||||
"version": "v2.11.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-amqplib/php-amqplib.git",
|
||||
"reference": "08d105d6b69ff4d8fa4fe090c49afdc568a5665b"
|
||||
"reference": "6353c5d2d3021a301914bc6566e695c99cfeb742"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/08d105d6b69ff4d8fa4fe090c49afdc568a5665b",
|
||||
"reference": "08d105d6b69ff4d8fa4fe090c49afdc568a5665b",
|
||||
"url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/6353c5d2d3021a301914bc6566e695c99cfeb742",
|
||||
"reference": "6353c5d2d3021a301914bc6566e695c99cfeb742",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-bcmath": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-sockets": "*",
|
||||
"php": ">=5.4.0"
|
||||
"php": ">=5.6.3",
|
||||
"phpseclib/phpseclib": "^2.0.0"
|
||||
},
|
||||
"conflict": {
|
||||
"php": "7.4.0 - 7.4.1"
|
||||
},
|
||||
"replace": {
|
||||
"videlalvaro/php-amqplib": "self.version"
|
||||
@@ -5170,14 +5174,13 @@
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"nategood/httpful": "^0.2.20",
|
||||
"phpdocumentor/phpdocumentor": "^2.9",
|
||||
"phpunit/phpunit": "^4.8",
|
||||
"phpunit/phpunit": "^5.7|^6.5|^7.0",
|
||||
"squizlabs/php_codesniffer": "^2.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev"
|
||||
"dev-master": "2.11-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -5194,11 +5197,6 @@
|
||||
"name": "Alvaro Videla",
|
||||
"role": "Original Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "John Kelly",
|
||||
"email": "johnmkelly86@gmail.com",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Raúl Araya",
|
||||
"email": "nubeiro@gmail.com",
|
||||
@@ -5208,6 +5206,11 @@
|
||||
"name": "Luke Bakken",
|
||||
"email": "luke@bakken.io",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Ramūnas Dronga",
|
||||
"email": "github@ramuno.lt",
|
||||
"role": "Maintainer"
|
||||
}
|
||||
],
|
||||
"description": "Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.",
|
||||
@@ -5217,7 +5220,7 @@
|
||||
"queue",
|
||||
"rabbitmq"
|
||||
],
|
||||
"time": "2019-03-22T16:02:15+00:00"
|
||||
"time": "2020-05-13T13:56:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-ffmpeg/php-ffmpeg",
|
||||
|
@@ -107,58 +107,77 @@ class SubdefCreationWorker implements WorkerInterface
|
||||
$em->rollback();
|
||||
}
|
||||
|
||||
$this->subdefGenerator->setLogger($this->logger);
|
||||
try {
|
||||
$this->subdefGenerator->setLogger($this->logger);
|
||||
|
||||
$this->subdefGenerator->generateSubdefs($record, $wantedSubdef);
|
||||
$this->subdefGenerator->generateSubdefs($record, $wantedSubdef);
|
||||
|
||||
// begin to check if the subdef is successfully generated
|
||||
$subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($payload['subdefName']);
|
||||
$filePathToCheck = null;
|
||||
// begin to check if the subdef is successfully generated
|
||||
$subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($payload['subdefName']);
|
||||
$filePathToCheck = null;
|
||||
|
||||
if ($record->has_subdef($payload['subdefName']) ) {
|
||||
$filePathToCheck = $record->get_subdef($payload['subdefName'])->getRealPath();
|
||||
}
|
||||
if ($record->has_subdef($payload['subdefName']) ) {
|
||||
$filePathToCheck = $record->get_subdef($payload['subdefName'])->getRealPath();
|
||||
}
|
||||
|
||||
$filePathToCheck = $this->filesystem->generateSubdefPathname($record, $subdef, $filePathToCheck);
|
||||
$filePathToCheck = $this->filesystem->generateSubdefPathname($record, $subdef, $filePathToCheck);
|
||||
|
||||
if (!$this->filesystem->exists($filePathToCheck)) {
|
||||
if (!$this->filesystem->exists($filePathToCheck)) {
|
||||
|
||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||
|
||||
$this->dispatcher->dispatch(WorkerEvents::SUBDEFINITION_CREATION_FAILURE, new SubdefinitionCreationFailureEvent(
|
||||
$record,
|
||||
$payload['subdefName'],
|
||||
'Subdef generation failed !',
|
||||
$count
|
||||
));
|
||||
$this->dispatcher->dispatch(WorkerEvents::SUBDEFINITION_CREATION_FAILURE, new SubdefinitionCreationFailureEvent(
|
||||
$record,
|
||||
$payload['subdefName'],
|
||||
'Subdef generation failed !',
|
||||
$count
|
||||
));
|
||||
|
||||
$this->subdefGenerator->setLogger($oldLogger);
|
||||
return ;
|
||||
}
|
||||
// checking ended
|
||||
|
||||
// order to write meta for the subdef if needed
|
||||
$this->dispatcher->dispatch(WorkerEvents::SUBDEFINITION_WRITE_META, new SubdefinitionWritemetaEvent($record, $payload['subdefName']));
|
||||
|
||||
$this->subdefGenerator->setLogger($oldLogger);
|
||||
return ;
|
||||
}
|
||||
// checking ended
|
||||
|
||||
// order to write meta for the subdef if needed
|
||||
$this->dispatcher->dispatch(WorkerEvents::SUBDEFINITION_WRITE_META, new SubdefinitionWritemetaEvent($record, $payload['subdefName']));
|
||||
// update jeton when subdef is created
|
||||
$this->updateJeton($record);
|
||||
|
||||
$this->subdefGenerator->setLogger($oldLogger);
|
||||
$parents = $record->get_grouping_parents();
|
||||
|
||||
// update jeton when subdef is created
|
||||
$this->updateJeton($record);
|
||||
// create a cover for a story
|
||||
// used when uploaded via uploader-service and grouped as a story
|
||||
if (!$parents->is_empty() && isset($payload['status']) && $payload['status'] == MessagePublisher::NEW_RECORD_MESSAGE && in_array($payload['subdefName'], array('thumbnail', 'preview'))) {
|
||||
foreach ($parents->get_elements() as $story) {
|
||||
if (self::checkIfFirstChild($story, $record)) {
|
||||
$data = implode('_', [$databoxId, $story->getRecordId(), $recordId, $payload['subdefName']]);
|
||||
|
||||
$parents = $record->get_grouping_parents();
|
||||
|
||||
// create a cover for a story
|
||||
// used when uploaded via uploader-service and grouped as a story
|
||||
if (!$parents->is_empty() && isset($payload['status']) && $payload['status'] == MessagePublisher::NEW_RECORD_MESSAGE && in_array($payload['subdefName'], array('thumbnail', 'preview'))) {
|
||||
foreach ($parents->get_elements() as $story) {
|
||||
if (self::checkIfFirstChild($story, $record)) {
|
||||
$data = implode('_', [$databoxId, $story->getRecordId(), $recordId, $payload['subdefName']]);
|
||||
|
||||
$this->dispatcher->dispatch(WorkerEvents::STORY_CREATE_COVER, new StoryCreateCoverEvent($data));
|
||||
$this->dispatcher->dispatch(WorkerEvents::STORY_CREATE_COVER, new StoryCreateCoverEvent($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$payload = [
|
||||
'message_type' => MessagePublisher::SUBDEF_CREATION_TYPE,
|
||||
'payload' => $payload
|
||||
];
|
||||
$this->messagePublisher->publishMessage($payload, MessagePublisher::DELAYED_SUBDEF_QUEUE);
|
||||
|
||||
$em->beginTransaction();
|
||||
try {
|
||||
$workerRunningJob->setStatus(WorkerRunningJob::FINISHED);
|
||||
$em->persist($workerRunningJob);
|
||||
$em->flush();
|
||||
$em->commit();
|
||||
} catch (\Exception $e) {
|
||||
$em->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// update elastic
|
||||
$this->indexer->flushQueue();
|
||||
|
||||
|
@@ -107,143 +107,163 @@ class WriteMetadatasWorker implements WorkerInterface
|
||||
$em->rollback();
|
||||
}
|
||||
|
||||
$record = $databox->get_record($recordId);
|
||||
try {
|
||||
$record = $databox->get_record($recordId);
|
||||
|
||||
$subdef = $record->get_subdef($payload['subdefName']);
|
||||
$subdef = $record->get_subdef($payload['subdefName']);
|
||||
|
||||
if ($subdef->is_physically_present()) {
|
||||
$metadata = new MetadataBag();
|
||||
if ($subdef->is_physically_present()) {
|
||||
$metadata = new MetadataBag();
|
||||
|
||||
// add Uuid in metadatabag
|
||||
if ($record->getUuid()) {
|
||||
$metadata->add(
|
||||
new Metadata(
|
||||
new Tag\XMPExif\ImageUniqueID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
$metadata->add(
|
||||
new Metadata(
|
||||
new Tag\ExifIFD\ImageUniqueID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
$metadata->add(
|
||||
new Metadata(
|
||||
new Tag\IPTC\UniqueDocumentID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// read document fields and add to metadatabag
|
||||
$caption = $record->get_caption();
|
||||
foreach ($databox->get_meta_structure() as $fieldStructure) {
|
||||
|
||||
$tagName = $fieldStructure->get_tag()->getTagname();
|
||||
$fieldName = $fieldStructure->get_name();
|
||||
|
||||
// skip fields with no src
|
||||
if ($tagName == '' || $tagName == 'Phraseanet:no-source') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check exiftool known tags to skip Phraseanet:tf-*
|
||||
try {
|
||||
$tag = TagFactory::getFromRDFTagname($tagName);
|
||||
if(!$tag->isWritable()) {
|
||||
continue;
|
||||
}
|
||||
} catch (TagUnknown $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$field = $caption->get_field($fieldName);
|
||||
$fieldValues = $field->get_values();
|
||||
|
||||
if ($fieldStructure->is_multi()) {
|
||||
$values = array();
|
||||
foreach ($fieldValues as $value) {
|
||||
$values[] = $this->removeNulChar($value->getValue());
|
||||
}
|
||||
|
||||
$value = new Multi($values);
|
||||
} else {
|
||||
$fieldValue = array_pop($fieldValues);
|
||||
$value = $this->removeNulChar($fieldValue->getValue());
|
||||
|
||||
// fix the dates edited into phraseanet
|
||||
if($fieldStructure->get_type() === $fieldStructure::TYPE_DATE) {
|
||||
try {
|
||||
$value = self::fixDate($value); // will return NULL if the date is not valid
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$value = null; // do NOT write back to iptc
|
||||
}
|
||||
}
|
||||
|
||||
if($value !== null) { // do not write invalid dates
|
||||
$value = new Mono($value);
|
||||
}
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
// the field is not set in the record, erase it
|
||||
if ($fieldStructure->is_multi()) {
|
||||
$value = new Multi(array(''));
|
||||
}
|
||||
else {
|
||||
$value = new Mono('');
|
||||
}
|
||||
}
|
||||
|
||||
if($value !== null) { // do not write invalid data
|
||||
// add Uuid in metadatabag
|
||||
if ($record->getUuid()) {
|
||||
$metadata->add(
|
||||
new Metadata($fieldStructure->get_tag(), $value)
|
||||
new Metadata(
|
||||
new Tag\XMPExif\ImageUniqueID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
$metadata->add(
|
||||
new Metadata(
|
||||
new Tag\ExifIFD\ImageUniqueID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
$metadata->add(
|
||||
new Metadata(
|
||||
new Tag\IPTC\UniqueDocumentID(),
|
||||
new Mono($record->getUuid())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writer->reset();
|
||||
// read document fields and add to metadatabag
|
||||
$caption = $record->get_caption();
|
||||
foreach ($databox->get_meta_structure() as $fieldStructure) {
|
||||
|
||||
if ($MWG) {
|
||||
$this->writer->setModule(Writer::MODULE_MWG, true);
|
||||
}
|
||||
$tagName = $fieldStructure->get_tag()->getTagname();
|
||||
$fieldName = $fieldStructure->get_name();
|
||||
|
||||
$this->writer->erase($subdef->get_name() != 'document' || $clearDoc, true);
|
||||
// skip fields with no src
|
||||
if ($tagName == '' || $tagName == 'Phraseanet:no-source') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// write meta in file
|
||||
try {
|
||||
$this->writer->write($subdef->getRealPath(), $metadata);
|
||||
// check exiftool known tags to skip Phraseanet:tf-*
|
||||
try {
|
||||
$tag = TagFactory::getFromRDFTagname($tagName);
|
||||
if(!$tag->isWritable()) {
|
||||
continue;
|
||||
}
|
||||
} catch (TagUnknown $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->messagePublisher->pushLog(sprintf('meta written for sbasid=%1$d - recordid=%2$d (%3$s)', $databox->get_sbas_id(), $recordId, $subdef->get_name() ));
|
||||
} catch (PHPExiftoolException $e) {
|
||||
$workerMessage = sprintf('meta NOT written for sbasid=%1$d - recordid=%2$d (%3$s) because "%s"', $databox->get_sbas_id(), $recordId, $subdef->get_name() , $e->getMessage());
|
||||
$this->logger->error($workerMessage);
|
||||
try {
|
||||
$field = $caption->get_field($fieldName);
|
||||
$fieldValues = $field->get_values();
|
||||
|
||||
if ($fieldStructure->is_multi()) {
|
||||
$values = array();
|
||||
foreach ($fieldValues as $value) {
|
||||
$values[] = $this->removeNulChar($value->getValue());
|
||||
}
|
||||
|
||||
$value = new Multi($values);
|
||||
} else {
|
||||
$fieldValue = array_pop($fieldValues);
|
||||
$value = $this->removeNulChar($fieldValue->getValue());
|
||||
|
||||
// fix the dates edited into phraseanet
|
||||
if($fieldStructure->get_type() === $fieldStructure::TYPE_DATE) {
|
||||
try {
|
||||
$value = self::fixDate($value); // will return NULL if the date is not valid
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$value = null; // do NOT write back to iptc
|
||||
}
|
||||
}
|
||||
|
||||
if($value !== null) { // do not write invalid dates
|
||||
$value = new Mono($value);
|
||||
}
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
// the field is not set in the record, erase it
|
||||
if ($fieldStructure->is_multi()) {
|
||||
$value = new Multi(array(''));
|
||||
}
|
||||
else {
|
||||
$value = new Mono('');
|
||||
}
|
||||
}
|
||||
|
||||
if($value !== null) { // do not write invalid data
|
||||
$metadata->add(
|
||||
new Metadata($fieldStructure->get_tag(), $value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writer->reset();
|
||||
|
||||
if ($MWG) {
|
||||
$this->writer->setModule(Writer::MODULE_MWG, true);
|
||||
}
|
||||
|
||||
$this->writer->erase($subdef->get_name() != 'document' || $clearDoc, true);
|
||||
|
||||
// write meta in file
|
||||
try {
|
||||
$this->writer->write($subdef->getRealPath(), $metadata);
|
||||
|
||||
$this->messagePublisher->pushLog(sprintf('meta written for sbasid=%1$d - recordid=%2$d (%3$s)', $databox->get_sbas_id(), $recordId, $subdef->get_name() ));
|
||||
} catch (PHPExiftoolException $e) {
|
||||
$workerMessage = sprintf('meta NOT written for sbasid=%1$d - recordid=%2$d (%3$s) because "%s"', $databox->get_sbas_id(), $recordId, $subdef->get_name() , $e->getMessage());
|
||||
$this->logger->error($workerMessage);
|
||||
|
||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||
|
||||
$this->dispatch(WorkerEvents::SUBDEFINITION_WRITE_META, new SubdefinitionWritemetaEvent(
|
||||
$record,
|
||||
$payload['subdefName'],
|
||||
SubdefinitionWritemetaEvent::FAILED,
|
||||
$workerMessage,
|
||||
$count
|
||||
));
|
||||
}
|
||||
|
||||
// mark write metas finished
|
||||
$this->updateJeton($record);
|
||||
} else {
|
||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||
|
||||
$this->dispatch(WorkerEvents::SUBDEFINITION_WRITE_META, new SubdefinitionWritemetaEvent(
|
||||
$record,
|
||||
$payload['subdefName'],
|
||||
SubdefinitionWritemetaEvent::FAILED,
|
||||
$workerMessage,
|
||||
'Subdef is not physically present!',
|
||||
$count
|
||||
));
|
||||
}
|
||||
|
||||
// mark write metas finished
|
||||
$this->updateJeton($record);
|
||||
} else {
|
||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||
} catch(\Exception $e) {
|
||||
$payload = [
|
||||
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
|
||||
'payload' => $payload
|
||||
];
|
||||
$this->messagePublisher->publishMessage($payload, MessagePublisher::DELAYED_METADATAS_QUEUE);
|
||||
|
||||
$this->dispatch(WorkerEvents::SUBDEFINITION_WRITE_META, new SubdefinitionWritemetaEvent(
|
||||
$record,
|
||||
$payload['subdefName'],
|
||||
SubdefinitionWritemetaEvent::FAILED,
|
||||
'Subdef is not physically present!',
|
||||
$count
|
||||
));
|
||||
|
||||
$em->beginTransaction();
|
||||
try {
|
||||
$workerRunningJob->setStatus(WorkerRunningJob::FINISHED);
|
||||
$em->persist($workerRunningJob);
|
||||
$em->flush();
|
||||
$em->commit();
|
||||
} catch (\Exception $e) {
|
||||
$em->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// tell that we have finished to work on this file
|
||||
|
Reference in New Issue
Block a user