mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-33416 files: Remove unused reference fields in files table
Fields files.referencelastsync and files.referencelifetime just waste the space and actually duplicate the fields files_reference.lifetime and files_reference.lastsync
This commit is contained in:
parent
d45e65ccad
commit
e2a61ee3db
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?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"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||||
>
|
>
|
||||||
@ -2437,8 +2437,6 @@
|
|||||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
<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="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="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>
|
</FIELDS>
|
||||||
<KEYS>
|
<KEYS>
|
||||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||||
|
@ -2555,5 +2555,29 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
upgrade_main_savepoint(true, 2013092001.02);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1400,10 +1400,6 @@ class file_storage {
|
|||||||
$filerecord->sortorder = 0;
|
$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->mimetype = empty($filerecord->mimetype) ? $this->mimetype($filerecord->filename) : $filerecord->mimetype;
|
||||||
$filerecord->userid = empty($filerecord->userid) ? null : $filerecord->userid;
|
$filerecord->userid = empty($filerecord->userid) ? null : $filerecord->userid;
|
||||||
$filerecord->source = empty($filerecord->source) ? null : $filerecord->source;
|
$filerecord->source = empty($filerecord->source) ? null : $filerecord->source;
|
||||||
@ -2345,7 +2341,7 @@ class file_storage {
|
|||||||
'lastsync' => $lastsync,
|
'lastsync' => $lastsync,
|
||||||
'lifetime' => $lifetime);
|
'lifetime' => $lifetime);
|
||||||
$DB->execute('UPDATE {files} SET contenthash = :contenthash, filesize = :filesize,
|
$DB->execute('UPDATE {files} SET contenthash = :contenthash, filesize = :filesize,
|
||||||
status = :status, referencelastsync = :lastsync, referencelifetime = :lifetime
|
status = :status
|
||||||
WHERE referencefileid = :referencefileid', $params);
|
WHERE referencefileid = :referencefileid', $params);
|
||||||
$data = array('id' => $referencefileid, 'lastsync' => $lastsync, 'lifetime' => $lifetime);
|
$data = array('id' => $referencefileid, 'lastsync' => $lastsync, 'lifetime' => $lifetime);
|
||||||
$DB->update_record('files_reference', (object)$data);
|
$DB->update_record('files_reference', (object)$data);
|
||||||
|
@ -156,12 +156,6 @@ class stored_file {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// adding the field
|
||||||
$this->file_record->$field = $value;
|
$this->file_record->$field = $value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -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.
|
* 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
|
* New functions send_relative_file() and supports_relative_file() to allow sending relative linked
|
||||||
files - see filesystem repository for example.
|
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 ===
|
=== 2.5 ===
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
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.
|
// RR = release increments - 00 in DEV branches.
|
||||||
// .XX = incremental changes.
|
// .XX = incremental changes.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user