Skip to content

Commit

Permalink
fix(memcache): don't store a copy of $CONFIG in file objects
Browse files Browse the repository at this point in the history
Since filestore objects keep a copy of $CONFIG as a property, this would
get serialized with the ElggFile. We add a __sleep method to filter out
this property when serializing, and __wakeup to reinitialize it.

Fixes Elgg#9081
  • Loading branch information
mrclay committed Nov 5, 2015
1 parent 45688ef commit 3609935
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions engine/classes/ElggFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,29 @@ public function save() {

return true;
}

/**
* Get property names to serialize.
*
* @return string[]
*/
public function __sleep() {
return array_diff(array_keys(get_object_vars($this)), array(
// Don't persist filestore, which contains CONFIG
// https://github.com/Elgg/Elgg/issues/9081#issuecomment-152859856
'filestore',

// a resource
'handle',
));
}

/**
* Reestablish filestore property
*
* @throws ClassNotFoundException
*/
public function __wakeup() {
$this->getFilestore();
}
}

0 comments on commit 3609935

Please sign in to comment.