BUGFIX MSSQLDatabase::fullTextEnabled() should be cached so it doesn't have to query it all the time and slow down the database when dev/build occurs

This commit is contained in:
Sean Harvey 2010-02-23 01:23:42 +00:00
parent 5667388908
commit d09acc0cbe

View File

@ -53,7 +53,15 @@ class MSSQLDatabase extends SS_Database {
*/ */
public static $noiseWords = array("about", "1", "after", "2", "all", "also", "3", "an", "4", "and", "5", "another", "6", "any", "7", "are", "8", "as", "9", "at", "0", "be", "$", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "does", "each", "else", "for", "from", "get", "got", "has", "had", "he", "have", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "its", "just", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "no", "now", "of", "on", "only", "or", "other", "our", "out", "over", "re", "said", "same", "see", "should", "since", "so", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", "well", "were", "what", "when", "where", "which", "while", "who", "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); public static $noiseWords = array("about", "1", "after", "2", "all", "also", "3", "an", "4", "and", "5", "another", "6", "any", "7", "are", "8", "as", "9", "at", "0", "be", "$", "because", "been", "before", "being", "between", "both", "but", "by", "came", "can", "come", "could", "did", "do", "does", "each", "else", "for", "from", "get", "got", "has", "had", "he", "have", "her", "here", "him", "himself", "his", "how", "if", "in", "into", "is", "it", "its", "just", "like", "make", "many", "me", "might", "more", "most", "much", "must", "my", "never", "no", "now", "of", "on", "only", "or", "other", "our", "out", "over", "re", "said", "same", "see", "should", "since", "so", "some", "still", "such", "take", "than", "that", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "under", "up", "use", "very", "want", "was", "way", "we", "well", "were", "what", "when", "where", "which", "while", "who", "will", "with", "would", "you", "your", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
protected $supportsTransactions=false; protected $supportsTransactions = false;
/**
* Cached flag to determine if full-text is enabled. This is set by
* {@link MSSQLDatabase::fullTextEnabled()}
*
* @var boolean
*/
protected $fullTextEnabled = null;
/** /**
* Connect to a MS SQL database. * Connect to a MS SQL database.
@ -117,13 +125,16 @@ class MSSQLDatabase extends SS_Database {
* @return boolean * @return boolean
*/ */
public function fullTextEnabled() { public function fullTextEnabled() {
$isInstalled = (boolean) DB::query("SELECT fulltextserviceproperty('isfulltextinstalled')")->value(); if($this->fullTextEnabled === null) {
$enabledForDb = (boolean) DB::query(" $isInstalled = (boolean) DB::query("SELECT fulltextserviceproperty('isfulltextinstalled')")->value();
SELECT is_fulltext_enabled $enabledForDb = (boolean) DB::query("
FROM sys.databases SELECT is_fulltext_enabled
WHERE name = '$this->database' FROM sys.databases
")->value(); WHERE name = '$this->database'
return $isInstalled && $enabledForDb; ")->value();
$this->fullTextEnabled = ($isInstalled && $enabledForDb);
}
return $this->fullTextEnabled;
} }
/** /**
@ -304,7 +315,7 @@ class MSSQLDatabase extends SS_Database {
} }
} }
$this->tableList = $this->fieldList = $this->indexList = null; $this->tableList = $this->fieldList = $this->indexList = $this->fullTextEnabled = null;
} }
/** /**