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
@@ -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.=' <li>' . $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.='<font color="red">' . $this->str['wrong'] . '</font>';
|
||||
// Add the wrong field to the list
|
||||
$obj = new stdClass();
|
||||
|
||||
@@ -88,7 +88,7 @@ class create_xml_file extends XMLDBAction {
|
||||
$c.= ' <TABLES>' . "\n";
|
||||
$c.= ' <TABLE NAME="' . $xmltable . '" COMMENT="Default comment for ' . $xmltable .', please edit me">' . "\n";
|
||||
$c.= ' <FIELDS>' . "\n";
|
||||
$c.= ' <FIELD NAME="id" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" SEQUENCE="true" />' . "\n";
|
||||
$c.= ' <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />' . "\n";
|
||||
$c.= ' </FIELDS>' . "\n";
|
||||
$c.= ' <KEYS>' . "\n";
|
||||
$c.= ' <KEY NAME="primary" TYPE="primary" FIELDS="id" />' . "\n";
|
||||
|
||||
@@ -155,11 +155,6 @@ class edit_field extends XMLDBAction {
|
||||
// xmldb_field Decimals
|
||||
$o.= ' <tr valign="top"><td><label for="decimals" accesskey="d">Decimals:</label></td>';
|
||||
$o.= ' <td colspan="2"><input name="decimals" type="text" size="6" maxlength="6" id="decimals" value="' . s($field->getDecimals()) . '" /><span id="decimalstip"></span></td></tr>';
|
||||
// xmldb_field Unsigned
|
||||
$unsignedoptions = array (0 => 'signed', 1 => 'unsigned');
|
||||
$select = html_writer::select($unsignedoptions, 'unsigned', $field->getUnsigned(), false);
|
||||
$o.= ' <tr valign="top"><td><label for="menuunsigned" accesskey="u">Unsigned:</label></td>';
|
||||
$o.= ' <td colspan="2">' . $select . '</td></tr>';
|
||||
// xmldb_field NotNull
|
||||
$notnulloptions = array (0 => 'null', 'not null');
|
||||
$select = html_writer::select($notnulloptions, 'notnull', $field->getNotNull(), false);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
<td class="cell c1" style="white-space: nowrap;">
|
||||
<xsl:value-of select="@TYPE"/>
|
||||
(<xsl:value-of select="@LENGTH"/><xsl:if test="@DECIMALS">, <xsl:value-of select="@DECIMALS"/></xsl:if>)
|
||||
<xsl:if test="@UNSIGNED='true'">unsigned </xsl:if>
|
||||
<xsl:if test="@NOTNULL='true'">not null </xsl:if>
|
||||
<xsl:if test="@DEFAULT">
|
||||
<xsl:choose>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user