Skip to content

Commit

Permalink
Merge branch 'MDL-58684-master-fix1' of https://github.com/snake/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 8, 2017
2 parents ac6b845 + e927581 commit 1d5a366
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/filestorage/stored_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ public function __construct(file_storage $fs, stdClass $file_record, $deprecated
$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
*
Expand Down

0 comments on commit 1d5a366

Please sign in to comment.