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#1347 - Fix php warning in advanced search when opening some accordions #15650

Merged
merged 1 commit into from
Oct 30, 2019

Conversation

demeritcowboy
Copy link
Contributor

Overview

https://lab.civicrm.org/dev/core/issues/1347
When opening some accordions on advanced search, the accordion might not have a mapping for $mode, so $mode ends up being false, which gives a warning when used in array_key_exists. The warning doesn't show on screen for some reason, even if you have messages to the screen enabled, but does show up in drupal watchdog.

Before

Warning: array_key_exists(): The first argument should be either a string or an integer in CRM_Contact_Form_Search::getModeValue() (line 305 of .../CRM/Contact/Form/Search.php)

After

""

Technical Details

I wasn't sure if the right fix is to add a mapping, but I'm not sure even what effect the code has anyway because even when there is a mapping e.g. for the activities section, at the point the warning is appearing it still doesn't actually change the mode, which is controlled by the mode field at the top of the form.

Comments

@civibot
Copy link

civibot bot commented Oct 29, 2019

(Standard links)

@civibot civibot bot added the master label Oct 29, 2019
@@ -302,7 +302,8 @@ public static function getModeValue($mode = CRM_Contact_BAO_Query::MODE_CONTACTS
}

self::setModeValues();
if (!array_key_exists($mode, self::$_modeValues)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

or we could cast to an array

if (!array_key_exists($mode, (array) self::$_modeValues)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that help because the warning is the first param, because of the array_search above $mode sometimes ends up being FALSE.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah

@eileenmcnaughton
Copy link
Contributor

@demeritcowboy is this a 5.19 regression? or is master the right choice?

@demeritcowboy
Copy link
Contributor Author

I saw it in 5.14 too. And it doesn't affect search results.

@eileenmcnaughton
Copy link
Contributor

cool - good to go then

@eileenmcnaughton eileenmcnaughton merged commit 18efe70 into civicrm:master Oct 30, 2019
@demeritcowboy demeritcowboy deleted the mode-value-missing branch October 30, 2019 18:51
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