mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
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:
parent
5667388908
commit
d09acc0cbe
@ -55,6 +55,14 @@ class MSSQLDatabase extends SS_Database {
|
||||
|
||||
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.
|
||||
* @param array $parameters An map of parameters, which should include:
|
||||
@ -117,13 +125,16 @@ class MSSQLDatabase extends SS_Database {
|
||||
* @return boolean
|
||||
*/
|
||||
public function fullTextEnabled() {
|
||||
if($this->fullTextEnabled === null) {
|
||||
$isInstalled = (boolean) DB::query("SELECT fulltextserviceproperty('isfulltextinstalled')")->value();
|
||||
$enabledForDb = (boolean) DB::query("
|
||||
SELECT is_fulltext_enabled
|
||||
FROM sys.databases
|
||||
WHERE name = '$this->database'
|
||||
")->value();
|
||||
return $isInstalled && $enabledForDb;
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user