MDL-33587 Throw coding exception when trying to unlink a non-reference file

This commit is contained in:
David Mudrak
2012-06-07 17:36:29 +02:00
parent 2d2c194bbe
commit 2fa8aea279
+8 -1
View File
@@ -196,12 +196,19 @@ class stored_file {
}
/**
* Delete file reference
* Unlink the stored file from the referenced file
*
* This methods destroys the link to the record in files_reference table. This effectively
* turns the stored file from being an alias to a plain copy. However, the caller has
* to make sure that the actual file's content has beed synced prior to calling this method.
*/
public function delete_reference() {
global $DB;
if (!$this->is_external_file()) {
throw new coding_exception('An attempt to unlink a non-reference file.');
}
// Remove repository info.
$this->repository = null;