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

[REF] Fix PHP7.4 Test fails when we are accessing array keys when the… #17649

Merged

Conversation

seamuslee001
Copy link
Contributor

… value is not an array

Overview

This aims to fix a couple of unit tests that fail on PHP 7.4 because we are using array access on values that are either NULL or an Integer

Before

Tests fail on PHP7.4

After

Tests pass on PHP7.4

tests affected are:

  • CRM_Core_BAO_CustomFieldTest::testAlterCustomFieldDisplayValueHook
  • CRM_Core_BAO_CustomFieldTest::testGetDisplayedValuesContactRef

@civibot
Copy link

civibot bot commented Jun 18, 2020

(Standard links)

@civibot civibot bot added the master label Jun 18, 2020
@@ -2049,7 +2049,7 @@ public function whereClause($isForcePrimaryEmailOnly = NULL) {
$this->_params[$id][1]
);
$this->_qill[0][] = ts("%1 %2 %3", [
1 => $field['title'],
1 => $field['title'] ?? '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is set to NULL in L2044 if the $this->_fields doesn't contain an id key

$contact2 = $this->individualCreate(['custom_' . $createdField['id'] => $contact1['id']]);

$this->assertEquals($contact1['display_name'], CRM_Core_BAO_CustomField::displayValue($contact2['id'], $createdField['id']));
$contact2 = $this->individualCreate(['custom_' . $createdField['id'] => $contact1]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

individualCreate() returns an id not an array

@seamuslee001
Copy link
Contributor Author

Jenkins re test this please

@seamuslee001
Copy link
Contributor Author

ping @mattwire @eileenmcnaughton

@eileenmcnaughton eileenmcnaughton merged commit e0c38aa into civicrm:master Jun 18, 2020
@eileenmcnaughton eileenmcnaughton deleted the fix_array_acess_non_array branch June 18, 2020 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants