-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupgrade_packages.php
More file actions
123 lines (107 loc) · 3.61 KB
/
upgrade_packages.php
File metadata and controls
123 lines (107 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* @version $Header$
* @package install
* @subpackage upgrade
*/
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
$gBitSmarty->assign( 'next_step',$step );
$config_file = empty($_SERVER['CONFIG_INC']) ? '../config/kernel/config_inc.php' : $_SERVER['CONFIG_INC'];
// set the maximum execution time to very high
ini_set( "max_execution_time", "86400" );
/**
* required setup
*/
include_once( $config_file ); // relative, but we know we are in the installer here...
$gBitInstaller->scanPackages( 'admin/upgrade_inc.php' );
// get some nice R1 to R2 specific upgrade info on the screen - should keep users happy...
if( !empty( $_SESSION['upgrade_r1'] ) ) {
if( $rs = $gBitSystem->mDb->query( "SELECT `name` ,`value` FROM `" . BIT_DB_PREFIX . "tiki_preferences`" ) ) {
while( $row = $rs->fetchRow() ) {
$oldPrefs[$row['name']] = $row['value'];
}
}
foreach( array_keys( $gBitSystem->mPackages ) as $package ) {
if( @$oldPrefs['package_'.$package] == 'y' ) {
$upgrading[] = $package;
}
}
asort( $upgrading );
$gBitSmarty->assign( 'upgrading', $upgrading );
}
$upgradePath = array (
'TikiWiki 1.8' => array(
'TIKIWIKI18' => 'BONNIE',
'BONNIE' => 'BWR1',
'BWR1' => 'BWR2',
),
'TikiWiki 1.9' => array(
'TIKIWIKI19' => 'TIKIWIKI18',
'TIKIWIKI18' => 'BONNIE',
'BONNIE' => 'BWR1',
'BWR1' => 'BWR2',
),
'BWR0' => array(
'BONNIE' => 'BWR1',
'BWR1' => 'BWR2',
),
'BWR1' => array(
'BWR1' => 'BWR2',
),
);
$gBitSmarty->assign( 'upgradeFrom', $gUpgradeFrom );
$gBitSmarty->assign( 'upgradeTo', $gUpgradeTo );
$upPackages = array();
if( !empty( $_REQUEST['upgrade'] ) ) {
if( isset( $upgradePath[$_REQUEST['upgrade_from']] ) ) {
if( !empty( $gDebug ) || !empty( $_REQUEST['debug'] ) ) {
$gBitInstaller->mDb->debug();
}
foreach( $upgradePath[$_REQUEST['upgrade_from']] as $from=>$to ) {
global $gUpgradeFrom, $gUpgradeTo;
$gUpgradeFrom = $from;
$gUpgradeTo = $to;
$gBitInstaller->scanPackages( 'admin/upgrade_inc.php', FALSE );
$firstPackages = array_flip( array( 'kernel', 'users', 'categories', 'liberty', 'wiki', 'blogs' ) );
$secondPackages = array_flip( $upgrading );
// upgrade the ones that are order critical first
foreach( array_keys( $firstPackages ) as $package ) {
$gBitInstaller->upgradePackage( $package );
if( isset( $secondPackages[$package] ) ) {
unset( $secondPackages[$package] );
}
array_push( $upPackages, $package );
}
// upgrade remaining packages
foreach( array_keys( $secondPackages ) as $package ) {
$gBitInstaller->upgradePackage( $package );
array_push( $upPackages, $package );
}
unset( $gBitInstaller->mUpgrades );
}
// If server supports InnoDB for MySql and selected for use
// we traverse all tables in db after upgrade and change engine if needed
if( isset( $_SESSION['use_innodb'] ) && $_SESSION['use_innodb'] == TRUE ) {
$rs = $gBitInstaller->mDb->Execute("SHOW TABLE STATUS");
while ( !$rs->EOF) {
$row = $rs->GetRowAssoc(false);
switch( isset( $row['Engine'] ) ? strtoupper( $row['Engine'] ) : strtoupper( $row['Type'] )) {
case 'INNODB':
case 'INNOBASE':
break;
default:
$gBitInstaller->mDb->Execute("ALTER TABLE " . $row['Name'] . " ENGINE = INNODB");
break;
}
$rs->MoveNext();
}
$rs->Close();
}
}
$gBitSmarty->assign( 'package_list', $upPackages );
$app = '_done';
$gBitSmarty->assign( 'next_step',$step + 1 );
}
?>