1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

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:
epriestley 2013-02-13 14:45:57 -08:00
parent 262abd39bc
commit 4f42d85c1c

View file

@ -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) {