diff --git a/admin/tool/xmldb/actions/check_bigints/check_bigints.class.php b/admin/tool/xmldb/actions/check_bigints/check_bigints.class.php index f2def4aad10..18b49957366 100644 --- a/admin/tool/xmldb/actions/check_bigints/check_bigints.class.php +++ b/admin/tool/xmldb/actions/check_bigints/check_bigints.class.php @@ -23,8 +23,7 @@ /** * reporting about the ones not physically implemented as BIGINTs - * and providing one SQL script to fix all them. Also, under MySQL, - * it performs one check of signed bigints. MDL-11038 + * and providing one SQL script to fix all them. MDL-11038 * * @package tool * @subpackage xmldb @@ -53,7 +52,6 @@ class check_bigints extends XMLDBCheckAction { 'wrongints' => 'tool_xmldb', 'nowrongintsfound' => 'tool_xmldb', 'yeswrongintsfound' => 'tool_xmldb', - 'mysqlextracheckbigints' => 'tool_xmldb', )); // Correct fields must be type bigint for MySQL and int8 for PostgreSQL @@ -90,8 +88,8 @@ class check_bigints extends XMLDBCheckAction { $metacolumn = $metacolumns[$xmldb_field->getName()]; // Going to check this field in DB $o.='
  • ' . $this->str['field'] . ': ' . $xmldb_field->getName() . ' '; - // Detect if the physical field is wrong and, under mysql, check for incorrect signed fields too - if ($metacolumn->type != $this->correct_type || ($this->dbfamily == 'mysql' && $xmldb_field->getUnsigned() && !$metacolumn->unsigned)) { + // Detect if the physical field is wrong + if ($metacolumn->type != $this->correct_type) { $o.='' . $this->str['wrong'] . ''; // Add the wrong field to the list $obj = new stdClass(); diff --git a/admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php b/admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php index 1cf39694d67..632d12ea2d0 100644 --- a/admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php +++ b/admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php @@ -88,7 +88,7 @@ class create_xml_file extends XMLDBAction { $c.= ' ' . "\n"; $c.= ' ' . "\n"; $c.= ' ' . "\n"; - $c.= ' ' . "\n"; + $c.= ' ' . "\n"; $c.= ' ' . "\n"; $c.= ' ' . "\n"; $c.= ' ' . "\n"; diff --git a/admin/tool/xmldb/actions/edit_field/edit_field.class.php b/admin/tool/xmldb/actions/edit_field/edit_field.class.php index 2c38399c869..f13ec300bf6 100644 --- a/admin/tool/xmldb/actions/edit_field/edit_field.class.php +++ b/admin/tool/xmldb/actions/edit_field/edit_field.class.php @@ -155,11 +155,6 @@ class edit_field extends XMLDBAction { // xmldb_field Decimals $o.= ' '; $o.= ' '; - // xmldb_field Unsigned - $unsignedoptions = array (0 => 'signed', 1 => 'unsigned'); - $select = html_writer::select($unsignedoptions, 'unsigned', $field->getUnsigned(), false); - $o.= ' '; - $o.= ' '; // xmldb_field NotNull $notnulloptions = array (0 => 'null', 'not null'); $select = html_writer::select($notnulloptions, 'notnull', $field->getNotNull(), false); diff --git a/admin/tool/xmldb/actions/edit_field/edit_field.js b/admin/tool/xmldb/actions/edit_field/edit_field.js index 61aac8bc2c9..b5a45c1377c 100644 --- a/admin/tool/xmldb/actions/edit_field/edit_field.js +++ b/admin/tool/xmldb/actions/edit_field/edit_field.js @@ -50,7 +50,6 @@ function transformForm(event) { var typeField = document.getElementById('menutype'); var lengthField = document.getElementById('length'); var decimalsField = document.getElementById('decimals'); - var unsignedField = document.getElementById('menuunsigned'); var notnullField = document.getElementById('menunotnull'); var sequenceField = document.getElementById('menusequence'); var defaultField = document.getElementById('default'); @@ -60,15 +59,12 @@ function transformForm(event) { // Initially, enable everything decimalsField.disabled = false; - unsignedField.disabled = false; notnullField.disabled = false; sequenceField.disabled = false; defaultField.disabled = false; // Based on sequence, disable some items if (sequenceField.value == '1') { - unsignedField.disabled = true; - unsignedField.value = '1'; notnullField.disabled = true; notnullField.value = '1'; defaultField.disabled = true; @@ -86,22 +82,16 @@ function transformForm(event) { case '2': // XMLDB_TYPE_NUMBER lengthTip.innerHTML = ' 1...20'; decimalsTip.innerHTML = ' 0...length or empty'; - unsignedField.disabled = true; - unsignedField.value = '0'; break; case '3': // XMLDB_TYPE_FLOAT lengthTip.innerHTML = ' 1...20 or empty'; decimalsTip.innerHTML = ' 0...length or empty'; - unsignedField.disabled = true; - unsignedField.value = '0'; break; case '4': // XMLDB_TYPE_CHAR lengthTip.innerHTML = ' 1...1333'; // Hardcoded, yes! decimalsTip.innerHTML = ''; decimalsField.disabled = true; decimalsField.value = ''; - unsignedField.disabled = true; - unsignedField.value = '0'; sequenceField.disabled = true; sequenceField.value = '0'; break; @@ -110,8 +100,6 @@ function transformForm(event) { decimalsTip.innerHTML = ''; decimalsField.disabled = true; decimalsField.value = ''; - unsignedField.disabled = true; - unsignedField.value = '0'; sequenceField.disabled = true; sequenceField.value = '0'; defaultField.disabled = true; @@ -122,8 +110,6 @@ function transformForm(event) { decimalsTip.innerHTML = ''; decimalsField.disabled = true; decimalsField.value = ''; - unsignedField.disabled = true; - unsignedField.value = '0'; sequenceField.disabled = true; sequenceField.value = '0'; defaultField.disabled = true; @@ -136,8 +122,6 @@ function transformForm(event) { decimalsTip.innerHTML = ''; decimalsField.disabled = true; decimalsField.value = ''; - unsignedField.disabled = true; - unsignedField.value = '0'; sequenceField.disabled = true; sequenceField.value = '0'; defaultField.disabled = true; diff --git a/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php b/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php index 0e1f7d86f47..a1b4a80fd0a 100644 --- a/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php +++ b/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php @@ -96,7 +96,6 @@ class edit_field_save extends XMLDBAction { $type = required_param('type', PARAM_INT); $length = strtolower(optional_param('length', NULL, PARAM_ALPHANUM)); $decimals = optional_param('decimals', NULL, PARAM_INT); - $unsigned = optional_param('unsigned', false, PARAM_BOOL); $notnull = optional_param('notnull', false, PARAM_BOOL); $sequence = optional_param('sequence', false, PARAM_BOOL); $default = optional_param('default', NULL, PARAM_PATH); @@ -112,7 +111,6 @@ class edit_field_save extends XMLDBAction { // Perform some automatic assumptions if ($sequence) { - $unsigned = true; $notnull = true; $default = NULL; } @@ -231,7 +229,6 @@ class edit_field_save extends XMLDBAction { $tempfield->setType($type); $tempfield->setLength($length); $tempfield->setDecimals($decimals); - $tempfield->setUnsigned($unsigned); $tempfield->setNotNull($notnull); $tempfield->setSequence($sequence); $tempfield->setDefault($default); @@ -268,7 +265,6 @@ class edit_field_save extends XMLDBAction { $field->setType($type); $field->setLength($length); $field->setDecimals($decimals); - $field->setUnsigned($unsigned); $field->setNotNull($notnull); $field->setSequence($sequence); $field->setDefault($default); diff --git a/admin/tool/xmldb/actions/generate_documentation/xmldb.xsl b/admin/tool/xmldb/actions/generate_documentation/xmldb.xsl index 2bace7f0683..97403f6bad8 100644 --- a/admin/tool/xmldb/actions/generate_documentation/xmldb.xsl +++ b/admin/tool/xmldb/actions/generate_documentation/xmldb.xsl @@ -43,7 +43,6 @@
    ' . $select . '
    (, ) - unsigned not null diff --git a/admin/tool/xmldb/actions/new_table/new_table.class.php b/admin/tool/xmldb/actions/new_table/new_table.class.php index bb34696d5a7..cfdb38522ba 100644 --- a/admin/tool/xmldb/actions/new_table/new_table.class.php +++ b/admin/tool/xmldb/actions/new_table/new_table.class.php @@ -90,7 +90,6 @@ class new_table extends XMLDBAction { $field->setType(XMLDB_TYPE_INTEGER); $field->setLength(10); $field->setNotNull(true); - $field->setUnsigned(true); $field->setSequence(true); $field->setLoaded(true); $field->setChanged(true); diff --git a/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php b/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php index 36a1d8800d1..57c0bd39e6d 100644 --- a/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php +++ b/admin/tool/xmldb/actions/view_table_php/view_table_php.class.php @@ -125,7 +125,6 @@ class view_table_php extends XMLDBAction { $optionspacer . 'rename_field', $optionspacer . 'change_field_type', $optionspacer . 'change_field_precision', - $optionspacer . 'change_field_unsigned', $optionspacer . 'change_field_notnull', $optionspacer . 'change_field_default', $optionspacer . 'drop_enum_from_field', // TODO: Moodle 2.1 - Drop drop_enum_from_field @@ -218,13 +217,6 @@ class view_table_php extends XMLDBAction { $o.= $this->str['mustselectonefield']; } break; - case 'change_field_unsigned': - if ($fieldkeyindexinitial == 'f') { //Only if we have got one field - $o.= s($this->change_field_unsigned_php($structure, $tableparam, $fieldkeyindexparam)); - } else { - $o.= $this->str['mustselectonefield']; - } - break; case 'change_field_notnull': if ($fieldkeyindexinitial == 'f') { // Only if we have got one field $o.= s($this->change_field_notnull_php($structure, $tableparam, $fieldkeyindexparam)); @@ -553,54 +545,6 @@ class view_table_php extends XMLDBAction { return $result; } - /** - * This function will generate all the PHP code needed to - * change the unsigned/signed of one field using XMLDB objects and functions - * - * @param xmldb_structure structure object containing all the info - * @param string table table name - * @param string field field name to change unsigned/signed - */ - function change_field_unsigned_php($structure, $table, $field) { - - $result = ''; - // Validate if we can do it - if (!$table = $structure->getTable($table)) { - return false; - } - if (!$field = $table->getField($field)) { - return false; - } - if ($table->getAllErrors()) { - return false; - } - - // Calculate the unsigned tip text - $unsigned = $field->getUnsigned() ? 'unsigned' : 'signed'; - - // Add the standard PHP header - $result .= XMLDB_PHP_HEADER; - - // Add contents - $result .= XMLDB_LINEFEED; - $result .= ' // Changing sign of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $unsigned . XMLDB_LINEFEED; - $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED; - $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED; - - // Launch the proper DDL - $result .= XMLDB_LINEFEED; - $result .= ' // Launch change of sign for field ' . $field->getName() . XMLDB_LINEFEED; - $result .= ' $dbman->change_field_unsigned($table, $field);' . XMLDB_LINEFEED; - - // Add the proper upgrade_xxxx_savepoint call - $result .= $this->upgrade_savepoint_php ($structure); - - // Add standard PHP footer - $result .= XMLDB_PHP_FOOTER; - - return $result; - } - /** * This function will generate all the PHP code needed to * change the nullability of one field using XMLDB objects and functions diff --git a/admin/tool/xmldb/lang/en/tool_xmldb.php b/admin/tool/xmldb/lang/en/tool_xmldb.php index b24a219f857..ebb48782859 100644 --- a/admin/tool/xmldb/lang/en/tool_xmldb.php +++ b/admin/tool/xmldb/lang/en/tool_xmldb.php @@ -126,7 +126,6 @@ $string['missingindexes'] = 'Missing indexes found'; $string['mustselectonefield'] = 'You must select one field to see field related actions!'; $string['mustselectoneindex'] = 'You must select one index to see index related actions!'; $string['mustselectonekey'] = 'You must select one key to see key related actions!'; -$string['mysqlextracheckbigints'] = 'Under MySQL it also looks for incorrectly signed bigints, generating the required SQL to be executed in order to fix all them.'; $string['newfield'] = 'New field'; $string['newindex'] = 'New index'; $string['newkey'] = 'New key'; diff --git a/lib/dml/database_column_info.php b/lib/dml/database_column_info.php index a6c762af07a..0e8a093625c 100644 --- a/lib/dml/database_column_info.php +++ b/lib/dml/database_column_info.php @@ -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; diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 88309a42af1..ca000f3b165 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -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. */ diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 3f70beff41e..27284ead1c1 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -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) '; } diff --git a/lib/filterlib.php b/lib/filterlib.php index 3496f37951b..f46ce59b8e8 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -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. diff --git a/lib/xmldb/xmldb.xsd b/lib/xmldb/xmldb.xsd index a47f0d43e6f..e7954237820 100644 --- a/lib/xmldb/xmldb.xsd +++ b/lib/xmldb/xmldb.xsd @@ -62,6 +62,7 @@ + diff --git a/lib/xmldb/xmldb_constants.php b/lib/xmldb/xmldb_constants.php index 1454ffca8e9..347f728671d 100644 --- a/lib/xmldb/xmldb_constants.php +++ b/lib/xmldb/xmldb_constants.php @@ -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 diff --git a/lib/xmldb/xmldb_field.php b/lib/xmldb/xmldb_field.php index e272b51e86c..bcede355d15 100644 --- a/lib/xmldb/xmldb_field.php +++ b/lib/xmldb/xmldb_field.php @@ -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';