Skip to content

Commit

Permalink
MDL-47812 mod_lti: execute upgrade script for all DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Oct 24, 2014
1 parent 8950e7f commit d4a9e66
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions mod/lti/db/upgradelib.php
Expand Up @@ -32,31 +32,26 @@
function mod_lti_upgrade_custom_separator() {
global $DB;

if ($DB->replace_all_text_supported()) {

// Initialise parameter array.
$params = array('semicolon' => ';', 'likecr' => "%\r%", 'likelf' => "%\n%", 'lf' => "\n");

// Initialise NOT LIKE clauses to check for CR and LF characters.
$notlikecr = $DB->sql_like('value', ':likecr', true, true, true);
$notlikelf = $DB->sql_like('value', ':likelf', true, true, true);

// Update any instances in the lti_types_config table.
$sql = 'UPDATE {lti_types_config} ' .
'SET value = REPLACE(value, :semicolon, :lf) ' .
'WHERE (name = \'customparameters\') AND (' . $notlikecr . ') AND (' . $notlikelf . ')';
$DB->execute($sql, $params);

// Initialise NOT LIKE clauses to check for CR and LF characters.
$notlikecr = $DB->sql_like('instructorcustomparameters', ':likecr', true, true, true);
$notlikelf = $DB->sql_like('instructorcustomparameters', ':likelf', true, true, true);

// Update any instances in the lti table.
$sql = 'UPDATE {lti} ' .
'SET instructorcustomparameters = REPLACE(instructorcustomparameters, :semicolon, :lf) ' .
'WHERE (instructorcustomparameters IS NOT NULL) AND (' . $notlikecr . ') AND (' . $notlikelf . ')';
$DB->execute($sql, $params);

}

// Initialise parameter array.
$params = array('semicolon' => ';', 'likecr' => "%\r%", 'likelf' => "%\n%", 'lf' => "\n");

// Initialise NOT LIKE clauses to check for CR and LF characters.
$notlikecr = $DB->sql_like('value', ':likecr', true, true, true);
$notlikelf = $DB->sql_like('value', ':likelf', true, true, true);

// Update any instances in the lti_types_config table.
$sql = 'UPDATE {lti_types_config} ' .
'SET value = REPLACE(value, :semicolon, :lf) ' .
'WHERE (name = \'customparameters\') AND (' . $notlikecr . ') AND (' . $notlikelf . ')';
$DB->execute($sql, $params);

// Initialise NOT LIKE clauses to check for CR and LF characters.
$notlikecr = $DB->sql_like('instructorcustomparameters', ':likecr', true, true, true);
$notlikelf = $DB->sql_like('instructorcustomparameters', ':likelf', true, true, true);

// Update any instances in the lti table.
$sql = 'UPDATE {lti} ' .
'SET instructorcustomparameters = REPLACE(instructorcustomparameters, :semicolon, :lf) ' .
'WHERE (instructorcustomparameters IS NOT NULL) AND (' . $notlikecr . ') AND (' . $notlikelf . ')';
$DB->execute($sql, $params);
}

0 comments on commit d4a9e66

Please sign in to comment.