mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-58684 files: Ensure stored_file never serializes the file_storage
Magic methods __sleep and __wakeup used to properly store only the file_record property and to reinit using get_file_storage().
This commit is contained in:
parent
ac6b845de7
commit
e927581a50
@ -93,6 +93,24 @@ class stored_file {
|
||||
$this->filesystem = $fs->get_file_system();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method, called during serialization.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep() {
|
||||
// We only ever want the file_record saved, not the file_storage object.
|
||||
return ['file_record'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method, called during unserialization.
|
||||
*/
|
||||
public function __wakeup() {
|
||||
// Recreate our stored_file based on the file_record, and using file storage retrieved the correct way.
|
||||
$this->__construct(get_file_storage(), $this->file_record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this is a external resource
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user