Skip to content

Commit c728e4f

Browse files
author
jungejason
committed
Open database connection with 'w' instead of 'r' for writing
Summary: there are several places we open an 'r' connection but use it for writing. Fix them. Test Plan: ran parse_one_commit.php against one revision which executes the code with problem. It used to throw exception. Now it works fine. Reviewed By: Girish Reviewers: tuomaspelkonen, Girish Commenters: aran CC: aran, Girish Differential Revision: 213
1 parent 6bec3d2 commit c728e4f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

scripts/repository/rebuild_summaries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
$commit = new PhabricatorRepositoryCommit();
2929

30-
$conn_w = id(new PhabricatorRepository())->establishConnection('r');
30+
$conn_w = id(new PhabricatorRepository())->establishConnection('w');
3131
$sizes = queryfx_all(
3232
$conn_w,
3333
'SELECT repositoryID, count(*) N FROM %T GROUP BY repositoryID',

src/applications/repository/daemon/commitdiscovery/base/PhabricatorRepositoryCommitDiscoveryDaemon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function recordCommit($commit_identifier, $epoch) {
7676
$event->recordEvent();
7777

7878
queryfx(
79-
$repository->establishConnection('r'),
79+
$repository->establishConnection('w'),
8080
'INSERT INTO %T (repositoryID, size, lastCommitID, epoch)
8181
VALUES (%d, 1, %d, %d)
8282
ON DUPLICATE KEY UPDATE

src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final protected function updateCommitData($author, $message) {
5151
if ($revision) {
5252

5353
queryfx(
54-
$revision->establishConnection('r'),
54+
$revision->establishConnection('w'),
5555
'INSERT IGNORE INTO %T (revisionID, commitPHID) VALUES (%d, %s)',
5656
DifferentialRevision::TABLE_COMMIT,
5757
$revision->getID(),

0 commit comments

Comments
 (0)