From efbd3ecc48b72696224d535f9e74085f3cdff0b0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 13 Jun 2013 18:01:40 -0700 Subject: [PATCH] Fix the type of some values passed to MySQL Summary: Ref T3377. MySQL ignores indexes if we hand it mismatched datatypes. This seems colossally dumb, but give it what it expects. Test Plan: wat Reviewers: wez, btrahan Reviewed By: wez CC: aran Maniphest Tasks: T3377 Differential Revision: https://secure.phabricator.com/D6201 --- src/applications/diffusion/query/DiffusionCommitQuery.php | 7 +++++-- .../daemon/PhabricatorRepositoryPullLocalDaemon.php | 6 +++--- .../PhabricatorRepositorySvnCommitChangeParserWorker.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/applications/diffusion/query/DiffusionCommitQuery.php b/src/applications/diffusion/query/DiffusionCommitQuery.php index 05c908e838..cb5ae37c41 100644 --- a/src/applications/diffusion/query/DiffusionCommitQuery.php +++ b/src/applications/diffusion/query/DiffusionCommitQuery.php @@ -144,9 +144,12 @@ final class DiffusionCommitQuery } $sql[] = qsprintf( $conn_r, - '(repositoryID = %d AND commitIdentifier = %d)', + '(repositoryID = %d AND commitIdentifier = %s)', $repo->getID(), - $ref['identifier']); + // NOTE: Because the 'commitIdentifier' column is a string, MySQL + // ignores the index if we hand it an integer. Hand it a string. + // See T3377. + (int)$ref['identifier']); } else { if (strlen($ref['identifier']) < $min_qualified) { continue; diff --git a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php index 5fc45162f6..cac1946506 100644 --- a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php +++ b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php @@ -233,7 +233,7 @@ final class PhabricatorRepositoryPullLocalDaemon } $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( - 'repositoryID = %s AND commitIdentifier = %s', + 'repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $target); @@ -254,7 +254,7 @@ final class PhabricatorRepositoryPullLocalDaemon $target) { $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( - 'repositoryID = %s AND commitIdentifier = %s', + 'repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $target); @@ -362,7 +362,7 @@ final class PhabricatorRepositoryPullLocalDaemon $branch) { $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere( - 'repositoryID = %s AND commitIdentifier = %s', + 'repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $commit_identifier); diff --git a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php index cff194e04f..56b05b388c 100644 --- a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php +++ b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php @@ -498,7 +498,7 @@ final class PhabricatorRepositorySvnCommitChangeParserWorker $commit_data = queryfx_all( $commit_table->establishConnection('w'), 'SELECT id, commitIdentifier FROM %T - WHERE repositoryID = %d AND commitIdentifier in (%Ld)', + WHERE repositoryID = %d AND commitIdentifier in (%Ls)', $commit_table->getTableName(), $repository->getID(), $commits);