Exemple #1
0
function execute_upgrade_file($folder, $installed_version)
{
    global $db, $page, $conf;
    // At first the config file
    $upgrade_path = BASEDIR . '/upgrade/' . $folder;
    new ConfUpdater(CONFIG_PATH, $upgrade_path);
    $upgrade_info = parse_ini_file($upgrade_path . '/upgrade.info', true);
    // dev version upgrade?
    if ($folder == Flyspray::base_version($installed_version)) {
        $type = 'develupgrade';
    } else {
        $type = 'defaultupgrade';
    }
    // Next a mix of XML schema files and PHP upgrade scripts
    if (!isset($upgrade_info[$type])) {
        die('#1 Bad upgrade.info file.');
    }
    ksort($upgrade_info[$type]);
    foreach ($upgrade_info[$type] as $file) {
        if (substr($file, -4) == '.php') {
            require_once $upgrade_path . '/' . $file;
        }
        if (substr($file, -4) == '.xml') {
            $schema = new adoSchema($db->dblink);
            $xml = file_get_contents($upgrade_path . '/' . $file);
            $xml = str_replace('<table name="', '<table name="' . $conf['database']['dbprefix'], $xml);
            $schema->ParseSchemaString($xml);
            $schema->ExecuteSchema(null, true);
        }
    }
    // Last but not least global prefs update
    if (isset($upgrade_info['fsprefs'])) {
        $sql = $db->Query('SELECT pref_name FROM {prefs}');
        $existing = $db->FetchCol($sql);
        // Add what is missing
        foreach ($upgrade_info['fsprefs'] as $name => $value) {
            if (!in_array($name, $existing)) {
                $db->Query('INSERT INTO {prefs} (pref_name, pref_value) VALUES (?, ?)', array($name, $value));
            }
        }
        // Delete what is too much
        foreach ($existing as $name) {
            if (!isset($upgrade_info['fsprefs'][$name])) {
                $db->Query('DELETE FROM {prefs} WHERE pref_name = ?', array($name));
            }
        }
    }
    $db->Query('UPDATE {prefs} SET pref_value = ? WHERE pref_name = ?', array(basename($upgrade_path), 'fs_ver'));
    $page->assign('done', true);
}
Exemple #2
0
    if (isset($_POST["taskid"])) {
        $_POST["task_id"] = $_POST["taskid"];
    }
}
if (isset($_REQUEST["task_id"])) {
    $_REQUEST["taskid"] = $_REQUEST["task_id"];
} else {
    if (isset($_REQUEST["taskid"])) {
        $_REQUEST["task_id"] = $_REQUEST["taskid"];
    }
}
$db = new Database();
$db->dbOpenFast($conf['database']);
$fs = new Flyspray();
// If version number of database and files do not match, run upgrader
if (Flyspray::base_version($fs->version) != Flyspray::base_version($fs->prefs['fs_ver'])) {
    Flyspray::Redirect('setup/upgrade.php');
}
if (is_readable(BASEDIR . '/setup/index.php') && strpos($fs->version, 'dev') === false) {
    die('<div style="text-align:center;padding:20px;font-family:sans-serif;font-size:16px;">
<p>If you are upgrading, please <a href="setup/upgrade.php"
style="
margin:2em;
background-color: white;
border: 1px solid #bbb;
border-radius: 4px;
box-shadow: 0 1px 1px #ddd;
color: #565656;
cursor: pointer;
display: inline-block;
font-family: sans-serif;
Exemple #3
0
$page->assign('short_version', UPGRADE_VERSION);
// ---------------------------------------------------------------------
// Now the hard work
// ---------------------------------------------------------------------
// Find out which upgrades need to be run
$folders = glob_compat(BASEDIR . '/upgrade/[0-9]*');
$folders = array_map('basename', $folders);
usort($folders, 'version_compare');
// start with lowest version
$done = true;
if (Post::val('upgrade')) {
    $db->supports('transactions') && $db->beginTransaction();
    foreach ($folders as $folder) {
        if (version_compare($installed_version, $folder, '<=')) {
            // example: we upgrade from 0.9.9(final) to 1.0. In this case we want to start at 0.9.9.2
            if (version_compare($installed_version, $folder, 'eq') && Flyspray::base_version($installed_version) == $installed_version) {
                continue;
            }
            $res = execute_upgrade_file($folder, $installed_version);
            // did everything work?
            if (PEAR::isError($res)) {
                $done = false;
                if ($db->inTransaction()) {
                    $db->rollback();
                }
                $page->assign('errormsg', $res->getMessage() . ": \n" . wordwrap($res->userinfo, 80));
                break;
            }
            $installed_version = $folder;
        }
    }