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#2039 Fix OpenID::add to ensure is_primary is set #18498

Merged
merged 1 commit into from
Sep 17, 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
8 changes: 8 additions & 0 deletions CRM/Core/BAO/OpenID.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ class CRM_Core_BAO_OpenID extends CRM_Core_DAO_OpenID {
* Create or update OpenID record.
*
* @param array $params
*
* @return CRM_Core_DAO_OpenID
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
*/
public static function add($params) {
if (empty($params['id']) || is_numeric($params['is_primary'] ?? NULL)) {
CRM_Core_BAO_Block::handlePrimary($params, __CLASS__);
}
return self::writeRecord($params);
}

Expand All @@ -38,6 +45,7 @@ public static function add($params) {
* Input parameters to find object.
*
* @return mixed
* @throws \CRM_Core_Exception
*/
public static function &getValues($entityBlock) {
return CRM_Core_BAO_Block::getValues('openid', $entityBlock);
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/api/v3/OpenIDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
*/
class api_v3_OpenIDTest extends CiviUnitTestCase {

/**
* Should location types be checked to ensure primary addresses are correctly assigned after each test.
*
* @var bool
*/
protected $isLocationTypesOnPostAssert = TRUE;

protected $_params;
protected $id;
protected $_entity;
Expand Down