1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00

Fix an issue where added or removed source files could incorrectly select a DocumentEngine

Summary:
Ref T13425. The changes in D20865 could incorrectly lead to selection of a DocumentEngine that can not generate document diffs if a file was added or removed (for example, when a source file is added).

Move the engine pruning code to be shared -- we should always discard engines which can't generate a diff, even if we don't have both documents.

Test Plan: Viewed an added source file, no more document ref error arising from document engine selection.

Maniphest Tasks: T13425

Differential Revision: https://secure.phabricator.com/D20866
This commit is contained in:
epriestley 2019-10-26 12:06:45 -07:00
parent 8ff0e3ab35
commit 292f8fc612

View file

@ -1743,12 +1743,6 @@ final class DifferentialChangesetParser extends Phobject {
if ($new_engines !== null && $old_engines !== null) { if ($new_engines !== null && $old_engines !== null) {
$shared_engines = array_intersect_key($new_engines, $old_engines); $shared_engines = array_intersect_key($new_engines, $old_engines);
$default_engine = head_key($new_engines); $default_engine = head_key($new_engines);
foreach ($shared_engines as $key => $shared_engine) {
if (!$shared_engine->canDiffDocuments($old_ref, $new_ref)) {
unset($shared_engines[$key]);
}
}
} else if ($new_engines !== null) { } else if ($new_engines !== null) {
$shared_engines = $new_engines; $shared_engines = $new_engines;
$default_engine = head_key($shared_engines); $default_engine = head_key($shared_engines);
@ -1759,6 +1753,12 @@ final class DifferentialChangesetParser extends Phobject {
return null; return null;
} }
foreach ($shared_engines as $key => $shared_engine) {
if (!$shared_engine->canDiffDocuments($old_ref, $new_ref)) {
unset($shared_engines[$key]);
}
}
$engine_key = $this->getDocumentEngineKey(); $engine_key = $this->getDocumentEngineKey();
if (strlen($engine_key)) { if (strlen($engine_key)) {
if (isset($shared_engines[$engine_key])) { if (isset($shared_engines[$engine_key])) {