mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 20:13:28 +00:00
PHRAS-3468 remove logs trace
This commit is contained in:
@@ -34,10 +34,6 @@ class Sha256 extends AbstractChecker
|
|||||||
*/
|
*/
|
||||||
public function check(EntityManager $em, File $file)
|
public function check(EntityManager $em, File $file)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("\n%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into checker sha256")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$excludedCollIds = [];
|
$excludedCollIds = [];
|
||||||
if (!empty($this->compareIgnoreCollections)) {
|
if (!empty($this->compareIgnoreCollections)) {
|
||||||
foreach ($this->compareIgnoreCollections as $collection) {
|
foreach ($this->compareIgnoreCollections as $collection) {
|
||||||
@@ -50,10 +46,6 @@ class Sha256 extends AbstractChecker
|
|||||||
|
|
||||||
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findBySha256WithExcludedCollIds($file->getSha256(), $excludedCollIds));
|
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findBySha256WithExcludedCollIds($file->getSha256(), $excludedCollIds));
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return from checker sha256")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return new Response($boolean, $this);
|
return new Response($boolean, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,10 +33,6 @@ class UUID extends AbstractChecker
|
|||||||
*/
|
*/
|
||||||
public function check(EntityManager $em, File $file)
|
public function check(EntityManager $em, File $file)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("\n%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into checker uuid")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$excludedCollIds = [];
|
$excludedCollIds = [];
|
||||||
if (!empty($this->compareIgnoreCollections)) {
|
if (!empty($this->compareIgnoreCollections)) {
|
||||||
foreach ($this->compareIgnoreCollections as $collection) {
|
foreach ($this->compareIgnoreCollections as $collection) {
|
||||||
@@ -48,9 +44,6 @@ class UUID extends AbstractChecker
|
|||||||
}
|
}
|
||||||
|
|
||||||
$uuid = $file->getUUID(false, false);
|
$uuid = $file->getUUID(false, false);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("found uuid=%s", $uuid ?: 'null')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if($uuid === null) {
|
if($uuid === null) {
|
||||||
// no uuid in file so no need to search for a match
|
// no uuid in file so no need to search for a match
|
||||||
@@ -60,10 +53,6 @@ class UUID extends AbstractChecker
|
|||||||
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findByUuidWithExcludedCollIds($uuid, $excludedCollIds));
|
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findByUuidWithExcludedCollIds($uuid, $excludedCollIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return from checker uuid")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return new Response($boolean, $this);
|
return new Response($boolean, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,10 +63,6 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function __construct(Application $app, MediaInterface $media, \collection $collection, $originalName = null)
|
public function __construct(Application $app, MediaInterface $media, \collection $collection, $originalName = null)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into construct")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->media = $media;
|
$this->media = $media;
|
||||||
$this->collection = $collection;
|
$this->collection = $collection;
|
||||||
@@ -93,15 +89,7 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function getUUID($generate = false, $write = false)
|
public function getUUID($generate = false, $write = false)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into getuuid for \"%s\" with generate=%s, write=%s ; this->uuid=%s", $this->getFile()->getRealPath(), $generate?'true':'false', $write?'true':'false', $this->uuid ?:'null')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if ($this->uuid && !$write) {
|
if ($this->uuid && !$write) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return known uuid %s", $this->uuid)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $this->uuid;
|
return $this->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,10 +103,6 @@ class File
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (!$this->uuid) {
|
if (!$this->uuid) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("getMetadatas to get uuid")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$metadatas = $this->media->getMetadatas();
|
$metadatas = $this->media->getMetadatas();
|
||||||
|
|
||||||
$uuid = null;
|
$uuid = null;
|
||||||
@@ -132,10 +116,6 @@ class File
|
|||||||
if (Uuid::isValid($candidate)) {
|
if (Uuid::isValid($candidate)) {
|
||||||
$uuid = $candidate;
|
$uuid = $candidate;
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("found uuid from %s ; %s", $meta, $uuid)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,19 +123,12 @@ class File
|
|||||||
|
|
||||||
if (!$uuid && $generate) {
|
if (!$uuid && $generate) {
|
||||||
$uuid = Uuid::uuid4();
|
$uuid = Uuid::uuid4();
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("generated uuid %s", $uuid)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->uuid = $uuid;
|
$this->uuid = $uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($write) {
|
if ($write) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("writing uuid %s", $this->uuid)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$value = new MonoValue($this->uuid);
|
$value = new MonoValue($this->uuid);
|
||||||
$metadatas = new ExiftoolMetadataBag();
|
$metadatas = new ExiftoolMetadataBag();
|
||||||
|
|
||||||
@@ -167,30 +140,14 @@ class File
|
|||||||
$writer = $this->app['exiftool.writer'];
|
$writer = $this->app['exiftool.writer'];
|
||||||
$writer->reset();
|
$writer->reset();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("exiftool will write to %s", $this->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$writer->write($this->getFile()->getRealPath(), $metadatas);
|
$writer->write($this->getFile()->getRealPath(), $metadatas);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("exiftool has writen ok to %s", $this->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
} catch (PHPExiftoolException $e) {
|
} catch (PHPExiftoolException $e) {
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("exiftool failed to write to %s because (%s)", $this->getFile()->getRealPath(), $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
// PHPExiftool throws exception on some files not supported
|
// PHPExiftool throws exception on some files not supported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return uuid %s", $this->uuid ?: 'null')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $this->uuid;
|
return $this->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,30 +186,9 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function getSha256()
|
public function getSha256()
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into getSha256() for \"%s\" ; this->sha256=%s", $this->getFile()->getRealPath(), $this->sha256 ?: 'null')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if (!$this->sha256) {
|
if (!$this->sha256) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("sha256 unknown, calling mediavorus::getHash('sha256')")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->sha256 = $this->media->getHash('sha256');
|
$this->sha256 = $this->media->getHash('sha256');
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("mediavorus::getHash('sha256') returned \"%s\"", $this->sha256)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("sha256 known (\"%s\")", $this->sha256)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return sha256 %s", $this->sha256 ?: 'null')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $this->sha256;
|
return $this->sha256;
|
||||||
}
|
}
|
||||||
|
@@ -108,16 +108,9 @@ class Manager
|
|||||||
*/
|
*/
|
||||||
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null, $nosubdef = false)
|
public function process(LazaretSession $session, File $file, $callable = null, $forceBehavior = null, $nosubdef = false)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into process")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$visa = $this->getVisa($file);
|
$visa = $this->getVisa($file);
|
||||||
|
|
||||||
// READ the uuid (possibly generates one) but DO NOT write (because we need the stripped file for sha compare ?)
|
// READ the uuid (possibly generates one) but DO NOT write (because we need the stripped file for sha compare ?)
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("get uuid (generate, no write) from \"%s\"", $file->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$file->getUUID(true, false);
|
$file->getUUID(true, false);
|
||||||
|
|
||||||
@@ -126,42 +119,24 @@ class Manager
|
|||||||
$this->addMediaAttributes($file);
|
$this->addMediaAttributes($file);
|
||||||
|
|
||||||
// Write UUID
|
// Write UUID
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("get uuid (no generate, write) from \"%s\"", $file->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$file->getUUID(false, true);
|
$file->getUUID(false, true);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("creating record")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$element = $this->createRecord($file, $nosubdef);
|
$element = $this->createRecord($file, $nosubdef);
|
||||||
|
|
||||||
$code = self::RECORD_CREATED;
|
$code = self::RECORD_CREATED;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Write UUID
|
// Write UUID
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("get uuid (no generate, write) from \"%s\"", $file->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$file->getUUID(false, true);
|
$file->getUUID(false, true);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("creating lazaret")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$element = $this->createLazaret($file, $visa, $session, $forceBehavior === self::FORCE_LAZARET);
|
$element = $this->createLazaret($file, $visa, $session, $forceBehavior === self::FORCE_LAZARET);
|
||||||
|
|
||||||
$code = self::LAZARET_CREATED;
|
$code = self::LAZARET_CREATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Write UUID
|
// // Write UUID
|
||||||
// file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
// sprintf("get uuid (no generate, write) from \"%s\"", $file->getFile()->getRealPath())
|
|
||||||
// ), FILE_APPEND | LOCK_EX);
|
|
||||||
//
|
|
||||||
// $file->getUUID(false, true);
|
// $file->getUUID(false, true);
|
||||||
|
|
||||||
if (is_callable($callable)) {
|
if (is_callable($callable)) {
|
||||||
@@ -304,17 +279,8 @@ class Manager
|
|||||||
*/
|
*/
|
||||||
protected function createRecord(File $file, $nosubdef=false)
|
protected function createRecord(File $file, $nosubdef=false)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into createRecord")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$element = \record_adapter::createFromFile($file, $this->app);
|
$element = \record_adapter::createFromFile($file, $this->app);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("created %s.%s", $element->getDataboxId(), $element->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
|
|
||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
|
|
||||||
$file->addAttribute(
|
$file->addAttribute(
|
||||||
@@ -379,19 +345,12 @@ class Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("calling replaceMetadata")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
/** @var EventDispatcherInterface $dispatcher */
|
/** @var EventDispatcherInterface $dispatcher */
|
||||||
$dispatcher = $this->app['dispatcher'];
|
$dispatcher = $this->app['dispatcher'];
|
||||||
$dispatcher->addListener(
|
$dispatcher->addListener(
|
||||||
RecordEvents::METADATA_CHANGED,
|
RecordEvents::METADATA_CHANGED,
|
||||||
function (Event $event) {
|
function (Event $event) {
|
||||||
// we do not want replaceMetadata() to send a writemeta
|
// we do not want replaceMetadata() to send a writemeta
|
||||||
// file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
// sprintf("---------- event METADATA_CHANGED catched !!! Propagation stopped !!!")
|
|
||||||
// ), FILE_APPEND | LOCK_EX);
|
|
||||||
// $event->stopPropagation();
|
// $event->stopPropagation();
|
||||||
},
|
},
|
||||||
10
|
10
|
||||||
@@ -421,10 +380,6 @@ class Manager
|
|||||||
*/
|
*/
|
||||||
protected function createLazaret(File $file, Visa $visa, LazaretSession $session, $forced)
|
protected function createLazaret(File $file, Visa $visa, LazaretSession $session, $forced)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into createLazaret")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$file->addAttribute(
|
$file->addAttribute(
|
||||||
new MetadataAttr(
|
new MetadataAttr(
|
||||||
@@ -477,10 +432,6 @@ class Manager
|
|||||||
|
|
||||||
$this->app['orm.em']->flush();
|
$this->app['orm.em']->flush();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return from createLazaret")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $lazaretFile;
|
return $lazaretFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -117,10 +117,6 @@ class UploadController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function upload(Request $request)
|
public function upload(Request $request)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into upload controller")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'code' => null,
|
'code' => null,
|
||||||
@@ -198,21 +194,12 @@ class UploadController extends Controller
|
|||||||
$renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
|
$renamedFilename = $file->getRealPath() . '.' . pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("rename \"%s\" to \"%s\"", $uploadedFilename, $renamedFilename)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->getFilesystem()->rename($uploadedFilename, $renamedFilename);
|
$this->getFilesystem()->rename($uploadedFilename, $renamedFilename);
|
||||||
|
|
||||||
$originalName = $file->getClientOriginalName();
|
$originalName = $file->getClientOriginalName();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("calling getMediaFromUri(\"%s\")", $renamedFilename)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
|
|
||||||
$media = $this->app->getMediaFromUri($renamedFilename);
|
$media = $this->app->getMediaFromUri($renamedFilename);
|
||||||
$collection = \collection::getByBaseId($this->app, $base_id);
|
$collection = \collection::getByBaseId($this->app, $base_id);
|
||||||
|
|
||||||
@@ -241,15 +228,7 @@ class UploadController extends Controller
|
|||||||
$elementCreated = null;
|
$elementCreated = null;
|
||||||
|
|
||||||
$callback = function ($element, Visa $visa) use (&$reasons, &$elementCreated) {
|
$callback = function ($element, Visa $visa) use (&$reasons, &$elementCreated) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into callback")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
foreach ($visa->getResponses() as $response) {
|
foreach ($visa->getResponses() as $response) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("visa returned %s", $response->isOk() ? 'ok' : 'not ok')
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if (!$response->isOk()) {
|
if (!$response->isOk()) {
|
||||||
$reasons[] = $response->getMessage($this->app['translator']);
|
$reasons[] = $response->getMessage($this->app['translator']);
|
||||||
}
|
}
|
||||||
@@ -258,23 +237,10 @@ class UploadController extends Controller
|
|||||||
$elementCreated = $element;
|
$elementCreated = $element;
|
||||||
};
|
};
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("process")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$code = $this->getBorderManager()->process( $lazaretSession, $packageFile, $callback, $forceBehavior);
|
$code = $this->getBorderManager()->process( $lazaretSession, $packageFile, $callback, $forceBehavior);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("processed, returned elementCreated class \"%s\"", get_class($elementCreated))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if($renamedFilename !== $uploadedFilename) {
|
if($renamedFilename !== $uploadedFilename) {
|
||||||
$this->getFilesystem()->rename($renamedFilename, $uploadedFilename);
|
$this->getFilesystem()->rename($renamedFilename, $uploadedFilename);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("renamed \"%s\" back to \"%s\"", $renamedFilename, $uploadedFilename)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!$forceBehavior) {
|
if (!!$forceBehavior) {
|
||||||
@@ -282,19 +248,10 @@ class UploadController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($elementCreated instanceof \record_adapter) {
|
if ($elementCreated instanceof \record_adapter) {
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("record %s created", $elementCreated->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$id = $elementCreated->getId();
|
$id = $elementCreated->getId();
|
||||||
$element = 'record';
|
$element = 'record';
|
||||||
$message = $this->app->trans('The record was successfully created');
|
$message = $this->app->trans('The record was successfully created');
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch event RECORD_UPLOAD")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->dispatch(PhraseaEvents::RECORD_UPLOAD, new RecordEdit($elementCreated));
|
$this->dispatch(PhraseaEvents::RECORD_UPLOAD, new RecordEdit($elementCreated));
|
||||||
|
|
||||||
// try to create thumbnail from data URI
|
// try to create thumbnail from data URI
|
||||||
@@ -305,16 +262,8 @@ class UploadController extends Controller
|
|||||||
$fileName = $this->getTemporaryFilesystem()->createTemporaryFile('base_64_thumb', null, "png");
|
$fileName = $this->getTemporaryFilesystem()->createTemporaryFile('base_64_thumb', null, "png");
|
||||||
file_put_contents($fileName, $dataUri->getData());
|
file_put_contents($fileName, $dataUri->getData());
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("calling getMediaFromUri(\"%s\")", $fileName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$media = $this->app->getMediaFromUri($fileName);
|
$media = $this->app->getMediaFromUri($fileName);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("getMediaFromUri(...) done")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->getSubDefinitionSubstituer()->substituteSubdef($elementCreated, 'thumbnail', $media);
|
$this->getSubDefinitionSubstituer()->substituteSubdef($elementCreated, 'thumbnail', $media);
|
||||||
$this->getDataboxLogger($elementCreated->getDatabox())
|
$this->getDataboxLogger($elementCreated->getDatabox())
|
||||||
->log($elementCreated, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', '');
|
->log($elementCreated, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', '');
|
||||||
@@ -327,10 +276,6 @@ class UploadController extends Controller
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/** @var LazaretFile $elementCreated */
|
/** @var LazaretFile $elementCreated */
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch event LAZARET_CREATE")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->dispatch(PhraseaEvents::LAZARET_CREATE, new LazaretEvent($elementCreated));
|
$this->dispatch(PhraseaEvents::LAZARET_CREATE, new LazaretEvent($elementCreated));
|
||||||
|
|
||||||
$id = $elementCreated->getId();
|
$id = $elementCreated->getId();
|
||||||
@@ -350,10 +295,6 @@ class UploadController extends Controller
|
|||||||
$data['message'] = $this->app->trans('Unable to add file to Phraseanet');
|
$data['message'] = $this->app->trans('Unable to add file to Phraseanet');
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("returns")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$response = $this->app->json($data);
|
$response = $this->app->json($data);
|
||||||
// IE 7 and 8 does not correctly handle json response in file API
|
// IE 7 and 8 does not correctly handle json response in file API
|
||||||
// lets send them an html content-type header
|
// lets send them an html content-type header
|
||||||
|
@@ -111,9 +111,6 @@ class SubdefGenerator
|
|||||||
$hd = $hd->getRealPath();
|
$hd = $hd->getRealPath();
|
||||||
|
|
||||||
clearstatcache(true, $hd);
|
clearstatcache(true, $hd);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("creating subdefs for %s.%s from document \"%s\" (size=%s)", $record->getDataboxId(), $record->getRecordId(), $hd, filesize($hd))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$mediaCreated = [];
|
$mediaCreated = [];
|
||||||
@@ -130,10 +127,6 @@ class SubdefGenerator
|
|||||||
|
|
||||||
$pathdest = $record->get_subdef($subdefname)->getRealPath();
|
$pathdest = $record->get_subdef($subdefname)->getRealPath();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("deleting previous subdef \"%s\" (file=\"%s\") for %s.%s", $subdefname, $pathdest, $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$record->get_subdef($subdefname)->remove_file();
|
$record->get_subdef($subdefname)->remove_file();
|
||||||
$this->logger->info(sprintf('Removed old file for %s', $subdefname));
|
$this->logger->info(sprintf('Removed old file for %s', $subdefname));
|
||||||
$record->clearSubdefCache($subdefname);
|
$record->clearSubdefCache($subdefname);
|
||||||
|
@@ -42,10 +42,6 @@ class PhraseanetMetadataSetter
|
|||||||
*/
|
*/
|
||||||
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
public function replaceMetadata($metadataCollection, \record_adapter $record)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("replaceMetadata for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$metaStructure = $this->repository->find($record->getDataboxId())->get_meta_structure()->get_elements();
|
$metaStructure = $this->repository->find($record->getDataboxId())->get_meta_structure()->get_elements();
|
||||||
|
|
||||||
$metadataPerField = $this->extractMetadataPerField($metaStructure, $metadataCollection);
|
$metadataPerField = $this->extractMetadataPerField($metaStructure, $metadataCollection);
|
||||||
@@ -92,10 +88,6 @@ class PhraseanetMetadataSetter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($metadataInRecordFormat)) {
|
if (! empty($metadataInRecordFormat)) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("calling set_metadatas for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* todo : tryout to write meta AFTER meta was written in db by set_metadatas()
|
* todo : tryout to write meta AFTER meta was written in db by set_metadatas()
|
||||||
* how : uncomment section
|
* how : uncomment section
|
||||||
@@ -106,9 +98,6 @@ class PhraseanetMetadataSetter
|
|||||||
RecordEvents::METADATA_CHANGED,
|
RecordEvents::METADATA_CHANGED,
|
||||||
function () use ($record) {
|
function () use ($record) {
|
||||||
// order to write meta in file
|
// order to write meta in file
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch WorkerEvents::RECORDS_WRITE_META for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
// this event will add a msg to the writemeta q
|
// this event will add a msg to the writemeta q
|
||||||
$this->dispatcher->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
$this->dispatcher->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
||||||
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
||||||
@@ -128,9 +117,6 @@ class PhraseanetMetadataSetter
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// order to write meta in file
|
// order to write meta in file
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch WorkerEvents::RECORDS_WRITE_META for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->dispatcher->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
$this->dispatcher->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
||||||
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
||||||
@@ -138,13 +124,6 @@ class PhraseanetMetadataSetter
|
|||||||
* end of section to comment
|
* end of section to comment
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("no metadatas to set for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -129,10 +129,6 @@ class LazaretManipulator
|
|||||||
{
|
{
|
||||||
$ret = ['success' => false, 'message' => '', 'result' => []];
|
$ret = ['success' => false, 'message' => '', 'result' => []];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into lazaret/add")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
/* @var LazaretFile $lazaretFile */
|
/* @var LazaretFile $lazaretFile */
|
||||||
$lazaretFile = $this->repository->find($file_id);
|
$lazaretFile = $this->repository->find($file_id);
|
||||||
|
|
||||||
@@ -147,21 +143,12 @@ class LazaretManipulator
|
|||||||
$lazaretThumbFileName = $path .'/'.$lazaretFile->getThumbFilename();
|
$lazaretThumbFileName = $path .'/'.$lazaretFile->getThumbFilename();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("ok to add from lazaret")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$borderFile = Border\File::buildFromPathfile(
|
$borderFile = Border\File::buildFromPathfile(
|
||||||
$lazaretFileName,
|
$lazaretFileName,
|
||||||
$lazaretFile->getCollection($this->app),
|
$lazaretFile->getCollection($this->app),
|
||||||
$this->app,
|
$this->app,
|
||||||
$lazaretFile->getOriginalName()
|
$lazaretFile->getOriginalName()
|
||||||
);
|
);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("got borderFile \"%s\"", $borderFile->getFile()->getRealPath())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(\Exception $e) {
|
||||||
// the file is not in tmp anymore ?
|
// the file is not in tmp anymore ?
|
||||||
@@ -172,17 +159,9 @@ class LazaretManipulator
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("added from lazaret")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Post record creation
|
//Post record creation
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("force record creation")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
/** @var \record_adapter $record */
|
/** @var \record_adapter $record */
|
||||||
$record = null;
|
$record = null;
|
||||||
$callBack = function ($element) use (&$record) {
|
$callBack = function ($element) use (&$record) {
|
||||||
@@ -197,17 +176,9 @@ class LazaretManipulator
|
|||||||
Border\Manager::FORCE_RECORD
|
Border\Manager::FORCE_RECORD
|
||||||
);
|
);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("got record %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if ($keepAttributes) {
|
if ($keepAttributes) {
|
||||||
//add attribute
|
//add attribute
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("adding attributes")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$metaFields = new Border\MetaFieldsBag();
|
$metaFields = new Border\MetaFieldsBag();
|
||||||
$metadataBag = new Border\MetadataBag();
|
$metadataBag = new Border\MetadataBag();
|
||||||
|
|
||||||
@@ -250,25 +221,14 @@ class LazaretManipulator
|
|||||||
/* todo: better to to do only one set_metadatas ? */
|
/* todo: better to to do only one set_metadatas ? */
|
||||||
$data = $metadataBag->toMetadataArray($record->getDatabox()->get_meta_structure());
|
$data = $metadataBag->toMetadataArray($record->getDatabox()->get_meta_structure());
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("adding attributes \"databag\" %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$record->set_metadatas($data);
|
$record->set_metadatas($data);
|
||||||
|
|
||||||
$fields = $metaFields->toMetadataArray($record->getDatabox()->get_meta_structure());
|
$fields = $metaFields->toMetadataArray($record->getDatabox()->get_meta_structure());
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("adding attributes \"fields\" %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$record->set_metadatas($fields);
|
$record->set_metadatas($fields);
|
||||||
|
|
||||||
|
|
||||||
// order to write meta in file
|
// order to write meta in file
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch WorkerEvents::RECORDS_WRITE_META for %s.%s", $record->getDataboxId(), $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->app['dispatcher']->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
$this->app['dispatcher']->dispatch(WorkerEvents::RECORDS_WRITE_META,
|
||||||
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
|
||||||
@@ -291,10 +251,6 @@ class LazaretManipulator
|
|||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return from laaret/add")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,15 +86,8 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
$databoxId = $payload['databoxId'];
|
$databoxId = $payload['databoxId'];
|
||||||
$recordId = $payload['recordId'];
|
$recordId = $payload['recordId'];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf('canDoJob("%s") for %s.%s ?', $jobType, $databoxId, $recordId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
// first protect sql by a critical section
|
// first protect sql by a critical section
|
||||||
if( !( $recordMutexId = $this->getRecordMutex($databoxId, $recordId)) ) {
|
if( !( $recordMutexId = $this->getRecordMutex($databoxId, $recordId)) ) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
'getRecordMutex() failed'
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -120,38 +113,19 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
if ($stmt->execute() === true) {
|
if ($stmt->execute() === true) {
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED select on %s.%s because (%s)", $databoxId, $recordId, $stmt->errorCode())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if(!$row) {
|
if(!$row) {
|
||||||
// no job running : create or update (may return false) if error
|
// no job running : create or update (may return false) if error
|
||||||
$workerRunningJobId = $this->creteOrUpdateJob($cnx, $payload, $jobType);
|
$workerRunningJobId = $this->creteOrUpdateJob($cnx, $payload, $jobType);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("job %s (id=%s) already running on %s.%s", $row['work'], $row['id'], $databoxId, $recordId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnx->commit();
|
$cnx->commit();
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$cnx->rollBack();
|
$cnx->rollBack();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED in transaction to select/create on %s.%s because (%s)", $databoxId, $recordId, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED to create transaction to select/create on %s.%s", $databoxId, $recordId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
|
|
||||||
// end of critical section
|
// end of critical section
|
||||||
$this->releaseMutex($recordMutexId);
|
$this->releaseMutex($recordMutexId);
|
||||||
@@ -199,9 +173,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
if ($cnx->exec($sql) === 1) {
|
if ($cnx->exec($sql) === 1) {
|
||||||
// went well, the row is inserted
|
// went well, the row is inserted
|
||||||
$workerJobId = $cnx->lastInsertId();
|
$workerJobId = $cnx->lastInsertId();
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("created job %s (id=%s) for %s.%s.%s", $type, $workerJobId, $payload['databoxId'], $payload['recordId'], $payload['subdefName'])
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// row not inserted ?
|
// row not inserted ?
|
||||||
@@ -218,10 +189,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
if ($cnx->exec($sql) === 1) {
|
if ($cnx->exec($sql) === 1) {
|
||||||
// went well, the row is updated
|
// went well, the row is updated
|
||||||
$workerJobId = $payload['workerJobId'];
|
$workerJobId = $payload['workerJobId'];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("updated job %s (id=%s) for %s.%s.%s", $type, $workerJobId, $payload['databoxId'], $payload['recordId'], $payload['subdefName'])
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// row not inserted ?
|
// row not inserted ?
|
||||||
@@ -231,10 +198,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
// bad case : we return null anyway
|
// bad case : we return null anyway
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED creating/updating job %s for %s.%s.%s because (%s)", $type, $payload['databoxId'], $payload['recordId'], $payload['subdefName'], $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $workerJobId;
|
return $workerJobId;
|
||||||
@@ -273,18 +236,10 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
. " `flock` = " . $cnx->quote('_mutex_') . " AND\n"
|
. " `flock` = " . $cnx->quote('_mutex_') . " AND\n"
|
||||||
. " TIMESTAMPDIFF(SECOND, `published`, NOW()) > 60";
|
. " TIMESTAMPDIFF(SECOND, `published`, NOW()) > 60";
|
||||||
|
|
||||||
if ($cnx->exec($sql) > 0) {
|
$cnx->exec($sql);
|
||||||
// affected rows is 1 since by definition this key is unique
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! old mutex for %s.%s deleted !!! SHOULD NOT HAPPEN !!!", $databoxId, $recordId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
// here something went very wrong, like sql death
|
// here something went very wrong, like sql death
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED while trying to delete old mutex for %s.%s because (%s) !!! SHOULD NOT HAPPEN !!!", $e->getMessage(), $databoxId, $recordId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return false; // we could choose to continue, but if we end up here... better to stop
|
return false; // we could choose to continue, but if we end up here... better to stop
|
||||||
}
|
}
|
||||||
@@ -309,12 +264,7 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
|
|
||||||
if(($a = $cnx->exec($sql)) === 1) {
|
if(($a = $cnx->exec($sql)) === 1) {
|
||||||
|
|
||||||
$mutexId = $cnx->lastInsertId();
|
return $cnx->lastInsertId();
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("getMutex tryout %s for %s.%s OK, returning mutex (id=%s)", $tryout, $databoxId, $recordId, $mutexId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $mutexId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception(sprintf("inserting mutex should return 1 row affected, got %s", $a));
|
throw new Exception(sprintf("inserting mutex should return 1 row affected, got %s", $a));
|
||||||
@@ -328,19 +278,11 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
if($tryout < 3) {
|
if($tryout < 3) {
|
||||||
$rnd = rand(10, 50) * 10; // 100 ms ... 500 ms with 10 ms steps
|
$rnd = rand(10, 50) * 10; // 100 ms ... 500 ms with 10 ms steps
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("getMutex retry in %d msec", $rnd)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
usleep($rnd * 1000);
|
usleep($rnd * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED getMutex for %s.%s because (%s)", $databoxId, $recordId, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,20 +308,12 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
|
|
||||||
$cnx->exec($sql);
|
$cnx->exec($sql);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("releaseMutex (id=%s) DONE", $recordMutexId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
if($tryout < 3) {
|
if($tryout < 3) {
|
||||||
$rnd = rand(10, 50) * 10; // 100 ms ... 500 ms with 10 ms steps
|
$rnd = rand(10, 50) * 10; // 100 ms ... 500 ms with 10 ms steps
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("releaseMutex (id=%s) retry in %d msec", $recordMutexId, $rnd)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
usleep($rnd * 1000);
|
usleep($rnd * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,9 +321,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
|
|
||||||
// Here we were not able to release a mutex (bad)
|
// Here we were not able to release a mutex (bad)
|
||||||
// The last chance will be later, when old mutex (60s) is deleted
|
// The last chance will be later, when old mutex (60s) is deleted
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED release mutex (id=%s) because (%s)", $recordMutexId, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -417,9 +348,6 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
|
|
||||||
if(($a = $cnx->exec($sql) )=== 1) {
|
if(($a = $cnx->exec($sql) )=== 1) {
|
||||||
// ok
|
// ok
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("job (id=%d) marked as finished", $workerRunningJobId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -427,17 +355,11 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
throw new Exception(sprintf("updating WorkerRunningJob should return 1 row affected, got %s", $a));
|
throw new Exception(sprintf("updating WorkerRunningJob should return 1 row affected, got %s", $a));
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("failed to mark job (id=%d) as finished (tryout %s, retry in 1 sec) because (%s)", $workerRunningJobId, $tryout, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
if($tryout < 2) {
|
if($tryout < 2) {
|
||||||
sleep(1); // retry in 1 sec
|
sleep(1); // retry in 1 sec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! FAILED to mark job (id=%d) as finished", $workerRunningJobId)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -525,16 +447,10 @@ class WorkerRunningJobRepository extends EntityRepository
|
|||||||
public function reconnect()
|
public function reconnect()
|
||||||
{
|
{
|
||||||
if($this->_em->getConnection()->ping() === false) {
|
if($this->_em->getConnection()->ping() === false) {
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!!! reconnect-ping returned false, calling \"connect()\".")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
$this->_em->getConnection()->close();
|
$this->_em->getConnection()->close();
|
||||||
$this->_em->getConnection()->connect();
|
$this->_em->getConnection()->connect();
|
||||||
}
|
}
|
||||||
if(!$this->getEntityManager()->isOpen()) {
|
if(!$this->getEntityManager()->isOpen()) {
|
||||||
file_put_contents(dirname(__FILE__) . '/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!!! entity manager closed, recreating.")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
$this->_em = $this->_em->create(
|
$this->_em = $this->_em->create(
|
||||||
$this->_em->getConnection(),
|
$this->_em->getConnection(),
|
||||||
$this->_em->getConfiguration(),
|
$this->_em->getConfiguration(),
|
||||||
|
@@ -153,10 +153,6 @@ class RecordSubscriber implements EventSubscriberInterface
|
|||||||
$databoxId = $event->getDataboxId();
|
$databoxId = $event->getDataboxId();
|
||||||
$recordIds = $event->getRecordIds();
|
$recordIds = $event->getRecordIds();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("handle RECORDS_WRITE_META for %s.[%s]", $databoxId, join(',', $recordIds))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
foreach ($recordIds as $recordId) {
|
foreach ($recordIds as $recordId) {
|
||||||
$mediaSubdefRepository = $this->getMediaSubdefRepository($databoxId);
|
$mediaSubdefRepository = $this->getMediaSubdefRepository($databoxId);
|
||||||
$mediaSubdefs = $mediaSubdefRepository->findByRecordIdsAndNames([$recordId]);
|
$mediaSubdefs = $mediaSubdefRepository->findByRecordIdsAndNames([$recordId]);
|
||||||
@@ -178,10 +174,6 @@ class RecordSubscriber implements EventSubscriberInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($subdef->is_physically_present()) {
|
if ($subdef->is_physically_present()) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("q-publish WRITE_METADATAS_TYPE for %s.%s.%s", $databoxId, $recordId, $subdef->get_name())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
|
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -217,12 +209,6 @@ class RecordSubscriber implements EventSubscriberInterface
|
|||||||
|
|
||||||
public function onSubdefinitionWritemeta(SubdefinitionWritemetaEvent $event)
|
public function onSubdefinitionWritemeta(SubdefinitionWritemetaEvent $event)
|
||||||
{
|
{
|
||||||
$record = $event->getRecord();
|
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("Event WorkerEvents::SUBDEFINITION_WRITE_META catched for %s.%s.%s", $record->getDataboxId(), $record->getRecordId(), $event->getSubdefName())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if ($event->getStatus() == SubdefinitionWritemetaEvent::FAILED) {
|
if ($event->getStatus() == SubdefinitionWritemetaEvent::FAILED) {
|
||||||
$payload = [
|
$payload = [
|
||||||
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
|
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
|
||||||
@@ -297,22 +283,7 @@ class RecordSubscriber implements EventSubscriberInterface
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("sending message MessagePublisher::WRITE_METADATAS_TYPE for %s.%s.%s ...", $databoxId, $recordId, $event->getSubdefName())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
|
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" ... message MessagePublisher::WRITE_METADATAS_TYPE sent for %s.%s.%s", $databoxId, $recordId, $event->getSubdefName())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("no MessagePublisher::WRITE_METADATAS_TYPE for %s.%s.%s because(isSubdefMetadataUpdateRequired=%d)", $databoxId, $recordId, $event->getSubdefName(), $this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name()))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,10 +65,6 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
$databoxId = $payload['databoxId'];
|
$databoxId = $payload['databoxId'];
|
||||||
$subdefName = $payload['subdefName'];
|
$subdefName = $payload['subdefName'];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("process SubdefCreation for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$databox = $this->findDataboxById($databoxId);
|
$databox = $this->findDataboxById($databoxId);
|
||||||
$record = $databox->get_record($recordId);
|
$record = $databox->get_record($recordId);
|
||||||
|
|
||||||
@@ -90,41 +86,21 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
],
|
],
|
||||||
MessagePublisher::SUBDEF_CREATION_TYPE
|
MessagePublisher::SUBDEF_CREATION_TYPE
|
||||||
);
|
);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("cannot CreateSubdef for %s.%s.%s, delayed", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// here we can work
|
// here we can work
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("ready to CreateSubdef for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->subdefGenerator->setLogger($this->logger);
|
$this->subdefGenerator->setLogger($this->logger);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->subdefGenerator->generateSubdefs($record, [$subdefName]);
|
$this->subdefGenerator->generateSubdefs($record, [$subdefName]);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("subdef generated for %s.%s.%s (?)", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$this->logger->error("Exception catched: " . $e->getMessage());
|
$this->logger->error("Exception catched: " . $e->getMessage());
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! subdef generation failed (ignored) for %s.%s.%s : %s", $databoxId, $recordId, $subdefName, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Throwable $e) {
|
catch (Throwable $e) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("subdef generation failed, retry delayed for %s.%s.%s : %s", $databoxId, $recordId, $subdefName, $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||||
$workerMessage = "Exception throwable catched when create subdef for the recordID: " .$recordId;
|
$workerMessage = "Exception throwable catched when create subdef for the recordID: " .$recordId;
|
||||||
|
|
||||||
@@ -143,10 +119,6 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("checking subdef file for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
// begin to check if the subdef is successfully generated
|
// begin to check if the subdef is successfully generated
|
||||||
$subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($subdefName);
|
$subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($subdefName);
|
||||||
$filePathToCheck = null;
|
$filePathToCheck = null;
|
||||||
@@ -158,11 +130,6 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
$filePathToCheck = $this->filesystem->generateSubdefPathname($record, $subdef, $filePathToCheck);
|
$filePathToCheck = $this->filesystem->generateSubdefPathname($record, $subdef, $filePathToCheck);
|
||||||
|
|
||||||
if (!$this->filesystem->exists($filePathToCheck)) {
|
if (!$this->filesystem->exists($filePathToCheck)) {
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("!!! subdef file missing, retry delayed for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||||
|
|
||||||
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionCreationFailure() */
|
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionCreationFailure() */
|
||||||
@@ -182,10 +149,6 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
|
|
||||||
// checking ended
|
// checking ended
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("subdef file exists, order to write meta for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
// order to write meta for the subdef if needed
|
// order to write meta for the subdef if needed
|
||||||
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionWritemeta() */
|
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionWritemeta() */
|
||||||
$this->dispatcher->dispatch(
|
$this->dispatcher->dispatch(
|
||||||
@@ -196,10 +159,6 @@ class SubdefCreationWorker implements WorkerInterface
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("Event WorkerEvents::SUBDEFINITION_WRITE_META posted for %s.%s.%s", $record->getDataboxId(), $record->getRecordId(), $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->subdefGenerator->setLogger($oldLogger);
|
$this->subdefGenerator->setLogger($oldLogger);
|
||||||
|
|
||||||
// update jeton when subdef is created
|
// update jeton when subdef is created
|
||||||
|
@@ -67,10 +67,6 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
$recordId = $payload['recordId'];
|
$recordId = $payload['recordId'];
|
||||||
$subdefName = $payload['subdefName'];
|
$subdefName = $payload['subdefName'];
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("process WriteMeta for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$MWG = $payload['MWG'] ?? false;
|
$MWG = $payload['MWG'] ?? false;
|
||||||
$clearDoc = $payload['clearDoc'] ?? false;
|
$clearDoc = $payload['clearDoc'] ?? false;
|
||||||
$databox = $this->findDataboxById($databoxId);
|
$databox = $this->findDataboxById($databoxId);
|
||||||
@@ -87,25 +83,14 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
],
|
],
|
||||||
MessagePublisher::WRITE_METADATAS_TYPE
|
MessagePublisher::WRITE_METADATAS_TYPE
|
||||||
);
|
);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("cannot WriteMeta for %s.%s.%s, delayed", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// here we can work
|
// here we can work
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("ready to WriteMeta for %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$record = $databox->get_record($recordId);
|
$record = $databox->get_record($recordId);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - recordid = %s", $record->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
if ($record->getMimeType() == 'image/svg+xml') {
|
if ($record->getMimeType() == 'image/svg+xml') {
|
||||||
|
|
||||||
$this->logger->error("Can't write meta on svg file!");
|
$this->logger->error("Can't write meta on svg file!");
|
||||||
@@ -119,17 +104,9 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
$this->repoWorker->reconnect();
|
$this->repoWorker->reconnect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - getsubdef %s", $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$subdef = $record->get_subdef($subdefName);
|
$subdef = $record->get_subdef($subdefName);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - %s", $e->getMessage())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$workerMessage = "Exception catched when try to get subdef " .$subdefName. " from DB for the recordID: " .$recordId;
|
$workerMessage = "Exception catched when try to get subdef " .$subdefName. " from DB for the recordID: " .$recordId;
|
||||||
$this->logger->error($workerMessage);
|
$this->logger->error($workerMessage);
|
||||||
|
|
||||||
@@ -150,10 +127,6 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$subdef->is_physically_present()) {
|
if (!$subdef->is_physically_present()) {
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - not present")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
$count = isset($payload['count']) ? $payload['count'] + 1 : 2 ;
|
||||||
|
|
||||||
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionWritemeta() */
|
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionWritemeta() */
|
||||||
@@ -265,10 +238,6 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - reset")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->writer->reset();
|
$this->writer->reset();
|
||||||
|
|
||||||
if ($MWG) {
|
if ($MWG) {
|
||||||
@@ -277,21 +246,12 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
|
|
||||||
$this->writer->erase($subdef->get_name() != 'document' || $clearDoc, true);
|
$this->writer->erase($subdef->get_name() != 'document' || $clearDoc, true);
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf(" - erased")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
// write meta in file
|
// write meta in file
|
||||||
try {
|
try {
|
||||||
$this->writer->write($subdef->getRealPath(), $metadata);
|
$this->writer->write($subdef->getRealPath(), $metadata);
|
||||||
|
|
||||||
$this->messagePublisher->pushLog(sprintf('metadatas written %s databoxname=%s databoxid=%d recordid=%d',
|
$this->messagePublisher->pushLog(sprintf('metadatas written %s databoxname=%s databoxid=%d recordid=%d',
|
||||||
$subdef->get_name(), $databox->get_viewname(), $databox->get_sbas_id(), $recordId), 'info');
|
$subdef->get_name(), $databox->get_viewname(), $databox->get_sbas_id(), $recordId), 'info');
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("meta written in %s.%s.%s", $databoxId, $recordId, $subdefName)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
|
|
||||||
@@ -304,10 +264,6 @@ class WriteMetadatasWorker implements WorkerInterface
|
|||||||
$stopInfo = $matches[0];
|
$stopInfo = $matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("meta NOT written in %s.%s.%s because (%s)\n Will %sretry", $databoxId, $recordId, $subdefName, $msg, ($stopInfo ? "not ":""))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$workerMessage = sprintf('meta NOT written for databoxId=%1$d - recordId=%2$d (%3$s) because "%4$s"',
|
$workerMessage = sprintf('meta NOT written for databoxId=%1$d - recordId=%2$d (%3$s) because "%4$s"',
|
||||||
$databox->get_sbas_id(),
|
$databox->get_sbas_id(),
|
||||||
$recordId,
|
$recordId,
|
||||||
|
@@ -1140,10 +1140,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function set_metadatas(array $metadatas, $force_readonly = false)
|
public function set_metadatas(array $metadatas, $force_readonly = false)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into set_metadatas for record %s.%s", $this->getDataboxId(), $this->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$databox_descriptionStructure = $this->getDatabox()->get_meta_structure();
|
$databox_descriptionStructure = $this->getDatabox()->get_meta_structure();
|
||||||
|
|
||||||
foreach ($metadatas as $param) {
|
foreach ($metadatas as $param) {
|
||||||
@@ -1168,16 +1164,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$this->write_metas();
|
$this->write_metas();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("dispatch event RecordEvents::METADATA_CHANGED for record %s.%s", $this->getDataboxId(), $this->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$this->dispatch(RecordEvents::METADATA_CHANGED, new MetadataChangedEvent($this));
|
$this->dispatch(RecordEvents::METADATA_CHANGED, new MetadataChangedEvent($this));
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("return from set_metadata for record %s.%s", $this->getDataboxId(), $this->getRecordId())
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1682,10 +1670,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public static function createFromFile(File $file, Application $app)
|
public static function createFromFile(File $file, Application $app)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into createFromFile")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$collection = $file->getCollection();
|
$collection = $file->getCollection();
|
||||||
|
|
||||||
$record = self::_create(
|
$record = self::_create(
|
||||||
@@ -1703,28 +1687,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$newname_tmp = $newname.".tmp";
|
$newname_tmp = $newname.".tmp";
|
||||||
|
|
||||||
clearstatcache(true, $file->getFile()->getRealPath());
|
clearstatcache(true, $file->getFile()->getRealPath());
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("copying \"%s\" (size=%s) to \"%s\"", $file->getFile()->getRealPath(), filesize($file->getFile()->getRealPath()), $pathhd . $newname_tmp)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$filesystem->copy($file->getFile()->getRealPath(), $pathhd . $newname_tmp);
|
$filesystem->copy($file->getFile()->getRealPath(), $pathhd . $newname_tmp);
|
||||||
|
|
||||||
clearstatcache(true, $pathhd . $newname_tmp);
|
clearstatcache(true, $pathhd . $newname_tmp);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("copied \"%s\" to \"%s\" (size=%s)", $file->getFile()->getRealPath(), $pathhd . $newname_tmp, filesize($pathhd . $newname_tmp))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("moving \"%s\" (size=%s) to \"%s\"", $pathhd . $newname_tmp, filesize($pathhd . $newname_tmp), $pathhd . $newname)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$filesystem->rename($pathhd . $newname_tmp, $pathhd . $newname);
|
$filesystem->rename($pathhd . $newname_tmp, $pathhd . $newname);
|
||||||
|
|
||||||
clearstatcache(true, $pathhd . $newname);
|
clearstatcache(true, $pathhd . $newname);
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("moved \"%s\"to \"%s\" (size=%s) ", $pathhd . $newname_tmp, $pathhd . $newname, filesize($pathhd . $newname))
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
|
|
||||||
$media = $app->getMediaFromUri($pathhd . $newname);
|
$media = $app->getMediaFromUri($pathhd . $newname);
|
||||||
media_subdef::create($app, $record, 'document', $media);
|
media_subdef::create($app, $record, 'document', $media);
|
||||||
@@ -1767,10 +1737,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
private static function _create(collection $collection, Application $app, File $file=null)
|
private static function _create(collection $collection, Application $app, File $file=null)
|
||||||
{
|
{
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("into _create")
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$databox = $collection->get_databox();
|
$databox = $collection->get_databox();
|
||||||
|
|
||||||
$sql = "INSERT INTO record"
|
$sql = "INSERT INTO record"
|
||||||
@@ -1793,10 +1759,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
$record_id = $connection->lastInsertId();
|
$record_id = $connection->lastInsertId();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("sql record::inserted %s", $record_id)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
$record = new self($app, $databox->get_sbas_id(), $record_id);
|
$record = new self($app, $databox->get_sbas_id(), $record_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1813,12 +1775,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
':final' => $collection->get_coll_id(),
|
':final' => $collection->get_coll_id(),
|
||||||
]);
|
]);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
file_put_contents(dirname(__FILE__).'/../../../logs/trace.txt', sprintf("%s [%s] : %s (%s); %s\n", (date('Y-m-d\TH:i:s')), getmypid(), __FILE__, __LINE__,
|
|
||||||
sprintf("sql log_docs::inserted add %s", $record_id)
|
|
||||||
), FILE_APPEND | LOCK_EX);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
$record = null;
|
$record = null;
|
||||||
|
Reference in New Issue
Block a user