MDL-27982 remove unsigned support from all UIs and APIs, keep only public API for BC
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
c3dd6b01fe
commit
7e522ccbc8
@@ -113,6 +113,7 @@ class database_column_info {
|
||||
* True if integer unsigned, false if signed.
|
||||
* Null for other types
|
||||
* @var integer
|
||||
* @deprecated since 2.3
|
||||
*/
|
||||
public $unsigned;
|
||||
|
||||
|
||||
@@ -1798,6 +1798,7 @@ abstract class moodle_database {
|
||||
* (Only MySQL needs this. MySQL things that 1 * -1 = 18446744073709551615
|
||||
* if the 1 comes from an unsigned column).
|
||||
*
|
||||
* @deprecated since 2.3
|
||||
* @param string $fieldname The name of the field to be cast
|
||||
* @return string The piece of SQL code to be used in your statement.
|
||||
*/
|
||||
|
||||
@@ -1203,6 +1203,13 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
return $positivematch ? 'REGEXP' : 'NOT REGEXP';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL to be used in order to an UNSIGNED INTEGER column to SIGNED.
|
||||
*
|
||||
* @deprecated since 2.3
|
||||
* @param string $fieldname The name of the field to be cast
|
||||
* @return string The piece of SQL code to be used in your statement.
|
||||
*/
|
||||
public function sql_cast_2signed($fieldname) {
|
||||
return ' CAST(' . $fieldname . ' AS SIGNED) ';
|
||||
}
|
||||
|
||||
@@ -855,6 +855,7 @@ function filter_get_active_in_context($context) {
|
||||
) active
|
||||
LEFT JOIN {filter_config} fc ON fc.filter = active.filter AND fc.contextid = $context->id
|
||||
ORDER BY active.sortorder";
|
||||
//TODO: remove sql_cast_2signed() once we do not support upgrade from Moodle 2.2
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
|
||||
// Masssage the data into the specified format to return.
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<xs:attribute name="LENGTH" type="fieldLength" use="optional" />
|
||||
<xs:attribute name="NOTNULL" type="trueFalse" use="required" />
|
||||
<xs:attribute name="DECIMALS" type="xs:positiveInteger" use="optional" />
|
||||
<!-- TODO: Moodle 2.4 - Drop ignored UNSIGNED attribute -->
|
||||
<xs:attribute name="UNSIGNED" type="trueFalse" use="optional" />
|
||||
<!-- TODO: Moodle 2.1 - Drop ENUM and ENUMVALUES attributes -->
|
||||
<xs:attribute name="ENUM" type="trueFalse" use="optional" />
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
define ('XMLDB_STATEMENT_CUSTOM', 4); //Custom Statements
|
||||
|
||||
/// Some other useful Constants
|
||||
define ('XMLDB_UNSIGNED', true); //If the field is going to be unsigned
|
||||
define ('XMLDB_UNSIGNED', true); //If the field is going to be unsigned @deprecated since 2.3
|
||||
define ('XMLDB_NOTNULL', true); //If the field is going to be not null
|
||||
define ('XMLDB_SEQUENCE', true); //If the field is going to be a sequence
|
||||
define ('XMLDB_INDEX_UNIQUE', true); //If the index is going to be unique
|
||||
|
||||
@@ -30,7 +30,6 @@ class xmldb_field extends xmldb_object {
|
||||
|
||||
var $type;
|
||||
var $length;
|
||||
var $unsigned;
|
||||
var $notnull;
|
||||
var $default;
|
||||
var $sequence;
|
||||
@@ -53,7 +52,6 @@ class xmldb_field extends xmldb_object {
|
||||
function __construct($name, $type=null, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $default=null, $previous=null) {
|
||||
$this->type = NULL;
|
||||
$this->length = NULL;
|
||||
$this->unsigned = true;
|
||||
$this->notnull = false;
|
||||
$this->default = NULL;
|
||||
$this->sequence = false;
|
||||
@@ -98,7 +96,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->decimals = trim($precisionarr[1]);
|
||||
}
|
||||
$this->precision = $type;
|
||||
$this->unsigned = !empty($unsigned) ? true : false;
|
||||
$this->notnull = !empty($notnull) ? true : false;
|
||||
$this->sequence = !empty($sequence) ? true : false;
|
||||
$this->setDefault($default);
|
||||
@@ -136,9 +133,10 @@ class xmldb_field extends xmldb_object {
|
||||
|
||||
/**
|
||||
* Get the unsigned
|
||||
* @deprecated since moodle 2.3
|
||||
*/
|
||||
function getUnsigned() {
|
||||
return $this->unsigned;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,9 +176,9 @@ class xmldb_field extends xmldb_object {
|
||||
|
||||
/**
|
||||
* Set the field unsigned
|
||||
* @deprecated since moodle 2.3
|
||||
*/
|
||||
function setUnsigned($unsigned=true) {
|
||||
$this->unsigned = $unsigned;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +227,7 @@ class xmldb_field extends xmldb_object {
|
||||
/// print_object ($GLOBALS['traverse_array']); //Debug
|
||||
/// $GLOBALS['traverse_array']=""; //Debug
|
||||
|
||||
/// Process table attributes (name, type, length, unsigned,
|
||||
/// Process table attributes (name, type, length
|
||||
/// notnull, sequence, decimals, comment, previous, next)
|
||||
if (isset($xmlarr['@']['NAME'])) {
|
||||
$this->name = trim($xmlarr['@']['NAME']);
|
||||
@@ -289,19 +287,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->length = $length;
|
||||
}
|
||||
|
||||
if (isset($xmlarr['@']['UNSIGNED'])) {
|
||||
$unsigned = strtolower(trim($xmlarr['@']['UNSIGNED']));
|
||||
if ($unsigned == 'true') {
|
||||
$this->unsigned = true;
|
||||
} else if ($unsigned == 'false') {
|
||||
$this->unsigned = false;
|
||||
} else {
|
||||
$this->errormsg = 'Incorrect UNSIGNED attribute (true/false allowed)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xmlarr['@']['NOTNULL'])) {
|
||||
$notnull = strtolower(trim($xmlarr['@']['NOTNULL']));
|
||||
if ($notnull == 'true') {
|
||||
@@ -470,7 +455,7 @@ class xmldb_field extends xmldb_object {
|
||||
$this->hash = NULL;
|
||||
} else {
|
||||
$key = $this->name . $this->type . $this->length .
|
||||
$this->unsigned . $this->notnull . $this->sequence .
|
||||
$this->notnull . $this->sequence .
|
||||
$this->decimals . $this->comment;
|
||||
$this->hash = md5($key);
|
||||
}
|
||||
@@ -492,16 +477,6 @@ class xmldb_field extends xmldb_object {
|
||||
$notnull = 'false';
|
||||
}
|
||||
$o.= ' NOTNULL="' . $notnull . '"';
|
||||
if ($this->type == XMLDB_TYPE_INTEGER ||
|
||||
$this->type == XMLDB_TYPE_NUMBER ||
|
||||
$this->type == XMLDB_TYPE_FLOAT) {
|
||||
if ($this->unsigned) {
|
||||
$unsigned = 'true';
|
||||
} else {
|
||||
$unsigned = 'false';
|
||||
}
|
||||
$o.= ' UNSIGNED="' . $unsigned . '"';
|
||||
}
|
||||
if (!$this->sequence && $this->default !== NULL) {
|
||||
$o.= ' DEFAULT="' . $this->default . '"';
|
||||
}
|
||||
@@ -624,13 +599,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->type == XMLDB_TYPE_FLOAT)) {
|
||||
$this->decimals = $adofield->scale;
|
||||
}
|
||||
/// Calculate the unsigned field
|
||||
if ($adofield->unsigned &&
|
||||
($this->type == XMLDB_TYPE_INTEGER ||
|
||||
$this->type == XMLDB_TYPE_NUMBER ||
|
||||
$this->type == XMLDB_TYPE_FLOAT)) {
|
||||
$this->unsigned = true;
|
||||
}
|
||||
/// Calculate the notnull field
|
||||
if ($adofield->not_null) {
|
||||
$this->notnull = true;
|
||||
@@ -642,8 +610,6 @@ class xmldb_field extends xmldb_object {
|
||||
/// Calculate the sequence field
|
||||
if ($adofield->auto_increment) {
|
||||
$this->sequence = true;
|
||||
/// Sequence fields are always unsigned
|
||||
$this->unsigned = true;
|
||||
}
|
||||
/// Some more fields
|
||||
$this->loaded = true;
|
||||
@@ -696,14 +662,8 @@ class xmldb_field extends xmldb_object {
|
||||
} else {
|
||||
$result .= 'null, ';
|
||||
}
|
||||
/// Unsigned (only applicable to numbers)
|
||||
$unsigned = $this->getUnsigned();
|
||||
if (!empty($unsigned) &&
|
||||
($this->getType() == XMLDB_TYPE_INTEGER || $this->getType() == XMLDB_TYPE_NUMBER || $this->getType() == XMLDB_TYPE_FLOAT)) {
|
||||
$result .= 'XMLDB_UNSIGNED' . ', ';
|
||||
} else {
|
||||
$result .= 'null, ';
|
||||
}
|
||||
/// Unsigned is not used any more since Moodle 2.3
|
||||
$result .= 'null, ';
|
||||
/// Not Null
|
||||
$notnull = $this->getNotnull();
|
||||
if (!empty($notnull)) {
|
||||
@@ -765,16 +725,6 @@ class xmldb_field extends xmldb_object {
|
||||
$this->type == XMLDB_TYPE_BINARY) {
|
||||
$o .= ' (' . $this->length . ')';
|
||||
}
|
||||
/// unsigned
|
||||
if ($this->type == XMLDB_TYPE_INTEGER ||
|
||||
$this->type == XMLDB_TYPE_NUMBER ||
|
||||
$this->type == XMLDB_TYPE_FLOAT) {
|
||||
if ($this->unsigned) {
|
||||
$o .= ' unsigned';
|
||||
} else {
|
||||
$o .= ' signed';
|
||||
}
|
||||
}
|
||||
/// not null
|
||||
if ($this->notnull) {
|
||||
$o .= ' not null';
|
||||
|
||||
Reference in New Issue
Block a user