From 3fa0daa90f3b872cba807ddb8a94d9adeb65689f Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 17 Oct 2014 13:28:46 +0800 Subject: [PATCH] MDL-47664 phpunit: Do not use sequence number changes for Oracle When resetting a sequence number, we call change_database_structure() which in turns clears the MUC cache for databasemeta. This cache contains information about the table, columns, etc. After the cache is cleared, it must be re-filled, and it was discovered that the get_columns() code which fills this cache can take a particularly long time. Given that this is called for every table in Moodle, this can add up to a significant period, and this is done on a per-testsuite basis. On my SSD install this was taking approximately 40 seconds on each re-fill of the cache. --- lib/testing/classes/util.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index c6b560a9579..520cb775183 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -527,7 +527,12 @@ abstract class testing_util { foreach ($data as $table => $records) { if (isset($structure[$table]['id']) and $structure[$table]['id']->auto_increment) { - $nextid = self::get_next_sequence_starting_value($records); + $lastrecord = end($records); + if ($lastrecord) { + $nextid = $lastrecord->id + 1; + } else { + $nextid = 1; + } if (!isset($current[$table])) { $DB->get_manager()->reset_sequence($table); } else if ($nextid == $current[$table]) {