Use a serialize()-based cache instead of a JSON-based cache for changesets
Summary: These are full of PhutilSafeHTML objects now, which are destroyed by JSON serialization. Test Plan: Dropped cache, then reloaded pages. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4942
This commit is contained in:
@@ -63,7 +63,7 @@ final class DifferentialChangesetParser {
|
||||
return $this->disableCache;
|
||||
}
|
||||
|
||||
const CACHE_VERSION = 10;
|
||||
const CACHE_VERSION = 11;
|
||||
const CACHE_MAX_SIZE = 8e6;
|
||||
|
||||
const ATTR_GENERATED = 'attr:generated';
|
||||
@@ -270,7 +270,13 @@ final class DifferentialChangesetParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = json_decode($data['cache'], true);
|
||||
if ($data['cache'][0] == '{') {
|
||||
// This is likely an old-style JSON cache which we will not be able to
|
||||
// deserialize.
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = unserialize($data['cache']);
|
||||
if (!is_array($data) || !$data) {
|
||||
return false;
|
||||
}
|
||||
@@ -340,7 +346,7 @@ final class DifferentialChangesetParser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$cache = json_encode($cache);
|
||||
$cache = serialize($cache);
|
||||
|
||||
// We don't want to waste too much space by a single changeset.
|
||||
if (strlen($cache) > self::CACHE_MAX_SIZE) {
|
||||
|
||||
Reference in New Issue
Block a user