Commit 945a4790e2aad98142e67f15fab43a4627111e1f

Authored by Jarrett Jordaan
1 parent 3cb76963

KTC-881: Added mysql socket to database dump command.

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
setup/migrate/steps/migrateDatabase.php 100644 → 100755
@@ -122,6 +122,7 @@ class migrateDatabase extends Step @@ -122,6 +122,7 @@ class migrateDatabase extends Step
122 $dbSettings = $installation['dbSettings']; 122 $dbSettings = $installation['dbSettings'];
123 $location = $installation['location']; 123 $location = $installation['location'];
124 $port = $this->util->getPort($location); 124 $port = $this->util->getPort($location);
  125 + $socket = $this->getSocket($location);
125 $tmpFolder = $this->resolveTempDir(); 126 $tmpFolder = $this->resolveTempDir();
126 if(WINDOWS_OS) { 127 if(WINDOWS_OS) {
127 $termOrBash = "command prompt window"; 128 $termOrBash = "command prompt window";
@@ -143,7 +144,11 @@ class migrateDatabase extends Step @@ -143,7 +144,11 @@ class migrateDatabase extends Step
143 $dbName = $dbSettings['dbName']; 144 $dbName = $dbSettings['dbName'];
144 if(!$manual) { // Try to export database 145 if(!$manual) { // Try to export database
145 $sqlFile = $tmpFolder."/kt-backup-$date.sql"; 146 $sqlFile = $tmpFolder."/kt-backup-$date.sql";
146 - $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; 147 + if($socket != "")
  148 + $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.' --socket="'.$socket.'" '.$dbName.' > '.$sqlFile;
  149 + else
  150 + $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
  151 + echo $cmd;
147 $response = $this->util->pexec($cmd); 152 $response = $this->util->pexec($cmd);
148 } 153 }
149 if(file_exists($sqlFile)) { 154 if(file_exists($sqlFile)) {
@@ -162,7 +167,10 @@ class migrateDatabase extends Step @@ -162,7 +167,10 @@ class migrateDatabase extends Step
162 } else { 167 } else {
163 $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions 168 $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
164 } 169 }
165 - $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; 170 + if($socket != "")
  171 + $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.' --socket="'.$socket.'" '.$dbName.' > '.$sqlFile;
  172 + else
  173 + $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
166 $this->error[]['error'] = "The KnowledgeTree Setup Wizard was unable to connect to your KnowledgeTree 3.6.1 database."; 174 $this->error[]['error'] = "The KnowledgeTree Setup Wizard was unable to connect to your KnowledgeTree 3.6.1 database.";
167 $this->error[]['msg'] = "Ensure that your KnowledgeTree Mysql service is running."; 175 $this->error[]['msg'] = "Ensure that your KnowledgeTree Mysql service is running.";
168 $this->error[]['cmd'] = "Click <b>Next</b> after resolving the above errors."; 176 $this->error[]['cmd'] = "Click <b>Next</b> after resolving the above errors.";
@@ -269,5 +277,27 @@ class migrateDatabase extends Step @@ -269,5 +277,27 @@ class migrateDatabase extends Step
269 $this->temp_variables['dumpLocation'] = $this->sqlDumpFile; 277 $this->temp_variables['dumpLocation'] = $this->sqlDumpFile;
270 } 278 }
271 279
  280 + /**
  281 + * Return socket of the old installation
  282 + *
  283 + * @param location
  284 + * @return string
  285 + */
  286 + public function getSocket($location) {
  287 + if(WINDOWS_OS) {
  288 + $myIni = "my.ini";
  289 + } else {
  290 + $myIni = "my.cnf";
  291 + }
  292 + $dbConfigPath = $location.DS."mysql".DS."$myIni";
  293 +
  294 + if(file_exists($dbConfigPath)) {
  295 + $this->util->iniUtilities->load($dbConfigPath);
  296 + $dbSettings = $this->util->iniUtilities->getSection('mysqladmin');
  297 + return $dbSettings['socket'];
  298 + }
  299 +
  300 + return '';
  301 + }
272 } 302 }
273 -?>  
274 \ No newline at end of file 303 \ No newline at end of file
  304 +?>