Merge pull request #3425 from halkyon/removing_deprecated2

Removing deprecated class/functions marked for deprecation in 3.0/3.1
This commit is contained in:
Damian Mooyman 2014-08-26 09:13:08 +12:00
commit e301279358
17 changed files with 33 additions and 450 deletions

View File

@ -54,17 +54,6 @@ class Cookie {
return self::get_inst()->inst_get($name);
}
/**
* @param string
* @param string
* @param string
*/
public static function forceExpiry($name, $path = null, $domain = null) {
Deprecation::notice('3.1', 'Use Cookie::force_expiry instead.');
return self::force_expiry($name, $path, $domain);
}
/**
* @param string
* @param string

View File

@ -75,10 +75,6 @@ class Director implements TemplateGlobalProvider {
* priority 50.
*/
public static function addRules($priority, $rules) {
if ($priority != 100) {
Deprecation::notice('3.0', 'Priority argument is now ignored - use the default of 100. You should really'
. ' be setting routes via _config yaml fragments though.', Deprecation::SCOPE_GLOBAL);
}
Deprecation::notice('3.2', 'Use the "Director.rules" config setting instead');
Config::inst()->update('Director', 'rules', $rules);

View File

@ -373,102 +373,6 @@ abstract class Object {
return $default;
}
/**
* Get a static variable, taking into account SS's inbuild static caches and pseudo-statics
*
* This method first checks for any extra values added by {@link Object::add_static_var()}, and attemps to traverse
* up the extra static var chain until it reaches the top, or it reaches a replacement static.
*
* If any extra values are discovered, they are then merged with the default PHP static values, or in some cases
* completely replace the default PHP static when you set $replace = true, and do not define extra data on any
* child classes
*
* @param string $class
* @param string $name the property name
* @param bool $uncached if set to TRUE, force a regeneration of the static cache
* @return mixed
*/
public static function get_static($class, $name, $uncached = false) {
Deprecation::notice('3.1.0', 'Replaced by Config#get');
return Config::inst()->get($class, $name, Config::FIRST_SET);
}
/**
* Set a static variable
*
* @param string $class
* @param string $name the property name to set
* @param mixed $value
*/
public static function set_static($class, $name, $value) {
Deprecation::notice('3.1.0', 'Replaced by Config#update');
Config::inst()->update($class, $name, $value);
}
/**
* Get an uninherited static variable - a variable that is explicity set in this class, and not in the parent class.
*
* @param string $class
* @param string $name
* @return mixed
*/
public static function uninherited_static($class, $name, $uncached = false) {
Deprecation::notice('3.1.0', 'Replaced by Config#get');
return Config::inst()->get($class, $name, Config::UNINHERITED);
}
/**
* Traverse down a class ancestry and attempt to merge all the uninherited static values for a particular static
* into a single variable
*
* @param string $class
* @param string $name the static name
* @param string $ceiling an optional parent class name to begin merging statics down from, rather than traversing
* the entire hierarchy
* @return mixed
*/
public static function combined_static($class, $name, $ceiling = false) {
if ($ceiling) throw new Exception('Ceiling argument to combined_static is no longer supported');
Deprecation::notice('3.1.0', 'Replaced by Config#get');
return Config::inst()->get($class, $name);
}
/**
* Merge in a set of additional static variables
*
* @param string $class
* @param array $properties in a [property name] => [value] format
* @param bool $replace replace existing static vars
*/
public static function addStaticVars($class, $properties, $replace = false) {
Deprecation::notice('3.1.0', 'Replaced by Config#update');
foreach($properties as $prop => $value) self::add_static_var($class, $prop, $value, $replace);
}
/**
* Add a static variable without replacing it completely if possible, but merging in with both existing PHP statics
* and existing psuedo-statics. Uses PHP's array_merge_recursive() with if the $replace argument is FALSE.
*
* Documentation from http://php.net/array_merge_recursive:
* If the input arrays have the same string keys, then the values for these keys are merged together
* into an array, and this is done recursively, so that if one of the values is an array itself,
* the function will merge it with a corresponding entry in another array too.
* If, however, the arrays have the same numeric key, the later value will not overwrite the original value,
* but will be appended.
*
* @param string $class
* @param string $name the static name
* @param mixed $value
* @param bool $replace completely replace existing static values
*/
public static function add_static_var($class, $name, $value, $replace = false) {
Deprecation::notice('3.1.0', 'Replaced by Config#remove and Config#update');
if ($replace) Config::inst()->remove($class, $name);
Config::inst()->update($class, $name, $value);
}
/**
* Return TRUE if a class has a specified extension.
* This supports backwards-compatible format (static Object::has_extension($requiredExtension))

View File

@ -5,20 +5,37 @@
### Framework
* Minimum PHP version raised to 5.3.3
* DataObject::validate() method visibility changed to public
* NumericField now uses HTML5 "number" type instead of "text"
* UploadField "Select from files" shows files in all folders by default
* UploadField won't display an overwrite warning unless Upload:replaceFile is true
* HtmlEditorField no longer substitutes `<blockquote />` for indented text
* ClassInfo::dataClassesFor now returns classes which should have tables, regardless of whether those
* `DataObject::validate()` method visibility changed to public
* `NumericField` now uses HTML5 "number" type instead of "text"
* `UploadField` "Select from files" shows files in all folders by default
* `UploadField` won't display an overwrite warning unless `Upload::replaceFile` is true
* `HtmlEditorField` no longer substitutes `<blockquote />` for indented text
* `ClassInfo::dataClassesFor` now returns classes which should have tables, regardless of whether those
tables actually exist.
* SS_Filterable, SS_Limitable and SS_Sortable now explicitly extend SS_List
* ToggleField was deprecated in 3.1, and has been removed. Use custom Javascript with ReadonlyField instead.
* ExactMatchMultiFilter was deprecated in 3.1, and has been removed. Use ExactMatchFilter instead.
* NegationFilter was deprecated in 3.1, and has been removed. Use ExactMatchFilter:not instead.
* StartsWithMultiFilter was deprecated in 3.1, and has been removed. Use StartsWithFilter instead.
* ScheduledTask and subclasses like DailyTask were deprecated in 3.1, and have been removed.
* `SS_Filterable`, `SS_Limitable` and `SS_Sortable` now explicitly extend `SS_List`
#### Deprecated classes/methods removed
* `ToggleField` was deprecated in 3.1, and has been removed. Use custom Javascript with `ReadonlyField` instead.
* `ExactMatchMultiFilter` was deprecated in 3.1, and has been removed. Use `ExactMatchFilter` instead.
* `NegationFilter` was deprecated in 3.1, and has been removed. Use `ExactMatchFilter:not` instead.
* `StartsWithMultiFilter` was deprecated in 3.1, and has been removed. Use `StartsWithFilter` instead.
* `ScheduledTask` and subclasses like `DailyTask` were deprecated in 3.1, and have been removed.
Use custom code instead, or a module like silverstripe-crontask: https://github.com/silverstripe-labs/silverstripe-crontask
* `Cookie::forceExpiry()` was removed. Use `Cookie::force_expiry()` instead
* `Object` statics removal: `get_static()`, `set_static()`, `uninherited_static()`, `combined_static()`,
`addStaticVars()` and `add_static_var()` removed. Use the Config methods instead.
* `GD` methods removed: `setGD()`, `getGD()`, `hasGD()`. Use `setImageResource()`, `getImageResource()`, and `hasImageResource()` instead
* `DataExtension::get_extra_config()` removed, no longer supports `extraStatics` or `extraDBFields`. Define your
statics on the class directly.
* `DataList::getRange()` removed. Use `limit()` instead.
* `SQLMap` removed. Call `map()` on a `DataList` or use `SS_Map` directly instead.
* `Profiler` removed. Use xhprof or xdebug for profiling instead.
* `Aggregate` removed. Call aggregate methods on a `DataList` instead e.g. `Member::get()->max('LastEdited')`
* `MySQLDatabase::set_connection_charset()` removed. Use `MySQLDatabase.connection_charset` config setting instead
* `SQLConditionalExpression/SQLQuery` `select()`, `limit()`, `orderby()`, `groupby()`, `having()`, `from()`, `leftjoin()`, `innerjoin()`, `where()` and `whereAny()` removed.
Use `set*()` and `add*()` methods instead.
* Template `<% control $MyList %>` syntax removed. Use `<% loop $MyList %>` instead.
### CMS

View File

@ -86,20 +86,10 @@ class GDBackend extends Object implements Image_Backend {
$this->height = imagesy($resource);
}
public function setGD($gd) {
Deprecation::notice('3.1', 'Use GD::setImageResource instead');
return $this->setImageResource($gd);
}
public function getImageResource() {
return $this->gd;
}
public function getGD() {
Deprecation::notice('3.1', 'GD::getImageResource instead');
return $this->getImageResource();
}
/**
* @param string $filename
* @return boolean
@ -227,13 +217,6 @@ class GDBackend extends Object implements Image_Backend {
return $this->gd ? true : false;
}
public function hasGD() {
Deprecation::notice('3.1', 'GD::hasImageResource instead',
Deprecation::SCOPE_CLASS);
return $this->hasImageResource();
}
/**
* Resize an image, skewing it as necessary.
*/

View File

@ -122,27 +122,9 @@ class DropdownField extends FormField {
* @param array $source An map of the dropdown items
* @param string $value The current value
* @param Form $form The parent form
* @param string|bool $emptyString Add an empty selection on to of the {@link $source}-Array (can also be
* boolean, which results in an empty string). Argument is deprecated
* in 3.1, please use{@link setEmptyString()} and/or
* {@link setHasEmptyDefault(true)} instead.
*/
public function __construct($name, $title=null, $source=array(), $value='', $form=null, $emptyString=null) {
public function __construct($name, $title=null, $source=array(), $value='', $form=null) {
$this->setSource($source);
if($emptyString === true) {
Deprecation::notice('3.1',
'Please use setHasEmptyDefault(true) instead of passing a boolean true $emptyString argument',
Deprecation::SCOPE_GLOBAL);
}
if(is_string($emptyString)) {
Deprecation::notice('3.1', 'Please use setEmptyString() instead of passing a string emptyString argument.',
Deprecation::SCOPE_GLOBAL);
}
if($emptyString) $this->setHasEmptyDefault(true);
if(is_string($emptyString)) $this->setEmptyString($emptyString);
parent::__construct($name, ($title===null) ? $name : $title, $value, $form);
}

View File

@ -14,20 +14,6 @@ class PasswordField extends TextField {
*/
private static $autocomplete;
/**
* Returns an input field, class="text" and type="text" with an optional
* maxlength
*/
public function __construct($name, $title = null, $value = "") {
if(count(func_get_args()) > 3) {
Deprecation::notice('3.0', 'Use setMaxLength() instead of constructor arguments',
Deprecation::SCOPE_GLOBAL);
}
parent::__construct($name, $title, $value);
}
public function getAttributes() {
$attributes = array_merge(
parent::getAttributes(),

View File

@ -7,23 +7,6 @@
*/
abstract class DataExtension extends Extension {
public static function get_extra_config($class, $extension, $args) {
if(method_exists($extension, 'extraDBFields')) {
$extraStaticsMethod = 'extraDBFields';
} else {
$extraStaticsMethod = 'extraStatics';
}
$statics = Injector::inst()->get($extension, true, $args)->$extraStaticsMethod($class, $extension);
if ($statics) {
Deprecation::notice('3.1.0',
"$extraStaticsMethod deprecated. Just define statics on your extension, or use get_extra_config",
Deprecation::SCOPE_GLOBAL);
return $statics;
}
}
public static function unload_extra_statics($class, $extension) {
throw new Exception('unload_extra_statics gone');
}

View File

@ -482,11 +482,6 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
throw new InvalidArgumentException("Bad field expression $field");
}
if (!$this->inAlterDataQueryCall) {
Deprecation::notice('3.1',
'getRelationName is mutating, and must be called inside an alterDataQuery block');
}
if(strpos($field,'.') === false) {
return '"'.$field.'"';
}
@ -812,18 +807,6 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
return $this->count() > 0;
}
/**
* Get a sub-range of this dataobjectset as an array
*
* @param int $offset
* @param int $length
* @return DataList
*/
public function getRange($offset, $length) {
Deprecation::notice("3.0", 'Use limit($length, $offset) instead. Note the new argument order.');
return $this->limit($length, $offset);
}
/**
* Find the first DataObject of this DataList where the given key = value
*

View File

@ -1,92 +0,0 @@
<?php
/**
* This is a class used to represent key->value pairs generated from database queries.
* The query isn't actually executed until you need it.
*
* @package framework
* @subpackage model
*/
class SQLMap extends Object implements IteratorAggregate {
/**
* The query used to generate the map.
* @var SQLSelect
*/
protected $query;
protected $keyField, $titleField;
/**
* Construct a SQLMap.
*
* @param SQLSelect $query The query to generate this map. THis isn't executed until it's needed.
*/
public function __construct(SQLSelect $query, $keyField = "ID", $titleField = "Title") {
Deprecation::notice('3.0', 'Use SS_Map or DataList::map() instead.', Deprecation::SCOPE_CLASS);
if(!$query) {
user_error('SQLMap constructed with null query.', E_USER_ERROR);
}
$this->query = $query;
$this->keyField = $keyField;
$this->titleField = $titleField;
parent::__construct();
}
/**
* Get the name of an item.
* @param string|int $id The id of the item.
* @return string
*/
public function getItem($id) {
if($id) {
$baseTable = reset($this->query->from);
$oldWhere = $this->query->getWhere();
$this->query->where(array(
"\"$baseTable\".\"ID\" = ?" => $id
));
$record = $this->query->execute()->first();
$this->query->setWhere($oldWhere);
if($record) {
$className = $record['ClassName'];
$obj = new $className($record);
return $obj->Title;
}
}
}
public function getIterator() {
$this->genItems();
return new SS_Map_Iterator($this->items->getIterator(), $this->keyField, $this->titleField);
}
/**
* Get the items in this class.
* @return SS_List
*/
public function getItems() {
$this->genItems();
return $this->items;
}
/**
* Generate the items in this map. This is used by
* getItems() if the items have not been generated already.
*/
protected function genItems() {
if(!isset($this->items)) {
$this->items = new ArrayList();
$items = $this->query->execute();
foreach($items as $item) {
$className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName'];
if(!$className) {
user_error('SQLMap query could not retrieve className', E_USER_ERROR);
}
$this->items->push(new $className($item));
}
}
}
}

View File

@ -49,23 +49,6 @@ class MySQLDatabase extends SS_Database {
}
}
/**
* Sets the character set for the MySQL database connection.
*
* The character set connection should be set to 'utf8' for SilverStripe version 2.4.0 and
* later.
*
* However, sites created before version 2.4.0 should leave this unset or data that isn't 7-bit
* safe will be corrupted. As such, the installer comes with this set in mysite/_config.php by
* default in versions 2.4.0 and later.
*
* @deprecated 3.2 Use "MySQLDatabase.connection_charset" config setting instead
*/
public static function set_connection_charset($charset = 'utf8') {
Deprecation::notice('3.1', 'Use "MySQLDatabase.connection_charset" config setting instead');
Config::inst()->update('MySQLDatabase', 'connection_charset', $charset);
}
/**
* Sets the SQL mode
*

View File

@ -64,14 +64,6 @@ abstract class SQLConditionalExpression extends SQLExpression {
return $this->addFrom($from);
}
/**
* @deprecated since version 3.0
*/
public function from($from) {
Deprecation::notice('3.0', 'Please use setFrom() or addFrom() instead!');
return $this->setFrom($from);
}
/**
* Add a table to include in the query or update
*
@ -147,14 +139,6 @@ abstract class SQLConditionalExpression extends SQLExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function leftjoin($table, $onPredicate, $tableAlias = null, $order = 20) {
Deprecation::notice('3.0', 'Please use addLeftJoin() instead!');
$this->addLeftJoin($table, $onPredicate, $tableAlias);
}
/**
* Add an INNER JOIN criteria
*
@ -178,14 +162,6 @@ abstract class SQLConditionalExpression extends SQLExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function innerjoin($table, $onPredicate, $tableAlias = null, $order = 20) {
Deprecation::notice('3.0', 'Please use addInnerJoin() instead!');
return $this->addInnerJoin($table, $onPredicate, $tableAlias, $order);
}
/**
* Add an additional filter (part of the ON clause) on a join.
*
@ -474,22 +450,6 @@ abstract class SQLConditionalExpression extends SQLExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function where($where) {
Deprecation::notice('3.0', 'Please use setWhere() or addWhere() instead!');
return $this->setWhere($where);
}
/**
* @deprecated since version 3.0
*/
public function whereAny($where) {
Deprecation::notice('3.0', 'Please use setWhereAny() or setWhereAny() instead!');
return $this->setWhereAny($where);
}
/**
* @see SQLSelect::addWhere()
*

View File

@ -148,25 +148,12 @@ class SQLSelect extends SQLConditionalExpression {
}
foreach($fields as $idx => $field) {
if(preg_match('/^(.*) +AS +"?([^"]*)"?/i', $field, $matches)) {
Deprecation::notice("3.0", "Use selectField() to specify column aliases");
$this->selectField($matches[1], $matches[2]);
} else {
$this->selectField($field, is_numeric($idx) ? null : $idx);
}
$this->selectField($field, is_numeric($idx) ? null : $idx);
}
return $this;
}
/**
* @deprecated since version 3.0
*/
public function select($fields) {
Deprecation::notice('3.0', 'Please use setSelect() or addSelect() instead!');
$this->setSelect($fields);
}
/**
* Select an additional field.
*
@ -263,14 +250,6 @@ class SQLSelect extends SQLConditionalExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function limit($limit, $offset = 0) {
Deprecation::notice('3.0', 'Please use setLimit() instead!');
return $this->setLimit($limit, $offset);
}
/**
* Set ORDER BY clause either as SQL snippet or in array format.
*
@ -364,14 +343,6 @@ class SQLSelect extends SQLConditionalExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function orderby($clauses = null, $direction = null) {
Deprecation::notice('3.0', 'Please use setOrderBy() instead!');
return $this->setOrderBy($clauses, $direction);
}
/**
* Extract the direction part of a single-column order by clause.
*
@ -466,14 +437,6 @@ class SQLSelect extends SQLConditionalExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function groupby($where) {
Deprecation::notice('3.0', 'Please use setGroupBy() or addHaving() instead!');
return $this->setGroupBy($where);
}
/**
* Set a HAVING clause.
*
@ -507,14 +470,6 @@ class SQLSelect extends SQLConditionalExpression {
return $this;
}
/**
* @deprecated since version 3.0
*/
public function having($having) {
Deprecation::notice('3.0', 'Please use setHaving() or addHaving() instead!');
return $this->setHaving($having);
}
/**
* Return a list of HAVING clauses used internally.
* @return array

View File

@ -246,23 +246,9 @@ class Group extends DataObject {
* See {@link DirectMembers()} for retrieving members without any inheritance.
*
* @param String $filter
* @param String $sort
* @param String $join Deprecated, use leftJoin($table, $joinClause) instead
* @return ManyManyList
*/
public function Members($filter = "", $sort = "", $join = "", $limit = "") {
if($sort || $join || $limit) {
Deprecation::notice('3.0',
"The sort, join, and limit arguments are deprcated, use sort(), join() and limit() on the resulting"
. " DataList instead.");
}
if($join) {
throw new \InvalidArgumentException(
'The $join argument has been removed. Use leftJoin($table, $joinClause) instead.'
);
}
public function Members($filter = '') {
// First get direct members as a base result
$result = $this->DirectMembers();
// Remove the default foreign key filter in prep for re-applying a filter containing all children groups.
@ -275,7 +261,7 @@ class Group extends DataObject {
}
// Now set all children groups as a new foreign key
$groups = Group::get()->byIDs($this->collateFamilyIDs());
$result = $result->forForeignID($groups->column('ID'))->where($filter)->sort($sort)->limit($limit);
$result = $result->forForeignID($groups->column('ID'))->where($filter);
return $result;
}

View File

@ -3751,15 +3751,6 @@ class SSTemplateParser extends Parser implements TemplateParser {
'}; $scope->popScope(); ';
}
/**
* The deprecated closed block handler for control blocks
* @deprecated
*/
function ClosedBlock_Handle_Control(&$res) {
Deprecation::notice('3.1', '<% control %> is deprecated. Use <% with %> or <% loop %> instead.');
return $this->ClosedBlock_Handle_Loop($res);
}
/**
* The closed block handler for with blocks
*/

View File

@ -931,15 +931,6 @@ class SSTemplateParser extends Parser implements TemplateParser {
'}; $scope->popScope(); ';
}
/**
* The deprecated closed block handler for control blocks
* @deprecated
*/
function ClosedBlock_Handle_Control(&$res) {
Deprecation::notice('3.1', '<% control %> is deprecated. Use <% with %> or <% loop %> instead.');
return $this->ClosedBlock_Handle_Loop($res);
}
/**
* The closed block handler for with blocks
*/

View File

@ -1032,13 +1032,6 @@ class SSViewer {
public function process($item, $arguments = null, $inheritedScope = null) {
SSViewer::$topLevel[] = $item;
if ($arguments && $arguments instanceof Zend_Cache_Core) {
Deprecation::notice('3.0', 'Use setPartialCacheStore to override the partial cache storage backend, ' .
'the second argument to process is now an array of variables.');
$this->setPartialCacheStore($arguments);
$arguments = null;
}
if(isset($this->chosenTemplates['main'])) {
$template = $this->chosenTemplates['main'];
} else {
@ -1208,13 +1201,6 @@ class SSViewer_FromString extends SSViewer {
}
public function process($item, $arguments = null, $scope = null) {
if ($arguments && $arguments instanceof Zend_Cache_Core) {
Deprecation::notice('3.0', 'Use setPartialCacheStore to override the partial cache storage backend, ' .
'the second argument to process is now an array of variables.');
$this->setPartialCacheStore($arguments);
$arguments = null;
}
$hash = sha1($this->content);
$cacheFile = TEMP_FOLDER . "/.cache.$hash";