Commit 5c915816 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge "Bug 1215271: Show warning if db is newer than files"

parents e9cf7304 64f3d964
...@@ -337,6 +337,16 @@ if (get_config('installed')) { ...@@ -337,6 +337,16 @@ if (get_config('installed')) {
if ($upgradeavailable) { if ($upgradeavailable) {
ensure_upgrade_sanity(); ensure_upgrade_sanity();
} }
else if ($config->version < get_config('version')) {
if (get_config('productionmode')) {
throw new ConfigSanityException("Database version of Mahara $corerelease ($coreversion) is newer "
. "than files version $config->release ($config->version). "
. "Please make sure you have the correct Mahara files in place.");
}
else {
define('SITEOUTOFSYNC', 'core');
}
}
if ($upgradeavailable != get_config('siteclosedforupgrade')) { if ($upgradeavailable != get_config('siteclosedforupgrade')) {
set_config('siteclosedforupgrade', $upgradeavailable); set_config('siteclosedforupgrade', $upgradeavailable);
} }
......
...@@ -149,4 +149,5 @@ $string['wrongsessionhandle'] = 'The session save handler "%s" is not supported ...@@ -149,4 +149,5 @@ $string['wrongsessionhandle'] = 'The session save handler "%s" is not supported
$string['nomemcachedserver'] = 'The memcache server "%s" is not reachable. Please check the $cfg->memcacheservers value to make sure it is correct'; $string['nomemcachedserver'] = 'The memcache server "%s" is not reachable. Please check the $cfg->memcacheservers value to make sure it is correct';
$string['nophpextension'] = 'The PHP extension "%s" is not enabled. Please enable the extension and restart your webserver or choose a different session option.'; $string['nophpextension'] = 'The PHP extension "%s" is not enabled. Please enable the extension and restart your webserver or choose a different session option.';
$string['nomemcacheserversdefined'] = 'The session save handler "%s" has no related servers defined. Please set the $cfg->memcacheservers value, eg "localhost:11211"'; $string['nomemcacheserversdefined'] = 'The session save handler "%s" has no related servers defined. Please set the $cfg->memcacheservers value, eg "localhost:11211"';
$string['memcacheusememcached'] = 'The "memcache" session storage is obsolete. Please use "memcached"'; $string['memcacheusememcached'] = 'The "memcache" session storage is obsolete. Please use "memcached"';
\ No newline at end of file $string['siteoutofsyncfor'] = 'This site has database information newer than %s files indicate it should be.';
...@@ -54,6 +54,7 @@ function check_upgrades($name=null) { ...@@ -54,6 +54,7 @@ function check_upgrades($name=null) {
catch (Exception $e) { catch (Exception $e) {
$coreversion = 0; $coreversion = 0;
} }
$corerelease = get_config('release');
$core = new stdClass(); $core = new stdClass();
$core->to = $config->version; $core->to = $config->version;
$core->torelease = $config->release; $core->torelease = $config->release;
...@@ -81,7 +82,6 @@ function check_upgrades($name=null) { ...@@ -81,7 +82,6 @@ function check_upgrades($name=null) {
$installing = true; $installing = true;
} }
else if ($config->version > $coreversion) { else if ($config->version > $coreversion) {
$corerelease = get_config('release');
if (isset($config->minupgradefrom) && isset($config->minupgraderelease) if (isset($config->minupgradefrom) && isset($config->minupgraderelease)
&& $coreversion < $config->minupgradefrom) { && $coreversion < $config->minupgradefrom) {
throw new ConfigSanityException("Must upgrade to $config->minupgradefrom " throw new ConfigSanityException("Must upgrade to $config->minupgradefrom "
...@@ -93,6 +93,16 @@ function check_upgrades($name=null) { ...@@ -93,6 +93,16 @@ function check_upgrades($name=null) {
$core->from = $coreversion; $core->from = $coreversion;
$core->fromrelease = $corerelease; $core->fromrelease = $corerelease;
} }
else if ($config->version < $coreversion) {
if (get_config('productionmode')) {
throw new ConfigSanityException("Database version of Mahara $corerelease ($coreversion) is newer "
. "than files version $config->release ($config->version). "
. "Please make sure you have the correct Mahara files in place.");
}
else {
define('SITEOUTOFSYNC', 'core');
}
}
else { else {
// Core doesn't need to be upgraded. Remove it from the list! // Core doesn't need to be upgraded. Remove it from the list!
unset($toupgrade['core']); unset($toupgrade['core']);
...@@ -220,6 +230,11 @@ function check_upgrades($name=null) { ...@@ -220,6 +230,11 @@ function check_upgrades($name=null) {
$config = new StdClass; $config = new StdClass;
require(get_config('docroot') . $pluginpath . '/version.php'); require(get_config('docroot') . $pluginpath . '/version.php');
$classname = generate_class_name($plugintype, $pluginname);
safe_require($plugintype, $pluginname);
// Check if there is a displayname
$plugindisplayname = call_static_method($classname, 'get_plugin_display_name');
if (empty($pluginversion)) { if (empty($pluginversion)) {
$newinstall = false; $newinstall = false;
if (empty($installing) && $pluginkey != $name) { if (empty($installing) && $pluginkey != $name) {
...@@ -235,11 +250,7 @@ function check_upgrades($name=null) { ...@@ -235,11 +250,7 @@ function check_upgrades($name=null) {
if (property_exists($config, 'requires_parent')) { if (property_exists($config, 'requires_parent')) {
$plugininfo->requires_parent = $config->requires_parent; $plugininfo->requires_parent = $config->requires_parent;
} }
$plugininfo->displayname = $plugindisplayname;
$classname = generate_class_name($plugintype, $pluginname);
safe_require($plugintype, $pluginname);
// Check if there is a displayname
$plugininfo->displayname = call_static_method($classname, 'get_plugin_display_name');
try { try {
$classname::sanity_check(); $classname::sanity_check();
...@@ -281,11 +292,8 @@ function check_upgrades($name=null) { ...@@ -281,11 +292,8 @@ function check_upgrades($name=null) {
if (property_exists($config, 'requires_parent')) { if (property_exists($config, 'requires_parent')) {
$plugininfo->requires_parent = $config->requires_parent; $plugininfo->requires_parent = $config->requires_parent;
} }
$plugininfo->displayname = $plugindisplayname;
$classname = generate_class_name($plugintype, $pluginname);
safe_require($plugintype, $pluginname);
// Check if there is a displayname
$plugininfo->displayname = call_static_method($classname, 'get_plugin_display_name');
try { try {
$classname::sanity_check(); $classname::sanity_check();
} }
...@@ -300,6 +308,18 @@ function check_upgrades($name=null) { ...@@ -300,6 +308,18 @@ function check_upgrades($name=null) {
$toupgrade[$pluginkey] = $plugininfo; $toupgrade[$pluginkey] = $plugininfo;
} }
else if ($config->version < $pluginversion) {
$plugindisplayname = !empty($plugindisplayname) ? $plugindisplayname : $config->name;
if (get_config('productionmode')) {
throw new ConfigSanityException("Database version of Mahara plugin " . $plugindisplayname . " "
. $pluginrelease . " (" . $pluginversion . ") is newer "
. "than files version " . $config->release . " (" . $config->version . "). "
. "Please make sure you have the correct Mahara plugin files in place.");
}
else {
define('SITEOUTOFSYNC', $plugindisplayname);
}
}
} }
// if we've just asked for one, don't return an array... // if we've just asked for one, don't return an array...
......
...@@ -694,6 +694,9 @@ EOF; ...@@ -694,6 +694,9 @@ EOF;
} }
$smarty->assign('PRODUCTIONMODE', get_config('productionmode')); $smarty->assign('PRODUCTIONMODE', get_config('productionmode'));
if (defined('SITEOUTOFSYNC')) {
$smarty->assign('SITEOUTOFSYNC', SITEOUTOFSYNC);
}
if (function_exists('local_header_top_content')) { if (function_exists('local_header_top_content')) {
$sitetop = (isset($sitetop) ? $sitetop : '') . local_header_top_content(); $sitetop = (isset($sitetop) ? $sitetop : '') . local_header_top_content();
} }
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
{str tag=notproductionsite section=error} {str tag=notproductionsite section=error}
</div> </div>
{/if} {/if}
{if $SITEOUTOFSYNC}
<div class="site-message alert alert-warning" role="alert">
<span class="icon icon-lg icon-info-circle left" role="presentation" aria-hidden="true"></span>
{str tag=siteoutofsyncfor section=error arg1=$SITEOUTOFSYNC}
</div>
{/if}
{if $SITECLOSED} {if $SITECLOSED}
<div class="site-message alert alert-danger" role="alert"> <div class="site-message alert alert-danger" role="alert">
<span class="icon icon-lg icon-lock left" role="presentation" aria-hidden="true"></span> <span class="icon icon-lg icon-lock left" role="presentation" aria-hidden="true"></span>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment