From 050c3ea22e9e3c0ed74e22f0512eb9269afa3b42 Mon Sep 17 00:00:00 2001 From: Mark Noble Date: Tue, 11 Jun 2024 15:05:13 -0600 Subject: [PATCH] Update import script to ignore sandbox mode if not available --- code/web/cron/importAspenBackup.php | 13 ++++++++++++- code/web/release_notes/24.05.02.MD | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/web/cron/importAspenBackup.php b/code/web/cron/importAspenBackup.php index 6faeffb854..67c0f9f262 100644 --- a/code/web/cron/importAspenBackup.php +++ b/code/web/cron/importAspenBackup.php @@ -21,8 +21,19 @@ if ($exportFile != '.' && $exportFile != '..' && is_file($sqlBackupDir . $exportFile)) { /** @noinspection PhpStrFunctionsInspection */ if (strpos($exportFile, ".sql") > 0 && strpos($exportFile, 'mysql') === false) { + // Trimming the first two lines of the file + $filePath = $sqlBackupDir . $exportFile; + $fhnd = fopen($filePath, 'r'); + $line = fgets($fhnd); + fclose($fhnd); + echo("Importing $exportFile\n"); - $importCommand = "mysql -u$dbUser -p$dbPassword -h$dbHost -P$dbPort $dbName < $sqlBackupDir$exportFile"; + if (strpos($line, "/*!999999\- enable the sandbox mode") === 0){ + $importCommand = "mysql -u$dbUser -p$dbPassword -h$dbHost -P$dbPort -D $dbName --force < $sqlBackupDir$exportFile"; + }else{ + $importCommand = "mysql -u$dbUser -p$dbPassword -h$dbHost -P$dbPort $dbName < $sqlBackupDir$exportFile "; + } + $results = []; exec($importCommand, $results); echo(implode("\n", $results)); diff --git a/code/web/release_notes/24.05.02.MD b/code/web/release_notes/24.05.02.MD index 62bcb66a78..837cb85b94 100644 --- a/code/web/release_notes/24.05.02.MD +++ b/code/web/release_notes/24.05.02.MD @@ -6,7 +6,10 @@ - Correct indexing Polaris Items when new items are found that have not been indexed previously. (*MDN*) ### Symphony Updates -- Immediately delete MARC files after they have been processed. (Ticket 128804) (*MDN*) +- Immediately delete MARC files after they have been processed. (Ticket 128804) (*MDN*) + +### Other Updates +- Update import script to ignore sandbox mode if not available. (*MDN*) ## This release includes code contributions from - ByWater Solutions