PHRAS-3468 remove logs trace

This commit is contained in:
aynsix
2021-11-09 10:51:49 +03:00
parent 5b93a4b735
commit c12cefa028
13 changed files with 3 additions and 508 deletions

View File

@@ -34,10 +34,6 @@ class Sha256 extends AbstractChecker
*/
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 = [];
if (!empty($this->compareIgnoreCollections)) {
foreach ($this->compareIgnoreCollections as $collection) {
@@ -50,10 +46,6 @@ class Sha256 extends AbstractChecker
$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);
}

View File

@@ -33,10 +33,6 @@ class UUID extends AbstractChecker
*/
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 = [];
if (!empty($this->compareIgnoreCollections)) {
foreach ($this->compareIgnoreCollections as $collection) {
@@ -48,9 +44,6 @@ class UUID extends AbstractChecker
}
$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) {
// 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));
}
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);
}

View File

@@ -63,10 +63,6 @@ class File
*/
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->media = $media;
$this->collection = $collection;
@@ -93,15 +89,7 @@ class File
*/
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) {
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;
}
@@ -115,10 +103,6 @@ class File
];
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();
$uuid = null;
@@ -132,10 +116,6 @@ class File
if (Uuid::isValid($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;
}
}
@@ -143,19 +123,12 @@ class File
if (!$uuid && $generate) {
$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;
}
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);
$metadatas = new ExiftoolMetadataBag();
@@ -167,30 +140,14 @@ class File
$writer = $this->app['exiftool.writer'];
$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);
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) {
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
}
}
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;
}
@@ -229,30 +186,9 @@ class File
*/
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) {
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');
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;
}

View File

@@ -108,16 +108,9 @@ class Manager
*/
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);
// 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);
@@ -126,42 +119,24 @@ class Manager
$this->addMediaAttributes($file);
// 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_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);
$code = self::RECORD_CREATED;
} else {
// 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_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);
$code = self::LAZARET_CREATED;
}
// // 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);
if (is_callable($callable)) {
@@ -304,17 +279,8 @@ class Manager
*/
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);
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();
$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 */
$dispatcher = $this->app['dispatcher'];
$dispatcher->addListener(
RecordEvents::METADATA_CHANGED,
function (Event $event) {
// 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();
},
10
@@ -421,10 +380,6 @@ class Manager
*/
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();
$file->addAttribute(
new MetadataAttr(
@@ -477,10 +432,6 @@ class Manager
$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;
}

View File

@@ -117,10 +117,6 @@ class UploadController extends Controller
*/
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 = [
'success' => false,
'code' => null,
@@ -198,21 +194,12 @@ class UploadController extends Controller
$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);
$originalName = $file->getClientOriginalName();
}
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);
$collection = \collection::getByBaseId($this->app, $base_id);
@@ -241,15 +228,7 @@ class UploadController extends Controller
$elementCreated = null;
$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) {
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()) {
$reasons[] = $response->getMessage($this->app['translator']);
}
@@ -258,23 +237,10 @@ class UploadController extends Controller
$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);
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) {
$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) {
@@ -282,19 +248,10 @@ class UploadController extends Controller
}
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();
$element = 'record';
$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));
// try to create thumbnail from data URI
@@ -305,16 +262,8 @@ class UploadController extends Controller
$fileName = $this->getTemporaryFilesystem()->createTemporaryFile('base_64_thumb', null, "png");
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);
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->getDataboxLogger($elementCreated->getDatabox())
->log($elementCreated, \Session_Logger::EVENT_SUBSTITUTE, 'thumbnail', '');
@@ -327,10 +276,6 @@ class UploadController extends Controller
}
} else {
/** @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));
$id = $elementCreated->getId();
@@ -350,10 +295,6 @@ class UploadController extends Controller
$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);
// IE 7 and 8 does not correctly handle json response in file API
// lets send them an html content-type header

View File

@@ -111,9 +111,6 @@ class SubdefGenerator
$hd = $hd->getRealPath();
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 = [];
@@ -130,10 +127,6 @@ class SubdefGenerator
$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();
$this->logger->info(sprintf('Removed old file for %s', $subdefname));
$record->clearSubdefCache($subdefname);

View File

@@ -42,10 +42,6 @@ class PhraseanetMetadataSetter
*/
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();
$metadataPerField = $this->extractMetadataPerField($metaStructure, $metadataCollection);
@@ -92,10 +88,6 @@ class PhraseanetMetadataSetter
}
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()
* how : uncomment section
@@ -106,9 +98,6 @@ class PhraseanetMetadataSetter
RecordEvents::METADATA_CHANGED,
function () use ($record) {
// 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->dispatcher->dispatch(WorkerEvents::RECORDS_WRITE_META,
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
@@ -128,9 +117,6 @@ class PhraseanetMetadataSetter
*
*/
// 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,
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
@@ -138,13 +124,6 @@ class PhraseanetMetadataSetter
* 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);
}
}
/**

View File

@@ -129,10 +129,6 @@ class LazaretManipulator
{
$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 */
$lazaretFile = $this->repository->find($file_id);
@@ -147,21 +143,12 @@ class LazaretManipulator
$lazaretThumbFileName = $path .'/'.$lazaretFile->getThumbFilename();
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(
$lazaretFileName,
$lazaretFile->getCollection($this->app),
$this->app,
$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) {
// the file is not in tmp anymore ?
@@ -172,17 +159,9 @@ class LazaretManipulator
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 {
//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 */
$record = null;
$callBack = function ($element) use (&$record) {
@@ -197,17 +176,9 @@ class LazaretManipulator
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) {
//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();
$metadataBag = new Border\MetadataBag();
@@ -250,25 +221,14 @@ class LazaretManipulator
/* todo: better to to do only one set_metadatas ? */
$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);
$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);
// 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,
new RecordsWriteMetaEvent([$record->getRecordId()], $record->getDataboxId()));
@@ -291,10 +251,6 @@ class LazaretManipulator
// 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;
}

View File

@@ -86,15 +86,8 @@ class WorkerRunningJobRepository extends EntityRepository
$databoxId = $payload['databoxId'];
$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
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;
}
@@ -120,38 +113,19 @@ class WorkerRunningJobRepository extends EntityRepository
if ($stmt->execute() === true) {
$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();
if(!$row) {
// no job running : create or update (may return false) if error
$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();
}
catch (Exception $e) {
$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
$this->releaseMutex($recordMutexId);
@@ -199,9 +173,6 @@ class WorkerRunningJobRepository extends EntityRepository
if ($cnx->exec($sql) === 1) {
// went well, the row is inserted
$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 {
// row not inserted ?
@@ -218,10 +189,6 @@ class WorkerRunningJobRepository extends EntityRepository
if ($cnx->exec($sql) === 1) {
// went well, the row is updated
$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 {
// row not inserted ?
@@ -231,10 +198,6 @@ class WorkerRunningJobRepository extends EntityRepository
}
catch (Exception $e) {
// 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;
@@ -273,18 +236,10 @@ class WorkerRunningJobRepository extends EntityRepository
. " `flock` = " . $cnx->quote('_mutex_') . " AND\n"
. " TIMESTAMPDIFF(SECOND, `published`, NOW()) > 60";
if ($cnx->exec($sql) > 0) {
// 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);
}
$cnx->exec($sql);
}
catch(Exception $e) {
// 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
}
@@ -309,12 +264,7 @@ class WorkerRunningJobRepository extends EntityRepository
if(($a = $cnx->exec($sql)) === 1) {
$mutexId = $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;
return $cnx->lastInsertId();
}
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) {
$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);
}
}
}
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;
}
@@ -366,20 +308,12 @@ class WorkerRunningJobRepository extends EntityRepository
$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;
}
catch (Exception $e) {
if($tryout < 3) {
$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);
}
}
@@ -387,9 +321,6 @@ class WorkerRunningJobRepository extends EntityRepository
// Here we were not able to release a mutex (bad)
// 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) {
// 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;
}
@@ -427,17 +355,11 @@ class WorkerRunningJobRepository extends EntityRepository
throw new Exception(sprintf("updating WorkerRunningJob should return 1 row affected, got %s", $a));
}
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) {
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()
{
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()->connect();
}
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->getConnection(),
$this->_em->getConfiguration(),

View File

@@ -153,10 +153,6 @@ class RecordSubscriber implements EventSubscriberInterface
$databoxId = $event->getDataboxId();
$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) {
$mediaSubdefRepository = $this->getMediaSubdefRepository($databoxId);
$mediaSubdefs = $mediaSubdefRepository->findByRecordIdsAndNames([$recordId]);
@@ -178,10 +174,6 @@ class RecordSubscriber implements EventSubscriberInterface
];
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);
}
else {
@@ -217,12 +209,6 @@ class RecordSubscriber implements EventSubscriberInterface
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) {
$payload = [
'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);
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);
}
}

View File

@@ -65,10 +65,6 @@ class SubdefCreationWorker implements WorkerInterface
$databoxId = $payload['databoxId'];
$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);
$record = $databox->get_record($recordId);
@@ -90,41 +86,21 @@ class SubdefCreationWorker implements WorkerInterface
],
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 ;
}
// 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);
try {
$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) {
$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) {
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 ;
$workerMessage = "Exception throwable catched when create subdef for the recordID: " .$recordId;
@@ -143,10 +119,6 @@ class SubdefCreationWorker implements WorkerInterface
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
$subdef = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType())->getSubdef($subdefName);
$filePathToCheck = null;
@@ -158,11 +130,6 @@ class SubdefCreationWorker implements WorkerInterface
$filePathToCheck = $this->filesystem->generateSubdefPathname($record, $subdef, $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 ;
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionCreationFailure() */
@@ -182,10 +149,6 @@ class SubdefCreationWorker implements WorkerInterface
// 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
/** @uses \Alchemy\Phrasea\WorkerManager\Subscriber\RecordSubscriber::onSubdefinitionWritemeta() */
$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);
// update jeton when subdef is created

View File

@@ -67,10 +67,6 @@ class WriteMetadatasWorker implements WorkerInterface
$recordId = $payload['recordId'];
$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;
$clearDoc = $payload['clearDoc'] ?? false;
$databox = $this->findDataboxById($databoxId);
@@ -87,25 +83,14 @@ class WriteMetadatasWorker implements WorkerInterface
],
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 ;
}
// 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);
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') {
$this->logger->error("Can't write meta on svg file!");
@@ -119,17 +104,9 @@ class WriteMetadatasWorker implements WorkerInterface
$this->repoWorker->reconnect();
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);
}
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;
$this->logger->error($workerMessage);
@@ -150,10 +127,6 @@ class WriteMetadatasWorker implements WorkerInterface
}
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 ;
/** @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();
if ($MWG) {
@@ -277,21 +246,12 @@ class WriteMetadatasWorker implements WorkerInterface
$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
try {
$this->writer->write($subdef->getRealPath(), $metadata);
$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');
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) {
@@ -304,10 +264,6 @@ class WriteMetadatasWorker implements WorkerInterface
$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"',
$databox->get_sbas_id(),
$recordId,

View File

@@ -1140,10 +1140,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
*/
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();
foreach ($metadatas as $param) {
@@ -1168,16 +1164,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$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));
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;
}
@@ -1682,10 +1670,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
*/
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();
$record = self::_create(
@@ -1703,28 +1687,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$newname_tmp = $newname.".tmp";
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);
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);
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_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)
{
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();
$sql = "INSERT INTO record"
@@ -1793,10 +1759,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$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);
try {
@@ -1813,12 +1775,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
':final' => $collection->get_coll_id(),
]);
$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) {
$record = null;