Upgrade code for core namespaces

This commit is contained in:
Damian Mooyman 2016-08-30 13:08:11 +12:00
parent 551ccfd352
commit da6cefac06
9 changed files with 36 additions and 55 deletions

View File

@ -1,9 +1,10 @@
<?php <?php
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\MSSQL\MSSQLDatabaseConfigurationHelper;
// PDO connector for MS SQL Server // PDO connector for MS SQL Server
/** @skipUpgrade */ /** @skipUpgrade */
use SilverStripe\MSSQL\MSSQLDatabaseConfigurationHelper;
DatabaseAdapterRegistry::register(array( DatabaseAdapterRegistry::register(array(
'class' => 'MSSQLPDODatabase', 'class' => 'MSSQLPDODatabase',
'title' => 'SQL Server 2008 (using PDO)', 'title' => 'SQL Server 2008 (using PDO)',

View File

@ -18,7 +18,6 @@ namespace SilverStripe\MSSQL;
* Fulltext indexes are not supported. * Fulltext indexes are not supported.
* *
* @author Sean Harvey <sean at silverstripe dot com> * @author Sean Harvey <sean at silverstripe dot com>
* @package mssql
*/ */
class MSSQLAzureDatabase extends MSSQLDatabase class MSSQLAzureDatabase extends MSSQLDatabase
{ {

View File

@ -2,14 +2,14 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo;
use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\Connect\SS_Database;
use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DB; use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Connect\SS_Database; use SilverStripe\ORM\PaginatedList;
use Config;
use ClassInfo;
use PaginatedList;
use SilverStripe\ORM\Queries\SQLSelect; use SilverStripe\ORM\Queries\SQLSelect;
/** /**
@ -48,8 +48,6 @@ use SilverStripe\ORM\Queries\SQLSelect;
* *
* References: * References:
* @see http://freetds.org * @see http://freetds.org
*
* @package mssql
*/ */
class MSSQLDatabase extends SS_Database class MSSQLDatabase extends SS_Database
{ {
@ -217,14 +215,10 @@ class MSSQLDatabase extends SS_Database
*/ */
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false)
{ {
if (isset($objects)) { $results = new ArrayList();
$results = new ArrayList($objects);
} else {
$results = new ArrayList();
}
if (!$this->fullTextEnabled()) { if (!$this->fullTextEnabled()) {
return $results; return new PaginatedList($results);
} }
if (!in_array(substr($sortBy, 0, 9), array('"Relevanc', 'Relevance'))) { if (!in_array(substr($sortBy, 0, 9), array('"Relevanc', 'Relevance'))) {
user_error("Non-relevance sort not supported.", E_USER_ERROR); user_error("Non-relevance sort not supported.", E_USER_ERROR);
@ -262,14 +256,14 @@ class MSSQLDatabase extends SS_Database
$class = DataObject::getSchema()->tableClass($tableName); $class = DataObject::getSchema()->tableClass($tableName);
$join = $this->fullTextSearchMSSQL($tableName, $keywords); $join = $this->fullTextSearchMSSQL($tableName, $keywords);
if (!$join) { if (!$join) {
return $results; return new PaginatedList($results);
} // avoid "Null or empty full-text predicate" } // avoid "Null or empty full-text predicate"
// Check if we need to add ShowInSearch // Check if we need to add ShowInSearch
$where = null; $where = null;
if ($class === 'SiteTree') { if ($class === 'SilverStripe\\CMS\\Model\\SiteTree') {
$where = array("\"$tableName\".\"ShowInSearch\"!=0"); $where = array("\"$tableName\".\"ShowInSearch\"!=0");
} elseif ($class === 'File') { } elseif ($class === 'SilverStripe\\Assets\\File') {
// File.ShowInSearch was added later, keep the database driver backwards compatible // File.ShowInSearch was added later, keep the database driver backwards compatible
// by checking for its existence first // by checking for its existence first
$fields = $this->getSchemaManager()->fieldList($tableName); $fields = $this->getSchemaManager()->fieldList($tableName);

View File

@ -2,18 +2,16 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use DatabaseConfigurationHelper; use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\Dev\Install\DatabaseConfigurationHelper;
use PDO; use PDO;
use Exception; use Exception;
use DatabaseAdapterRegistry;
/** /**
* This is a helper class for the SS installer. * This is a helper class for the SS installer.
* *
* It does all the specific checking for MSSQLDatabase * It does all the specific checking for MSSQLDatabase
* to ensure that the configuration is setup correctly. * to ensure that the configuration is setup correctly.
*
* @package mssql
*/ */
class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper
{ {
@ -111,7 +109,7 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper
* *
* @param mixed $conn Connection object/resource * @param mixed $conn Connection object/resource
* @param string $value Value to quote * @param string $value Value to quote
* @return string Quoted strieng * @return string Quoted string
*/ */
protected function quote($conn, $value) protected function quote($conn, $value)
{ {
@ -124,6 +122,7 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper
} else { } else {
user_error('Invalid database connection', E_USER_ERROR); user_error('Invalid database connection', E_USER_ERROR);
} }
return null;
} }
/** /**

View File

@ -2,17 +2,12 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\ORM\Queries\SQLSelect; use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\ORM\Connect\DBQueryBuilder; use SilverStripe\ORM\Connect\DBQueryBuilder;
/** /**
* Builds a SQL query string from a SQLExpression object * Builds a SQL query string from a SQLExpression object
*
* @package mssql
*/ */
class MSSQLQueryBuilder extends DBQueryBuilder class MSSQLQueryBuilder extends DBQueryBuilder
{ {

View File

@ -2,15 +2,10 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use SilverStripe\ORM\Connect\DBSchemaManager; use SilverStripe\ORM\Connect\DBSchemaManager;
/** /**
* Represents and handles all schema management for a MS SQL database * Represents and handles all schema management for a MS SQL database
*
* @package mssql
*/ */
class MSSQLSchemaManager extends DBSchemaManager class MSSQLSchemaManager extends DBSchemaManager
{ {
@ -697,6 +692,7 @@ class MSSQLSchemaManager extends DBSchemaManager
* For a given table name, get all the internal index names, * For a given table name, get all the internal index names,
* except for those that are primary keys and fulltext indexes. * except for those that are primary keys and fulltext indexes.
* *
* @param string $tableName
* @return array * @return array
*/ */
public function indexNames($tableName) public function indexNames($tableName)
@ -786,6 +782,9 @@ class MSSQLSchemaManager extends DBSchemaManager
/** /**
* @todo Make this work like {@link MySQLDatabase::set()} * @todo Make this work like {@link MySQLDatabase::set()}
*
* @param array $values
* @return string
*/ */
public function set($values) public function set($values)
{ {

View File

@ -2,15 +2,10 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use SilverStripe\ORM\Connect\DBConnector; use SilverStripe\ORM\Connect\DBConnector;
/** /**
* Database connector driver for sqlsrv_ library * Database connector driver for sqlsrv_ library
*
* @package mssql
*/ */
class SQLServerConnector extends DBConnector class SQLServerConnector extends DBConnector
{ {

View File

@ -2,15 +2,11 @@
namespace SilverStripe\MSSQL; namespace SilverStripe\MSSQL;
use SilverStripe\ORM\Connect\SS_Query;
use DateTime; use DateTime;
use SilverStripe\ORM\Connect\SS_Query;
/** /**
* A result-set from a MSSQL database. * A result-set from a MSSQL database.
*
* @package mssql
*/ */
class SQLServerQuery extends SS_Query class SQLServerQuery extends SS_Query
{ {

View File

@ -1,6 +1,9 @@
<?php <?php
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Dev\TestOnly;
class MSSQLDatabaseQueryTest extends SapphireTest class MSSQLDatabaseQueryTest extends SapphireTest
{ {