Commit b2d61b78d255e05fa95e42a61f3d4163b16be5fd

Authored by kevin_fourie
1 parent 0c251ac7

Merged in from DEV trunk...

KTS-1715
"Add DB backup step to upgrade process"
Fixed. Upgrade not possible if mysql directory not resolvable.

Reviewed By: Kevin Fourie

KTS-2122
"Cannot restore a backup done in Commercial 3.3.7, commercial 3.4 looks for the back in a different directory"
Fixed. Can now specify backup/mysqlDirectory to find mysqldump. Also, backups must be located in default or backup/backupDirectory.

Reviewed By: Kevin Fourie

KTS-2115
"create unit tests for ktapi"
Fixed. Added a test for using existing sessions.

Reviewed By: Kevin Fourie

KTS-2115
"create unit tests for ktapi"
Fixed. Added a test for using existing sessions.

Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@6831 c91229c3-7414-0410-bfa2-8a42b809f60b
config/config.ini
@@ -278,3 +278,6 @@ safemode = on @@ -278,3 +278,6 @@ safemode = on
278 ; Identify location of kt-backup for database backups. 278 ; Identify location of kt-backup for database backups.
279 ;backupDirectory=c:/kt-backups 279 ;backupDirectory=c:/kt-backups
280 ;backupDirectory=/tmp/kt-backups 280 ;backupDirectory=/tmp/kt-backups
  281 +
  282 +; Identify the location of the mysql.exe and mysqldump.exe
  283 +;mysqlDirectory=c:/program files/ktdms/mysql/bin
ktapi/ktapi.inc.php
@@ -31,14 +31,16 @@ @@ -31,14 +31,16 @@
31 */ 31 */
32 32
33 session_start(); 33 session_start();
34 -require_once('../config/dmsDefaults.php'); 34 +require_once(KT_DIR . '/config/dmsDefaults.php');
35 require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); 35 require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
36 require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); 36 require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php');
37 37
38 -require_once('KTAPIConstants.inc.php');  
39 -require_once('KTAPISession.inc.php');  
40 -require_once('KTAPIFolder.inc.php');  
41 -require_once('KTAPIDocument.inc.php'); 38 +define('KTAPI_DIR',KT_DIR . '/ktapi');
  39 +
  40 +require_once(KTAPI_DIR .'/KTAPIConstants.inc.php');
  41 +require_once(KTAPI_DIR .'/KTAPISession.inc.php');
  42 +require_once(KTAPI_DIR .'/KTAPIFolder.inc.php');
  43 +require_once(KTAPI_DIR .'/KTAPIDocument.inc.php');
42 44
43 class KTAPI_FolderItem 45 class KTAPI_FolderItem
44 { 46 {
setup/upgrade.php
@@ -295,10 +295,7 @@ function loginFailed($message) @@ -295,10 +295,7 @@ function loginFailed($message)
295 } 295 }
296 296
297 function resolveMysqlDir() 297 function resolveMysqlDir()
298 -{  
299 -  
300 -  
301 - 298 +{
302 // possibly detect existing installations: 299 // possibly detect existing installations:
303 300
304 if (OS_UNIX) 301 if (OS_UNIX)
@@ -310,15 +307,18 @@ function resolveMysqlDir() @@ -310,15 +307,18 @@ function resolveMysqlDir()
310 { 307 {
311 $dirs = explode(';', $_SERVER['PATH']); 308 $dirs = explode(';', $_SERVER['PATH']);
312 $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; 309 $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin';
  310 + $dirs[] = 'c:/program files/ktdms/mysql/bin';
313 $mysqlname ='mysql.exe'; 311 $mysqlname ='mysql.exe';
314 } 312 }
315 313
  314 + $oKTConfig =& KTConfig::getSingleton();
  315 + $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
  316 + $dirs[] = $mysqldir;
316 317
317 -  
318 - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms')) 318 + if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false)
319 { 319 {
320 $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); 320 $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
321 - } 321 + }
322 322
323 foreach($dirs as $dir) 323 foreach($dirs as $dir)
324 { 324 {
@@ -435,7 +435,7 @@ function resolveTempDir() @@ -435,7 +435,7 @@ function resolveTempDir()
435 $dir='c:/kt-db-backup'; 435 $dir='c:/kt-db-backup';
436 } 436 }
437 $oKTConfig =& KTConfig::getSingleton(); 437 $oKTConfig =& KTConfig::getSingleton();
438 - $dir = $oKTConfig->get('backups/backupDirectory',$dir); 438 + $dir = $oKTConfig->get('backup/backupDirectory',$dir);
439 439
440 if (!is_dir($dir)) 440 if (!is_dir($dir))
441 { 441 {
@@ -496,7 +496,7 @@ Your mysql installation has been resolved. Manually, you would do the following: @@ -496,7 +496,7 @@ Your mysql installation has been resolved. Manually, you would do the following:
496 else 496 else
497 { 497 {
498 ?> 498 ?>
499 -It appears as though you are not using the stack installer, or are using a custom install. 499 +The mysql backup utility could not be found automatically. Either do a manual backup, or edit the config.ini and update the backup/mysqlDirectory entry.
500 <P> 500 <P>
501 You can continue to do the backup manually using the following process: 501 You can continue to do the backup manually using the following process:
502 <P> 502 <P>
@@ -638,7 +638,7 @@ Manually, you would do the following to restore the backup: @@ -638,7 +638,7 @@ Manually, you would do the following to restore the backup:
638 else 638 else
639 { 639 {
640 ?> 640 ?>
641 -It appears as though you are not using the stack installer, or are using a custom install. 641 +The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysqlDirectory entry.
642 <P> 642 <P>
643 You can continue to do the restore manually using the following command(s): 643 You can continue to do the restore manually using the following command(s):
644 <P> 644 <P>
@@ -718,7 +718,7 @@ function backupDone() @@ -718,7 +718,7 @@ function backupDone()
718 else 718 else
719 { 719 {
720 ?> 720 ?>
721 - It appears as though you are not using the stack installer, or are using a custom install. 721 + The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysqlDirectory entry.
722 <P> 722 <P>
723 If you need to restore from this backup, you should be able to use the following statements: 723 If you need to restore from this backup, you should be able to use the following statements:
724 <P> 724 <P>
@@ -861,6 +861,11 @@ function backup() @@ -861,6 +861,11 @@ function backup()
861 $dir=resolveTempDir(); 861 $dir=resolveTempDir();
862 $_SESSION['backupFile'] = $stmt['target']; 862 $_SESSION['backupFile'] = $stmt['target'];
863 863
  864 + if (OS_UNIX)
  865 + {
  866 + chmod($stmt['target'],0600);
  867 + }
  868 +
864 if (is_file($stmt['target']) && filesize($stmt['target']) > 0) 869 if (is_file($stmt['target']) && filesize($stmt['target']) > 0)
865 { 870 {
866 $_SESSION['backupStatus'] = true; 871 $_SESSION['backupStatus'] = true;
tests/api/authentication.php
@@ -16,6 +16,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase @@ -16,6 +16,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase
16 $this->assertTrue(is_a($session,'KTAPI_UserSession')); 16 $this->assertTrue(is_a($session,'KTAPI_UserSession'));
17 $this->assertTrue($session->is_active()); 17 $this->assertTrue($session->is_active());
18 18
  19 + $ktapi = new KTAPI();
  20 + $session = $ktapi->get_active_session($session->session);
  21 + $this->assertTrue(is_a($session,'KTAPI_UserSession'));
  22 +
  23 +
19 $session->logout(); 24 $session->logout();
20 $this->assertFalse($session->is_active()); 25 $this->assertFalse($session->is_active());
21 } 26 }
@@ -27,7 +32,7 @@ class APIAuthenticationTestCase extends KTUnitTestCase @@ -27,7 +32,7 @@ class APIAuthenticationTestCase extends KTUnitTestCase
27 $session = $ktapi->start_system_session(); 32 $session = $ktapi->start_system_session();
28 $this->assertTrue(is_a($session,'KTAPI_SystemSession')); 33 $this->assertTrue(is_a($session,'KTAPI_SystemSession'));
29 $this->assertTrue($session->is_active()); 34 $this->assertTrue($session->is_active());
30 - 35 +
31 $session->logout(); 36 $session->logout();
32 $this->assertFalse($session->is_active()); 37 $this->assertFalse($session->is_active());
33 } 38 }
@@ -40,6 +45,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase @@ -40,6 +45,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase
40 $this->assertTrue(is_a($session,'KTAPI_AnonymousSession')); 45 $this->assertTrue(is_a($session,'KTAPI_AnonymousSession'));
41 $this->assertTrue($session->is_active()); 46 $this->assertTrue($session->is_active());
42 47
  48 + $ktapi = new KTAPI();
  49 + $session = $ktapi->get_active_session($session->session);
  50 + $this->assertTrue(is_a($session,'KTAPI_AnonymousSession'));
  51 +
  52 +
43 $session->logout(); 53 $session->logout();
44 $this->assertFalse($session->is_active()); 54 $this->assertFalse($session->is_active());
45 } 55 }