#!/usr/bin/env php <?php /* Updating schema requires edits in the following files: 1. Update schema.sql for change. This should reflect the latest version of the schema. The last line should log the updated version (say x.y). 2. Create a module in /updates/schema-vx.y.inc.php containing code to update the schema from the previous version. 3. Edit this file (update.php) to include reference to that file in $updates array 3. Update the version in updateTo below to reflect x,y. */ if (!php_sapi_name() == 'cli') { die('This is a command line only script.'); } require_once dirname(__FILE__) . "/../globals/functions.php"; require_once dirname(__FILE__) . "/../globals/classes/DBUpdater.class.php"; // Load configuration require dirname(__FILE__) . "/../config/config.php"; try { // Start-up updater $updater = new DBUpdater($config['db']['server'], $config['db']['username'], $config['db']['password'], $config['db']['database']); $updates = array(include dirname(__FILE__) . "/updates/schema-v1.1.inc.php", include dirname(__FILE__) . "/updates/schema-v1.2.inc.php", include dirname(__FILE__) . "/updates/schema-v1.3.inc.php"); $updater->updateTo(new SchemaVersion(1, 3), $updates); } catch (Exception $e) { die($e->getMessage() . "\n"); }
/** * Delete plugin * * @param string name */ public static function uninstallPlugin($name) { self::getInstalledPlugins(); if (!array_key_exists($name, self::$plugins)) { return; } // No throw Logger::info('Uninstalling plugin "' . $name . '"'); $info = self::getPluginInfo($name); call_user_func($class . '::uninstall'); DBUpdater::removePluginModel($name); unset(self::$plugins[$name]); self::saveInstalledPluginsData(); }
$cacheFileName = KB_CACHEDIR . "/update/" . $lastPart[count($lastPart) - 1]; new FileCacher($hostFileName, $cacheFileName); break; } } } else { if (isset($_GET['db_apply_ref'])) { $db = $parser->getDBInfo(); foreach ($db as $piece) { //version number must be greater than current version, else do nothing if ($piece['version'] > $dbversion && $piece['version'] == $_GET['db_apply_ref']) { $hostFileName = $piece['url']; $lastPart = explode('/', $hostFileName); $cacheFileName = KB_CACHEDIR . "/update/" . $lastPart[count($lastPart) - 1]; //cachefile holds the stuff we want to import $update = new DBUpdater($cacheFileName); $update->runQueries(); Config::set('upd_dbVersion', $piece['version']); $qry = DBFactory::getDBQuery(true); $qry->execute("INSERT INTO `kb3_config` (cfg_site, cfg_key, cfg_value) " . "SELECT cfg_site, 'upd_dbVersion', '{$piece['version']}' FROM `kb3_config` " . "GROUP BY cfg_site ON DUPLICATE KEY UPDATE cfg_value = '{$piece['version']}';"); $dbversion = $piece['version']; break; } } } else { if (isset($_GET['code_dl_ref'])) { $code = $parser->getcodeInfo(); foreach ($code as $piece) { //version number must be greater than current version, else do nothing if ($piece['version'] > $codeversion && $piece['version'] == $_GET['code_dl_ref']) { if (!file_exists(getcwd() . "/update")) {
<?php /** * This file is part of the BaseProject project. * 2015 * Copyright (c) RENATER */ include dirname(__FILE__) . '/../../includes/core/init.php'; Logger::setProcess(ProcessTypes::UPGRADE); /** * Create/upgrade application's database */ set_error_handler(function ($no, $str, $file = '', $line = '') { if ($no == '2048') { return; } Logger::error('[' . $no . '] ' . $str . ' in ' . $file . ' at line ' . $line); }); try { DBUpdater::updateModel(); echo 'Everything went well' . "\n"; echo 'Database structure is up to date' . "\n"; } catch (Exception $e) { $uid = $e instanceof LoggingException ? $e->getUid() : 'no available uid'; die('Encountered exception : ' . $e->getMessage() . ', see logs for details (uid: ' . $uid . ') ...'); }