Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2102 Fix hang on event edit #18713

Merged
merged 1 commit into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Event/Form/ManageEvent/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function postProcess() {
CRM_Event_BAO_Event::deleteEventLocBlock($this->_oldLocBlockId, $this->_id);
}

$isUpdateToExistingLocationBlock = !empty($params['loc_event_id']) && (int) $params['loc_event_id'] === $this->locationBlock['loc_block_id'];
$isUpdateToExistingLocationBlock = !$deleteOldBlock && !empty($params['loc_event_id']) && (int) $params['loc_event_id'] === $this->locationBlock['loc_block_id'];
// It should be impossible for there to be no default location type. Consider removing this handling
$defaultLocationTypeID = CRM_Core_BAO_LocationType::getDefault()->id ?? 1;

Expand Down
70 changes: 70 additions & 0 deletions tests/phpunit/CRM/Event/Form/ManageEvent/LocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,76 @@ public function testCreateWithLocBlock() {
$this->eventDelete($eventID);
}

/**
* Test updating a location block.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function testUpdateLocationBlock() {
$eventID = (int) $this->eventCreate()['id'];
$this->submitForm([
'address' => [
'1' => [
'street_address' => 'Old address',
'supplemental_address_1' => 'Hallmark Ct',
'supplemental_address_2' => 'Jersey Village',
'supplemental_address_3' => 'My Town',
'city' => 'Newark',
'postal_code' => '01903',
'country_id' => 1228,
'state_province_id' => 1029,
'geo_code_1' => '18.219023',
'geo_code_2' => '-105.00973',
'is_primary' => 1,
'location_type_id' => 1,
],
],
], $eventID);

$this->submitForm([
'location_option' => 1,
'loc_event_id' => Event::get()->addWhere('id', '=', $eventID)->addSelect('loc_block_id')->execute()->first()['loc_block_id'],
'address' => [
'1' => [
'street_address' => 'New address',
'supplemental_address_1' => 'Hallmark Ct',
'supplemental_address_2' => 'Jersey Village',
'supplemental_address_3' => 'My Town',
'city' => 'Newark',
'postal_code' => '01903',
'country_id' => 1228,
'state_province_id' => 1029,
'geo_code_1' => '18.219023',
'geo_code_2' => '-105.00973',
],
],
'email' => [
'1' => [
'email' => '',
],
'2' => [
'email' => '',
],
],
'phone' => [
'1' => [
'phone_type_id' => 1,
'phone' => '',
'phone_ext' => '',
],
'2' => [
'phone_type_id' => 1,
'phone' => '',
'phone_ext' => '',
],
],
], $eventID);
// Cleanup.
$this->eventDelete($eventID);
}

/**
* Get the values to submit for the form.
*
Expand Down