Skip to content

Commit

Permalink
MINOR Security::database_is_ready() check are doing duplicate DB quer…
Browse files Browse the repository at this point in the history
…ies for Members.

The will make sure that if the database has been ready once, it is ready for the rest of the request
  • Loading branch information
Stig Lindqvist committed Apr 11, 2012
1 parent 5750eb0 commit a9509a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions security/Security.php
Expand Up @@ -104,6 +104,14 @@ static function get_word_list() {
*/
static $force_database_is_ready = null;

/**
* When the database has once been verified as ready, it will not do the
* checks again.
*
* @var bool
*/
protected static $database_is_ready = false;

/**
* Set location of word list file
*
Expand Down Expand Up @@ -800,6 +808,8 @@ static function encrypt_password($password, $salt = null, $algorithm = null, $me
public static function database_is_ready() {
// Used for unit tests
if(self::$force_database_is_ready !== NULL) return self::$force_database_is_ready;

if(self::$database_is_ready) return self::$database_is_ready;

$requiredTables = ClassInfo::dataClassesFor('Member');
$requiredTables[] = 'Group';
Expand All @@ -822,6 +832,7 @@ public static function database_is_ready() {

if($missingFields) return false;
}
self::$database_is_ready = true;

return true;
}
Expand Down

0 comments on commit a9509a6

Please sign in to comment.