From dccba8bcc933acea21e958c475d0c4488925f98c Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Thu, 31 May 2012 10:27:09 +0200 Subject: [PATCH] MDL-33330 Populate referencehash field values --- lib/db/upgrade.php | 13 +++++++++++++ lib/filestorage/file_storage.php | 1 + version.php | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d4f3bdabc9d..411864eff99 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -779,5 +779,18 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012060100.01); } + if ($oldversion < 2012060100.02) { + // Populate referencehash field with SHA1 hash of the reference - this shoudl affect only 2.3dev sites + // that were using the feature for testing. Production sites have the table empty. + $rs = $DB->get_recordset('files_reference', null, '', 'id, reference'); + foreach ($rs as $record) { + $hash = sha1($record->reference); + $DB->set_field('files_reference', 'referencehash', $hash, array('id' => $record->id)); + } + $rs->close(); + + upgrade_main_savepoint(true, 2012060100.02); + } + return true; } diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 14dcf438d2d..872d7966c73 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -1938,6 +1938,7 @@ class file_storage { $id = $DB->insert_record('files_reference', array( 'repositoryid' => $repositoryid, 'reference' => $reference, + 'referencehash' => sha1($reference), 'lastsync' => $lastsync, 'lifetime' => $lifetime)); } catch (dml_exception $e) { diff --git a/version.php b/version.php index b8a6cdee871..88918eaf1fa 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012060100.01; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012060100.02; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes