Skip to content

Commit

Permalink
MDL-46963 environment: add check for antelope row format
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Apr 13, 2015
1 parent d705b4a commit 742bb09
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions admin/environment.xml
Expand Up @@ -1262,6 +1262,11 @@
<ON_CHECK message="slashargumentswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
<FEEDBACK>
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
<MOODLE version="2.9" requires="2.2">
Expand Down Expand Up @@ -1395,6 +1400,11 @@
<ON_CHECK message="slashargumentswarning" />
</FEEDBACK>
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
<FEEDBACK>
<ON_CHECK message="unsupporteddbtablerowformat" />
</FEEDBACK>
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -1062,6 +1062,7 @@
$string['unsettheme'] = 'Unset theme';
$string['unsupported'] = 'Unsupported';
$string['unsupporteddbstorageengine'] = 'The database storage engine being used is no longer supported.';
$string['unsupporteddbtablerowformat'] = 'Your database has tables using Antelope as the file format. You are recommended to convert the tables to the Barracuda file format. See the documentation <a href="https://docs.moodle.org/en/cli">Administration via command line</a> for details of a tool for converting InnoDB tables to Barracuda.';
$string['unsuspenduser'] = 'Activate user account';
$string['updateaccounts'] = 'Update existing accounts';
$string['updatecomponent'] = 'Update component';
Expand Down
32 changes: 32 additions & 0 deletions lib/upgradelib.php
Expand Up @@ -2245,3 +2245,35 @@ function check_slasharguments(environment_results $result){

return null;
}

/**
* This function verifies if the database has tables using innoDB Antelope row format.
*
* @param environment_results $result
* @return environment_results|null updated results object, or null if no Antelope table has been found.
*/
function check_database_tables_row_format(environment_results $result) {
global $DB;

if ($DB->get_dbfamily() == 'mysql') {
$generator = $DB->get_manager()->generator;

foreach ($DB->get_tables(false) as $table) {
$columns = $DB->get_columns($table, false);
$size = $generator->guess_antolope_row_size($columns);
$format = $DB->get_row_format($table);

if ($size <= $generator::ANTELOPE_MAX_ROW_SIZE) {
continue;
}

if ($format === 'Compact' or $format === 'Redundant') {
$result->setInfo('unsupported_db_table_row_format');
$result->setStatus(false);
return $result;
}
}
}

return null;
}

0 comments on commit 742bb09

Please sign in to comment.