From 6f78e2a91c88657dbc6956a86a8a1db1b126e0de Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 8 Sep 2020 12:51:09 -0700 Subject: [PATCH] When a commit is marked "closeable", clear the "published" flag Summary: Ref T13552. When a previously discovered commit becomes reachable from a permanent ref, we re-queue workers to update it. However, the commit may already be marked as "published", so the publish worker may do nothing. It would perhaps be simpler to not mark the commit as published when it isn't reachable from a permanent ref, but this is tricky because the flag is also part of the "imported / all steps" state (see T13580). Until that can be cleaned up, just clear the flag. Test Plan: - Pushed a commit with "fixes X" to a non-permanent branch. - Pushed it to a permanent branch. - Before change: task failed to close. - After change: task closes properly. Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21460 --- .../engine/PhabricatorRepositoryRefEngine.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php index 68e2c344fc..a1b7ae5f55 100644 --- a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php @@ -553,6 +553,7 @@ final class PhabricatorRepositoryRefEngine } $closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE; + $published_flag = PhabricatorRepositoryCommit::IMPORTED_PUBLISH; $all_commits = ipull($all_commits, null, 'commitIdentifier'); foreach ($identifiers as $identifier) { @@ -566,12 +567,21 @@ final class PhabricatorRepositoryRefEngine $identifier)); } - if (!($row['importStatus'] & $closeable_flag)) { + $import_status = $row['importStatus']; + if (!($import_status & $closeable_flag)) { + // Set the "closeable" flag. + $import_status = ($import_status | $closeable_flag); + + // See T13580. Clear the "published" flag, so publishing executes + // again. We may have previously performed a no-op "publish" on the + // commit to make sure it has all bits in the "IMPORTED_ALL" bitmask. + $import_status = ($import_status & ~$published_flag); + queryfx( $conn, - 'UPDATE %T SET importStatus = (importStatus | %d) WHERE id = %d', + 'UPDATE %T SET importStatus = %d WHERE id = %d', $commit_table->getTableName(), - $closeable_flag, + $import_status, $row['id']); $data = array(