mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-44682 fix bug in decompose_update_into_safe_changes
This commit is contained in:
parent
9b8555fbea
commit
c35cf42e55
@ -2036,7 +2036,7 @@ function decompose_update_into_safe_changes(array $newvalues, $unusedvalue) {
|
||||
$next = $nontrivialmap[$current];
|
||||
unset($nontrivialmap[$current]);
|
||||
$current = $next;
|
||||
} while ($current !== $cyclestart);
|
||||
} while ($current != $cyclestart);
|
||||
|
||||
// Now convert it to a sequence of safe renames by using a temp.
|
||||
$safechanges[] = array($cyclestart, $unusedvalue);
|
||||
|
@ -77,6 +77,14 @@ class datalib_update_with_unique_index_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
public function test_decompose_update_into_safe_changes_string_values() {
|
||||
// Sometimes this happens when data has been loaded from the database.
|
||||
$this->assertEquals(array(array(1, -1), array(2, 1),
|
||||
array(3, 2), array(4, 3), array(-1, 4)),
|
||||
decompose_update_into_safe_changes(
|
||||
array(1 => '4', 2 => '1', 3 => '2', 4 => '3'), -1));
|
||||
}
|
||||
|
||||
public function test_reorder_rows() {
|
||||
global $DB;
|
||||
$dbman = $DB->get_manager();
|
||||
|
Loading…
x
Reference in New Issue
Block a user