diff --git a/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php b/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php new file mode 100644 index 00000000000..97248cd1bed --- /dev/null +++ b/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php @@ -0,0 +1,153 @@ +. + +/** + * @package xmldb-editor + * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * This class will check all the varchar2() columns + * in the Moodle installed DB, looking for incorrect (INT) + * length semanticas providing one SQL script to fix all + * them by changing to cross-db (CHAR) length semantics. + * See MDL-29322 for more details. + * + * @package xmldb-editor + * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class check_oracle_semantics extends XMLDBCheckAction { + + /** + * Init method, every subclass will have its own + */ + function init() { + $this->introstr = 'confirmcheckoraclesemantics'; + parent::init(); + + // Set own core attributes + + // Set own custom attributes + + // Get needed strings + $this->loadStrings(array( + 'wrongoraclesemantics' => 'tool_xmldb', + 'nowrongoraclesemanticsfound' => 'tool_xmldb', + 'yeswrongoraclesemanticsfound' => 'tool_xmldb', + 'expected' => 'tool_xmldb', + 'actual' => 'tool_xmldb', + )); + } + + protected function check_table(xmldb_table $xmldb_table, array $metacolumns) { + global $DB; + $o = ''; + $wrong_fields = array(); + + // Get and process XMLDB fields + if ($xmldb_fields = $xmldb_table->getFields()) { + $o .= '
';
+ $r.= ' ' . $this->str['searchresults'] . ''; + $r.= '' . $this->str['wrongoraclesemantics'] . ': ' . count($wrong_fields) . ' '; + $r.= ' |
| ';
+
+ // If we have found wrong defaults inform about them
+ if (count($wrong_fields)) {
+ $r.= ' ' . $this->str['yeswrongoraclesemanticsfound'] . ' '; + $r.= '
' . str_replace("\n", ''; + } + $r.= ' ' . $s; + } else { + $r.= ' ' . $this->str['nowrongoraclesemanticsfound'] . ' '; + } + $r.= ' |
| ';
+ // Add the complete log message
+ $r.= ' ' . $this->str['completelogbelow'] . ' '; + $r.= ' |