1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

Fix a problem with recording image replacement, every other mock update

Summary:
This fixes a weird issue which currently doesn't have much impact on things, but starts to matter if we do the grid.

We're incorrectly initializing the form with `replacesPHID` as the //previously replaced Image PHID//. It is supposed to be the //current File PHID//.

Every other time, this is `null` and things work properly. On even updates (2, 4, 6, etc.), it's wrong and we don't record the replacement completely correctly.

Test Plan: Replaced images twice, saw three rows of thumb grid.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9541
This commit is contained in:
epriestley 2014-06-14 21:02:00 -07:00
parent 2bbafcc924
commit 3a36f1e31c

View file

@ -135,9 +135,11 @@ final class PholioMockEditController extends PholioController {
$replaces_image_phid = null;
if (isset($replaces_map[$file_phid])) {
$old_file_phid = $replaces_map[$file_phid];
$old_image = idx($mock_images, $old_file_phid);
if ($old_image) {
$replaces_image_phid = $old_image->getPHID();
if ($old_file_phid != $file_phid) {
$old_image = idx($mock_images, $old_file_phid);
if ($old_image) {
$replaces_image_phid = $old_image->getPHID();
}
}
}
@ -158,7 +160,7 @@ final class PholioMockEditController extends PholioController {
$xactions[] = id(new PholioTransaction())
->setTransactionType(
PholioTransactionType::TYPE_IMAGE_REPLACE)
->setNewValue($replace_image);
->setNewValue($replace_image);
$posted_mock_images[] = $replace_image;
} else if (!$existing_image) { // this is an add
$add_image = id(new PholioImage())
@ -256,7 +258,7 @@ final class PholioMockEditController extends PholioController {
$image_elements[] = id(new PholioUploadedImageView())
->setUser($user)
->setImage($mock_image)
->setReplacesPHID($mock_image->getReplacesImagePHID());
->setReplacesPHID($mock_image->getFilePHID());
}
$list_id = celerity_generate_unique_node_id();