mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
#1754 - Database upgrades problematic (merged from branches/2.2.0, r44770)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@44895 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c4ea119cd2
commit
c7415ad3d4
@ -219,6 +219,16 @@ class DB {
|
|||||||
return DB::$globalConn->tableList();
|
return DB::$globalConn->tableList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all the fields for the given table.
|
||||||
|
* Returns a map of field name => field spec.
|
||||||
|
* @param string $table The table name.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
static function fieldList($table) {
|
||||||
|
return DB::$globalConn->fieldList($table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable supression of database messages.
|
* Enable supression of database messages.
|
||||||
*/
|
*/
|
||||||
|
@ -528,7 +528,7 @@ class DataObject extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Divvy up field saving into a number of database manipulations
|
// Divvy up field saving into a number of database manipulations
|
||||||
if(is_array($ancestry)) {
|
if(isset($ancestry) && is_array($ancestry)) {
|
||||||
foreach($ancestry as $idx => $class) {
|
foreach($ancestry as $idx => $class) {
|
||||||
$classSingleton = singleton($class);
|
$classSingleton = singleton($class);
|
||||||
foreach($this->record as $fieldName => $value) {
|
foreach($this->record as $fieldName => $value) {
|
||||||
|
@ -65,9 +65,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
* Updates the database schema, creating tables & fields as necessary.
|
* Updates the database schema, creating tables & fields as necessary.
|
||||||
*/
|
*/
|
||||||
function build() {
|
function build() {
|
||||||
if((Director::isLive() && ClassInfo::hasTable('Member') &&
|
if(Director::isLive() && Security::database_is_ready() && (!Member::currentUser() || !Member::currentUser()->isAdmin())) {
|
||||||
ClassInfo::hasTable('Group') && ClassInfo::hasTable('Permission'))
|
|
||||||
&& (!Member::currentUser() || !Member::currentUser()->isAdmin())) {
|
|
||||||
Security::permissionFailure($this,
|
Security::permissionFailure($this,
|
||||||
"This page is secured and you need administrator rights to access it. " .
|
"This page is secured and you need administrator rights to access it. " .
|
||||||
"Enter your credentials below and we will send you right along.");
|
"Enter your credentials below and we will send you right along.");
|
||||||
@ -79,8 +77,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
set_time_limit(600);
|
set_time_limit(600);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->doBuild(isset($_REQUEST['quiet']) ||
|
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']));
|
||||||
isset($_REQUEST['from_installer']));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -835,6 +835,19 @@ class Security extends Controller {
|
|||||||
print '</p>';
|
print '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the database is in a state to perform security checks.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function database_is_ready() {
|
||||||
|
return
|
||||||
|
ClassInfo::hasTable('Member') &&
|
||||||
|
ClassInfo::hasTable('Group') &&
|
||||||
|
ClassInfo::hasTable('Permission') &&
|
||||||
|
(($permissionFields = DB::fieldList('Permission')) && isset($permissionFields['Type'])) &&
|
||||||
|
(($memberFields = DB::fieldList('Member')) && isset($memberFields['RememberLoginToken']));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user