Skip to content

Commit

Permalink
Merge branch 'wip-MDL-33416-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
Sam Hemelryk committed Sep 30, 2013
2 parents 00a2879 + e2a61ee commit 4754755
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
4 changes: 1 addition & 3 deletions lib/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20130921" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20130927" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -2437,8 +2437,6 @@
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="order of files"/>
<FIELD NAME="referencefileid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Use to indicate file is a proxy for repository file"/>
<FIELD NAME="referencelastsync" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="Last time the proxy file was synced with repository, defined for performance reasons"/>
<FIELD NAME="referencelifetime" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="How often do we have to sync proxy file with repository, defined for performance reasons"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
24 changes: 24 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2555,5 +2555,29 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013092001.02);
}

if ($oldversion < 2013092700.01) {

$table = new xmldb_table('files');

// Define field referencelastsync to be dropped from files.
$field = new xmldb_field('referencelastsync');

// Conditionally launch drop field referencelastsync.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}

// Define field referencelifetime to be dropped from files.
$field = new xmldb_field('referencelifetime');

// Conditionally launch drop field referencelifetime.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2013092700.01);
}

return true;
}
6 changes: 1 addition & 5 deletions lib/filestorage/file_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,10 +1400,6 @@ public function create_file_from_reference($filerecord, $repositoryid, $referenc
$filerecord->sortorder = 0;
}

// TODO MDL-33416 [2.4] fields referencelastsync and referencelifetime to be removed from {files} table completely
unset($filerecord->referencelastsync);
unset($filerecord->referencelifetime);

$filerecord->mimetype = empty($filerecord->mimetype) ? $this->mimetype($filerecord->filename) : $filerecord->mimetype;
$filerecord->userid = empty($filerecord->userid) ? null : $filerecord->userid;
$filerecord->source = empty($filerecord->source) ? null : $filerecord->source;
Expand Down Expand Up @@ -2345,7 +2341,7 @@ public function update_references($referencefileid, $lastsync, $lifetime, $conte
'lastsync' => $lastsync,
'lifetime' => $lifetime);
$DB->execute('UPDATE {files} SET contenthash = :contenthash, filesize = :filesize,
status = :status, referencelastsync = :lastsync, referencelifetime = :lifetime
status = :status
WHERE referencefileid = :referencefileid', $params);
$data = array('id' => $referencefileid, 'lastsync' => $lastsync, 'lifetime' => $lifetime);
$DB->update_record('files_reference', (object)$data);
Expand Down
6 changes: 0 additions & 6 deletions lib/filestorage/stored_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ protected function update($dataobject) {
}
}

if ($field === 'referencelastsync' or $field === 'referencelifetime') {
// do not update those fields
// TODO MDL-33416 [2.4] fields referencelastsync and referencelifetime to be removed from {files} table completely
continue;
}

// adding the field
$this->file_record->$field = $value;
} else {
Expand Down
3 changes: 2 additions & 1 deletion repository/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ http://docs.moodle.org/dev/Repository_API
* The function repository_attach_id() was removed, it was never used and was not useful.
* New functions send_relative_file() and supports_relative_file() to allow sending relative linked
files - see filesystem repository for example.

* DB fields files.referencelifetime and files.referencelastsync are deleted.
Their values are stored only in files_reference.lastsync and files_reference.lifetime.

=== 2.5 ===

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2013092700.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2013092700.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 4754755

Please sign in to comment.