Differential D20047 Diff 47883 src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | public function synchronizeWorkingCopyBeforeRead() { | ||||
$versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions( | $versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions( | ||||
$repository_phid); | $repository_phid); | ||||
$versions = mpull($versions, null, 'getDevicePHID'); | $versions = mpull($versions, null, 'getDevicePHID'); | ||||
$this_version = idx($versions, $device_phid); | $this_version = idx($versions, $device_phid); | ||||
if ($this_version) { | if ($this_version) { | ||||
$this_version = (int)$this_version->getRepositoryVersion(); | $this_version = (int)$this_version->getRepositoryVersion(); | ||||
} else { | } else { | ||||
$this_version = -1; | $this_version = null; | ||||
} | } | ||||
if ($versions) { | if ($versions) { | ||||
// This is the normal case, where we have some version information and | // This is the normal case, where we have some version information and | ||||
// can identify which nodes are leaders. If the current node is not a | // can identify which nodes are leaders. If the current node is not a | ||||
// leader, we want to fetch from a leader and then update our version. | // leader, we want to fetch from a leader and then update our version. | ||||
$max_version = (int)max(mpull($versions, 'getRepositoryVersion')); | $max_version = (int)max(mpull($versions, 'getRepositoryVersion')); | ||||
if ($max_version > $this_version) { | if (($this_version === null) || ($max_version > $this_version)) { | ||||
if ($repository->isHosted()) { | if ($repository->isHosted()) { | ||||
$fetchable = array(); | $fetchable = array(); | ||||
foreach ($versions as $version) { | foreach ($versions as $version) { | ||||
if ($version->getRepositoryVersion() == $max_version) { | if ($version->getRepositoryVersion() == $max_version) { | ||||
$fetchable[] = $version->getDevicePHID(); | $fetchable[] = $version->getDevicePHID(); | ||||
} | } | ||||
} | } | ||||
$this->synchronizeWorkingCopyFromDevices( | $this->synchronizeWorkingCopyFromDevices( | ||||
$fetchable, | $fetchable, | ||||
$this_version, | $this_version, | ||||
epriestley: I also traced this variable down the stack, nothing else uses it except the logging which is… | |||||
$max_version); | $max_version); | ||||
} else { | } else { | ||||
$this->synchronizeWorkingCopyFromRemote(); | $this->synchronizeWorkingCopyFromRemote(); | ||||
} | } | ||||
PhabricatorRepositoryWorkingCopyVersion::updateVersion( | PhabricatorRepositoryWorkingCopyVersion::updateVersion( | ||||
$repository_phid, | $repository_phid, | ||||
$device_phid, | $device_phid, | ||||
▲ Show 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | public function synchronizeWorkingCopyAfterDiscovery($new_version) { | ||||
$versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions( | $versions = PhabricatorRepositoryWorkingCopyVersion::loadVersions( | ||||
$repository_phid); | $repository_phid); | ||||
$versions = mpull($versions, null, 'getDevicePHID'); | $versions = mpull($versions, null, 'getDevicePHID'); | ||||
$this_version = idx($versions, $device_phid); | $this_version = idx($versions, $device_phid); | ||||
if ($this_version) { | if ($this_version) { | ||||
$this_version = (int)$this_version->getRepositoryVersion(); | $this_version = (int)$this_version->getRepositoryVersion(); | ||||
} else { | } else { | ||||
$this_version = -1; | $this_version = null; | ||||
} | } | ||||
if ($new_version > $this_version) { | if (($this_version === null) || ($new_version > $this_version)) { | ||||
PhabricatorRepositoryWorkingCopyVersion::updateVersion( | PhabricatorRepositoryWorkingCopyVersion::updateVersion( | ||||
$repository_phid, | $repository_phid, | ||||
$device_phid, | $device_phid, | ||||
$new_version); | $new_version); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 423 Lines • Show Last 20 Lines |
I also traced this variable down the stack, nothing else uses it except the logging which is running into an issue.