diff --git a/CHANGELOG.md b/CHANGELOG.md index 20611082998bb499e60f21d8372695f1f6ed4235..1520a4cc6cd738db7968a53bbb86f3b7457df011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +4.0.3 +----- +- Amélioration du RunSQLProcess : petite désadhérance avec Oracle, nouveaux attributs dans RunSQLResult, correction d'un warning. + 4.0.2 (15/12/2021) ------------------ - [FIX] uploader cassé : FormElementManagerV3Polyfill est deprecated et inutilisé, remplacé par FormElementManager diff --git a/src/UnicaenApp/Process/ProcessResult.php b/src/UnicaenApp/Process/ProcessResult.php index 26328820ebcbf6c73c2af57a49cc6e94efbc7ce8..585869f232af74603e818920000a799bd17b78ff 100644 --- a/src/UnicaenApp/Process/ProcessResult.php +++ b/src/UnicaenApp/Process/ProcessResult.php @@ -68,7 +68,10 @@ abstract class ProcessResult implements ProcessResultInterface public function __destruct() { - fclose($this->logStream); + // Test ajouté pour éviter l'étrange "Warning: fclose(): supplied resource is not a valid stream resource" + if (is_resource($this->logStream)) { + fclose($this->logStream); + } } /** diff --git a/src/UnicaenApp/Service/SQL/RunSQLProcess.php b/src/UnicaenApp/Service/SQL/RunSQLProcess.php index a29587fe681667a58e37d0b2f5d6becce4e8492e..9f7a4d2dbcdfd57c0f4d2d9d996a85872244fc5e 100644 --- a/src/UnicaenApp/Service/SQL/RunSQLProcess.php +++ b/src/UnicaenApp/Service/SQL/RunSQLProcess.php @@ -4,15 +4,15 @@ namespace UnicaenApp\Service\SQL; use Doctrine\DBAL\Connection; use Exception; -use UnicaenApp\Exception\RuntimeException; use Laminas\Log\LoggerAwareTrait; use Laminas\Stdlib\Glob; +use UnicaenApp\Exception\RuntimeException; class RunSQLProcess { use LoggerAwareTrait; - const QUERIES_SPLIT_PATTERN = "#^/$#m"; + const QUERIES_SPLIT_PATTERN = "#^/$#m"; // oracle !! const LOG_FILE_EXT = '.log.sql'; const LOG_FILE_EXT_PATTERN = '.log.*.sql'; const LOG_FILE_EXT_TEMPLATE = '.log.%d.sql'; @@ -32,6 +32,11 @@ class RunSQLProcess */ private $connection; + /** + * @var string + */ + private $queriesSplitPattern = self::QUERIES_SPLIT_PATTERN; + /** * @var string[] */ @@ -75,6 +80,17 @@ class RunSQLProcess return $this; } + /** + * @param string $queriesSplitPattern + * @return self + */ + public function setQueriesSplitPattern($queriesSplitPattern) + { + $this->queriesSplitPattern = $queriesSplitPattern; + + return $this; + } + /** * Exécute dans la transaction courante toutes les instructions d'un script SQL. * @@ -126,7 +142,7 @@ class RunSQLProcess */ protected function extractQueriesFromScript() { - $parts = preg_split(self::QUERIES_SPLIT_PATTERN, file_get_contents($this->scriptPath)); + $parts = preg_split($this->queriesSplitPattern, file_get_contents($this->scriptPath)); $queries = array_filter(array_map('trim', $parts)); if (count($queries) === 0) { @@ -144,6 +160,8 @@ class RunSQLProcess private function executeQueries() { $result = new RunSQLResult(); + $result->setScriptPath($this->scriptPath); + $result->setLogFilePath($this->logFilePath); $result->attachLogger($this->logger); $result->setIsSuccess(true); diff --git a/src/UnicaenApp/Service/SQL/RunSQLResult.php b/src/UnicaenApp/Service/SQL/RunSQLResult.php index bee134521ed20d247d87ddda018a637dee20dd8e..d5ff5198da4fdb3ca51f8338ca9f5d8601b11f52 100644 --- a/src/UnicaenApp/Service/SQL/RunSQLResult.php +++ b/src/UnicaenApp/Service/SQL/RunSQLResult.php @@ -11,5 +11,49 @@ use UnicaenApp\Process\ProcessResult; */ class RunSQLResult extends ProcessResult { + /** + * @var string + */ + protected $scriptPath; + /** + * @var string + */ + protected $logFilePath; + + /** + * @return string + */ + public function getScriptPath() + { + return $this->scriptPath; + } + + /** + * @param string $scriptPath + * @return self + */ + public function setScriptPath($scriptPath) + { + $this->scriptPath = $scriptPath; + return $this; + } + + /** + * @return string + */ + public function getLogFilePath() + { + return $this->logFilePath; + } + + /** + * @param string $logFilePath + * @return self + */ + public function setLogFilePath($logFilePath) + { + $this->logFilePath = $logFilePath; + return $this; + } } \ No newline at end of file