From d744d5d85995664f70d0cb024ee1ab606343840c Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 17 May 2014 16:34:13 -0700 Subject: [PATCH] Fix binary/utf8 issues with Differential changeset parse cache Summary: Fixes T4898. After we increased the strictness of the `%s` conversion, most `serialize()` output is rejected from the cache. Drop the cache, change the column type to latin1_bin, and then use `%B` to mark the data as binary during query construction. Test Plan: Viewed Differential, saw cache fills. Reviewers: btrahan, spicyj Reviewed By: spicyj Subscribers: epriestley Maniphest Tasks: T4898 Differential Revision: https://secure.phabricator.com/D9171 --- .../sql/autopatches/20140517.dxbinarycache.sql | 4 ++++ .../parser/DifferentialChangesetParser.php | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 resources/sql/autopatches/20140517.dxbinarycache.sql diff --git a/resources/sql/autopatches/20140517.dxbinarycache.sql b/resources/sql/autopatches/20140517.dxbinarycache.sql new file mode 100644 index 0000000000..acf7162b65 --- /dev/null +++ b/resources/sql/autopatches/20140517.dxbinarycache.sql @@ -0,0 +1,4 @@ +TRUNCATE {$NAMESPACE}_differential.differential_changeset_parse_cache; + +ALTER TABLE {$NAMESPACE}_differential.differential_changeset_parse_cache + CHANGE cache cache LONGTEXT COLLATE latin1_bin NOT NULL; diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index 637b3ac363..c437ee43f2 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -352,22 +352,19 @@ final class DifferentialChangesetParser { return; } - try { - $changeset = new DifferentialChangeset(); - $conn_w = $changeset->establishConnection('w'); + $changeset = new DifferentialChangeset(); + $conn_w = $changeset->establishConnection('w'); - $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); + $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx( $conn_w, - 'INSERT INTO %T (id, cache, dateCreated) VALUES (%d, %s, %d) + 'INSERT INTO %T (id, cache, dateCreated) VALUES (%d, %B, %d) ON DUPLICATE KEY UPDATE cache = VALUES(cache)', DifferentialChangeset::TABLE_CACHE, $render_cache_key, $cache, time()); - } catch (AphrontQueryException $ex) { - // TODO: uhoh - } + unset($unguarded); } private function markGenerated($new_corpus_block = '') {