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 278 ; Identify location of kt-backup for database backups.
279 279 ;backupDirectory=c:/kt-backups
280 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 31 */
32 32  
33 33 session_start();
34   -require_once('../config/dmsDefaults.php');
  34 +require_once(KT_DIR . '/config/dmsDefaults.php');
35 35 require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
36 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 45 class KTAPI_FolderItem
44 46 {
... ...
setup/upgrade.php
... ... @@ -295,10 +295,7 @@ function loginFailed($message)
295 295 }
296 296  
297 297 function resolveMysqlDir()
298   -{
299   -
300   -
301   -
  298 +{
302 299 // possibly detect existing installations:
303 300  
304 301 if (OS_UNIX)
... ... @@ -310,15 +307,18 @@ function resolveMysqlDir()
310 307 {
311 308 $dirs = explode(';', $_SERVER['PATH']);
312 309 $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin';
  310 + $dirs[] = 'c:/program files/ktdms/mysql/bin';
313 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 320 $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
321   - }
  321 + }
322 322  
323 323 foreach($dirs as $dir)
324 324 {
... ... @@ -435,7 +435,7 @@ function resolveTempDir()
435 435 $dir='c:/kt-db-backup';
436 436 }
437 437 $oKTConfig =& KTConfig::getSingleton();
438   - $dir = $oKTConfig->get('backups/backupDirectory',$dir);
  438 + $dir = $oKTConfig->get('backup/backupDirectory',$dir);
439 439  
440 440 if (!is_dir($dir))
441 441 {
... ... @@ -496,7 +496,7 @@ Your mysql installation has been resolved. Manually, you would do the following:
496 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 500 <P>
501 501 You can continue to do the backup manually using the following process:
502 502 <P>
... ... @@ -638,7 +638,7 @@ Manually, you would do the following to restore the backup:
638 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 642 <P>
643 643 You can continue to do the restore manually using the following command(s):
644 644 <P>
... ... @@ -718,7 +718,7 @@ function backupDone()
718 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 722 <P>
723 723 If you need to restore from this backup, you should be able to use the following statements:
724 724 <P>
... ... @@ -861,6 +861,11 @@ function backup()
861 861 $dir=resolveTempDir();
862 862 $_SESSION['backupFile'] = $stmt['target'];
863 863  
  864 + if (OS_UNIX)
  865 + {
  866 + chmod($stmt['target'],0600);
  867 + }
  868 +
864 869 if (is_file($stmt['target']) && filesize($stmt['target']) > 0)
865 870 {
866 871 $_SESSION['backupStatus'] = true;
... ...
tests/api/authentication.php
... ... @@ -16,6 +16,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase
16 16 $this->assertTrue(is_a($session,'KTAPI_UserSession'));
17 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 24 $session->logout();
20 25 $this->assertFalse($session->is_active());
21 26 }
... ... @@ -27,7 +32,7 @@ class APIAuthenticationTestCase extends KTUnitTestCase
27 32 $session = $ktapi->start_system_session();
28 33 $this->assertTrue(is_a($session,'KTAPI_SystemSession'));
29 34 $this->assertTrue($session->is_active());
30   -
  35 +
31 36 $session->logout();
32 37 $this->assertFalse($session->is_active());
33 38 }
... ... @@ -40,6 +45,11 @@ class APIAuthenticationTestCase extends KTUnitTestCase
40 45 $this->assertTrue(is_a($session,'KTAPI_AnonymousSession'));
41 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 53 $session->logout();
44 54 $this->assertFalse($session->is_active());
45 55 }
... ...