Fix document substitution

This commit is contained in:
Thibaud Fabre
2016-11-24 17:21:11 +01:00
parent 97e08d91f4
commit d00d674cdf
6 changed files with 13 additions and 2 deletions

View File

@@ -537,6 +537,7 @@ class Application extends SilexApplication
$this['root.path'] = realpath(__DIR__ . '/../../..'); $this['root.path'] = realpath(__DIR__ . '/../../..');
// temporary resources default path such as download zip, quarantined documents etc .. // temporary resources default path such as download zip, quarantined documents etc ..
$this['tmp.path'] = getenv('PHRASEANET_TMP') ?: $this['root.path'].'/tmp'; $this['tmp.path'] = getenv('PHRASEANET_TMP') ?: $this['root.path'].'/tmp';
// plugin path // plugin path
$this['plugin.path'] = $this['root.path'].'/plugins'; $this['plugin.path'] = $this['root.path'].'/plugins';
// thumbnails path // thumbnails path

View File

@@ -46,8 +46,10 @@ class TaskManagerController extends Controller
$this->getDispatcher()->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) { $this->getDispatcher()->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) {
$process = new Process($cmdLine); $process = new Process($cmdLine);
$process->setTimeout(0); $process->setTimeout(0);
$process->disableOutput(); $process->disableOutput();
set_time_limit(0); set_time_limit(0);
ignore_user_abort(true); ignore_user_abort(true);
@@ -65,6 +67,7 @@ class TaskManagerController extends Controller
$info = $this->getLiveInformationRequest(); $info = $this->getLiveInformationRequest();
$data = $info->getManager(); $data = $info->getManager();
if (null !== $pid = $data['process-id']) { if (null !== $pid = $data['process-id']) {
if (substr(php_uname(), 0, 7) == "Windows"){ if (substr(php_uname(), 0, 7) == "Windows"){
exec(sprintf('TaskKill /PID %d', $pid)); exec(sprintf('TaskKill /PID %d', $pid));

View File

@@ -186,8 +186,10 @@ class ToolsController extends Controller
try { try {
$tempoDir = tempnam(sys_get_temp_dir(), 'substit'); $tempoDir = tempnam(sys_get_temp_dir(), 'substit');
unlink($tempoDir); unlink($tempoDir);
mkdir($tempoDir); mkdir($tempoDir);
$tempoFile = $tempoDir . DIRECTORY_SEPARATOR . $fileName; $tempoFile = $tempoDir . DIRECTORY_SEPARATOR . $fileName;
if (false === rename($file->getPathname(), $tempoFile)) { if (false === rename($file->getPathname(), $tempoFile)) {

View File

@@ -115,6 +115,7 @@ class FilesystemService
* @param \databox $databox * @param \databox $databox
* @param string $source * @param string $source
* @param string $filename * @param string $filename
* @return string
*/ */
public function writeMediaSourceFile(\databox $databox, $source, $filename) public function writeMediaSourceFile(\databox $databox, $source, $filename)
{ {
@@ -122,6 +123,8 @@ class FilesystemService
$this->filesystem->copy($source, $realPath, true); $this->filesystem->copy($source, $realPath, true);
$this->filesystem->chmod($realPath, 0760); $this->filesystem->chmod($realPath, 0760);
return $realPath;
} }
/** /**

View File

@@ -67,9 +67,9 @@ class SubdefSubstituer
$source = $file->getRealPath(); $source = $file->getRealPath();
$target = $this->fs->generateDocumentFilename($record, $file); $target = $this->fs->generateDocumentFilename($record, $file);
$this->fs->writeMediaSourceFile($record->getDatabox(), $source, $target); $target = $this->fs->writeMediaSourceFile($record->getDatabox(), $source, $target);
$media = $this->mediavorus->guess($source); $media = $this->mediavorus->guess($target);
$this->createMediaSubdef($record, 'document', $media); $this->createMediaSubdef($record, 'document', $media);

View File

@@ -656,10 +656,12 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$params['height'] = $media->getHeight(); $params['height'] = $media->getHeight();
} }
/** @var callable $factoryProvider */
$factoryProvider = $app['provider.factory.media_subdef']; $factoryProvider = $app['provider.factory.media_subdef'];
$factory = $factoryProvider($record->getDataboxId()); $factory = $factoryProvider($record->getDataboxId());
$subdef = $factory($params); $subdef = $factory($params);
Assertion::isInstanceOf($subdef, \media_subdef::class); Assertion::isInstanceOf($subdef, \media_subdef::class);
$repository = self::getMediaSubdefRepository($app, $record->getDataboxId()); $repository = self::getMediaSubdefRepository($app, $record->getDataboxId());