diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index dea7992be8..c194068aa7 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -537,6 +537,7 @@ class Application extends SilexApplication $this['root.path'] = realpath(__DIR__ . '/../../..'); // temporary resources default path such as download zip, quarantined documents etc .. $this['tmp.path'] = getenv('PHRASEANET_TMP') ?: $this['root.path'].'/tmp'; + // plugin path $this['plugin.path'] = $this['root.path'].'/plugins'; // thumbnails path diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php index 0fd26968da..086119ec0b 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManagerController.php @@ -46,8 +46,10 @@ class TaskManagerController extends Controller $this->getDispatcher()->addListener(KernelEvents::TERMINATE, function () use ($cmdLine) { $process = new Process($cmdLine); + $process->setTimeout(0); $process->disableOutput(); + set_time_limit(0); ignore_user_abort(true); @@ -65,6 +67,7 @@ class TaskManagerController extends Controller $info = $this->getLiveInformationRequest(); $data = $info->getManager(); + if (null !== $pid = $data['process-id']) { if (substr(php_uname(), 0, 7) == "Windows"){ exec(sprintf('TaskKill /PID %d', $pid)); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 556d3d8c3a..2c037b9c00 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -186,8 +186,10 @@ class ToolsController extends Controller try { $tempoDir = tempnam(sys_get_temp_dir(), 'substit'); + unlink($tempoDir); mkdir($tempoDir); + $tempoFile = $tempoDir . DIRECTORY_SEPARATOR . $fileName; if (false === rename($file->getPathname(), $tempoFile)) { diff --git a/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php b/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php index bbe1c32ab9..9d5e75822d 100644 --- a/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php +++ b/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php @@ -115,6 +115,7 @@ class FilesystemService * @param \databox $databox * @param string $source * @param string $filename + * @return string */ public function writeMediaSourceFile(\databox $databox, $source, $filename) { @@ -122,6 +123,8 @@ class FilesystemService $this->filesystem->copy($source, $realPath, true); $this->filesystem->chmod($realPath, 0760); + + return $realPath; } /** diff --git a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php index 6333ba4fd1..3bbdc2666d 100644 --- a/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php +++ b/lib/Alchemy/Phrasea/Media/SubdefSubstituer.php @@ -67,9 +67,9 @@ class SubdefSubstituer $source = $file->getRealPath(); $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); diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index ed9cf0ffe6..339efac9d1 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -656,10 +656,12 @@ class media_subdef extends media_abstract implements cache_cacheableInterface $params['height'] = $media->getHeight(); } + /** @var callable $factoryProvider */ $factoryProvider = $app['provider.factory.media_subdef']; $factory = $factoryProvider($record->getDataboxId()); $subdef = $factory($params); + Assertion::isInstanceOf($subdef, \media_subdef::class); $repository = self::getMediaSubdefRepository($app, $record->getDataboxId());