Permalink
Browse files

MDL-34441 tool_dbtranfer - fix codechecker warnings

Since we were so close to perfection.
  • Loading branch information...
1 parent 55bf451 commit c237be89fbf3bae6ed885b3d10a456349050ed72 @danpoltawski danpoltawski committed Jul 25, 2012
@@ -90,7 +90,7 @@
if (!isset($options['dbtype'])) {
$choose = array();
- foreach ($drivers as $driver=>$name) {
+ foreach ($drivers as $driver => $name) {
list($dbtype, $dblibrary) = explode('/', $driver);
$choose[$dbtype] = $dbtype;
}
@@ -100,15 +100,15 @@
}
$choose = array();
-foreach ($drivers as $driver=>$name) {
+foreach ($drivers as $driver => $name) {
list($dbtype, $dblibrary) = explode('/', $driver);
if ($dbtype === $options['dbtype']) {
$choose[$dblibrary] = $dblibrary;
}
}
if (!isset($options['dblibrary']) or !isset($choose[$options['dblibrary']])) {
$optionsstr = implode(', ', $choose);
- cli_heading('Database library'." ($optionsstr)"); // note: no need to localise unless we add real PDO drivers
+ cli_heading('Database library'." ($optionsstr)"); // Note: no need to localise unless we add real PDO drivers.
$options['dblibrary'] = cli_input(get_string('clitypevalue', 'admin'), '', $choose, true);
}
@@ -149,7 +149,8 @@
}
}
-$a = (object)array('dbtypefrom'=>$CFG->dbtype, 'dbtype'=>$options['dbtype'], 'dbname'=>$options['dbname'], 'dbhost'=>$options['dbhost']);
+$a = (object)array('dbtypefrom' => $CFG->dbtype, 'dbtype' => $options['dbtype'],
+ 'dbname' => $options['dbname'], 'dbhost' => $options['dbhost']);
cli_heading(get_string('transferringdbto', 'tool_dbtransfer', $a));
// Try target DB connection.
@@ -164,7 +165,8 @@
$dboptions['dbsocket'] = $options['dbsocket'];
}
try {
- $targetdb->connect($options['dbhost'], $options['dbuser'], $options['dbpass'], $options['dbname'], $options['prefix'], $dboptions);
+ $targetdb->connect($options['dbhost'], $options['dbuser'], $options['dbpass'], $options['dbname'],
+ $options['prefix'], $dboptions);
if ($targetdb->get_tables()) {
$problem .= get_string('targetdatabasenotempty', 'tool_dbtransfer');
}
@@ -29,10 +29,16 @@
/**
* Definition of db export settings form.
+ *
+ * @package tool_dbtransfer
+ * @copyright 2008 Petr Skoda {@link http://skodak.org/}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class database_export_form extends moodleform {
-
- function definition() {
+ /**
+ * Define the export form.
+ */
+ public function definition() {
$mform = $this->_form;
$mform->addElement('header', 'database', get_string('dbexport', 'tool_dbtransfer'));
@@ -30,6 +30,9 @@
/**
* Definition of db transfer settings form.
+ *
+ * @copyright 2008 Petr Skoda {@link http://skodak.org/}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class database_transfer_form extends moodleform {
@@ -40,6 +40,6 @@
}
echo $OUTPUT->header();
-// TODO: add some more info here
+// TODO: add some more info here.
$form->display();
echo $OUTPUT->footer();
@@ -52,7 +52,7 @@
function tool_dbtransfer_export_xml_database($description, $mdb) {
@set_time_limit(0);
- session_get_instance()->write_close(); // release session
+ session_get_instance()->write_close(); // Release session.
header('Content-Type: application/xhtml+xml; charset=utf-8');
header('Content-Disposition: attachment; filename=database.xml');
@@ -65,7 +65,7 @@ function tool_dbtransfer_export_xml_database($description, $mdb) {
$var = new file_xml_database_exporter('php://output', $mdb);
$var->export_database($description);
- // no more output
+ // No more output.
die;
}
@@ -79,7 +79,7 @@ function tool_dbtransfer_export_xml_database($description, $mdb) {
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
@set_time_limit(0);
- session_get_instance()->write_close(); // release session
+ session_get_instance()->write_close(); // Release session.
$var = new database_mover($sourcedb, $targetdb, true, $feedback);
$var->export_database(null);
@@ -106,9 +106,9 @@ function tool_dbtransfer_rebuild_target_log_actions(moodle_database $target, pro
$DB->delete_records('log_display', array('component'=>'moodle'));
log_update_descriptions('moodle');
$plugintypes = get_plugin_types();
- foreach ($plugintypes as $type=>$location) {
+ foreach ($plugintypes as $type => $location) {
$plugs = get_plugin_list($type);
- foreach ($plugs as $plug=>$fullplug) {
+ foreach ($plugs as $plug => $fullplug) {
$component = $type.'_'.$plug;
$DB->delete_records('log_display', array('component'=>$component));
log_update_descriptions($component);
@@ -25,7 +25,9 @@
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
- $ADMIN->add('experimental', new admin_externalpage('tooldbtransfer', get_string('dbtransfer', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/index.php', 'moodle/site:config', false));
+ $ADMIN->add('experimental', new admin_externalpage('tooldbtransfer', get_string('dbtransfer', 'tool_dbtransfer'),
+ $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/index.php', 'moodle/site:config', false));
// DB export/import is not ready yet - keep it hidden for now.
- $ADMIN->add('experimental', new admin_externalpage('tooldbexport', get_string('dbexport', 'tool_dbtransfer'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/dbexport.php', 'moodle/site:config', true));
+ $ADMIN->add('experimental', new admin_externalpage('tooldbexport', get_string('dbexport', 'tool_dbtransfer'),
+ $CFG->wwwroot.'/'.$CFG->admin.'/tool/dbtransfer/dbexport.php', 'moodle/site:config', true));
}
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2012062200; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2012061700; // Requires this Moodle version
-$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics)
+$plugin->version = 2012062200; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2012061700; // Requires this Moodle version.
+$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics).

0 comments on commit c237be8

Please sign in to comment.