Skip to content
This repository
tree: c3dc7692d4
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 90 lines (75 sloc) 3.274 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
<?php
error_reporting(2147483647);

try {
/*
* If we are run from another directory, try to change the current
* working directory to a directory the script is in
*/
if (@!file_exists(getcwd() . '/' . basename($argv[0]))) {
chdir(dirname(__FILE__));
} # if

require_once "lib/SpotClassAutoload.php";
require_once "settings.php";

/*
* Make sure we are not run from the server, an db upgrade can take too much time and
* will easily be aborted by either a database, apache or browser timeout
*/
SpotCommandline::initialize(array('reset-groupmembership', 'reset-securitygroups', 'reset-filters'),
array('reset-groupmembership' => false, 'reset-securitygroups' => false, 'reset-filters' => false));
if (!SpotCommandline::isCommandline()) {
die("upgrade-db.php can only be run from the console, it cannot be run from the web browser");
} # if

echo "Updating schema..(" . $settings['db']['engine'] . ")" . PHP_EOL;

$spotUpgrader = new SpotUpgrader($settings['db']);
$spotUpgrader->database();
echo "Schema update done" . PHP_EOL;
echo "Updating settings" . PHP_EOL;
$spotUpgrader->settings($settings);
echo "Settings update done" . PHP_EOL;
$spotUpgrader->users($settings);
echo "Updating users" . PHP_EOL;
echo "Users' update done" . PHP_EOL;

/* If the user asked to reset group membership, reset all group memberships */
if (SpotCommandline::get('reset-securitygroups')) {
echo "Resetting security groups to their default settings" . PHP_EOL;
$spotUpgrader->resetSecurityGroups();
echo "Reset security groups to their default settings done" . PHP_EOL;
} # if


/*
* If the user asked to reset group membership, reset all group memberships.
*/
if (SpotCommandline::get('reset-groupmembership')) {
echo "Resetting users' group membeship to the default" . PHP_EOL;
$spotUpgrader->resetUserGroupMembership();
echo "Reset of users' group membership done" . PHP_EOL;
} # if

/*
* If the user asked to reset filters, do so
*/
if (SpotCommandline::get('reset-filters')) {
echo "Resetting users' filters to the default" . PHP_EOL;
$spotUpgrader->resetFilters();
echo "Reset of users' filters done" . PHP_EOL;
} # if

echo "Performing basic analysis of database tables" . PHP_EOL;
$spotUpgrader->analyze($settings);
echo "Basic database optimalisation done" . PHP_EOL;
}

catch(SpotwebCannotBeUpgradedToooldException $x) {
die("Your current Spotweb installation is too old to be upgraded to this current version of Spotweb. " . PHP_EOL .
"Please download an earlier version of Spotweb (https://github.com/spotweb/spotweb/zipball/" . $x->getMessage() . "), " . PHP_EOL .
"run upgrade-db.php using that version and then upgrade back to this version to run upgrade-db.php once more.");
} # SpotwebCannotBeUpgradedToooldException

catch(InvalidOwnSettingsSettingException $x) {
echo "There is an error in your ownsettings.php" . PHP_EOL . PHP_EOL;
echo $x->getMessage() . PHP_EOL;
} # InvalidOwnSettingsSettingException

catch(Exception $x) {
echo PHP_EOL . PHP_EOL;
echo 'SpotWeb crashed' . PHP_EOL . PHP_EOL;
echo "Database schema of settings upgrade mislukt:" . PHP_EOL;
echo " " . $x->getMessage() . PHP_EOL;
echo PHP_EOL . PHP_EOL;
echo $x->getTraceAsString();
die(1);
} # catch

Something went wrong with that request. Please try again.