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] CRM_Utils_Array::value() -> empty() #16704

Merged
merged 1 commit into from
Mar 8, 2020

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Mar 7, 2020

Overview

Replaces CRM_Utils_Array::value() with empty() when the value is immediately cast to boolean.
The two statements have identical meaning but the latter is faster & easier to read.

Technical Details

Before/after should be functionally identical.

Comments

This was done via regex with some spot-checking.

@civibot
Copy link

civibot bot commented Mar 7, 2020

(Standard links)

@civibot civibot bot added the master label Mar 7, 2020
@colemanw colemanw force-pushed the arrayValue1 branch 2 times, most recently from b716053 to 7396bec Compare March 7, 2020 18:07
@@ -546,7 +546,7 @@ public function preProcess() {

// assign context to drive the template display, make sure context is valid
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
if (!CRM_Utils_Array::value($this->_context, self::validContext())) {
if (!array_key_exists($this->_context, self::validContext())) {
Copy link
Contributor

@demeritcowboy demeritcowboy Mar 7, 2020

Choose a reason for hiding this comment

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

Theoretically these aren't equal. I don't see any code outside this class that manipulates the $_validContext property directly (which is what is returned by self::validContext()), and it seems unlikely anyone would do something screwy with it like change it to null, but it's a public property. Seems low risk though.

Copy link
Member Author

Choose a reason for hiding this comment

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

My thoughts too.

Replaces CRM_Utils_Array::value() with empty() when the value is immediately cast to boolean.
The two statements have identical meaning but the latter is faster & easier to read.
@demeritcowboy
Copy link
Contributor

Ok looks good I don't have anything more to add.

@eileenmcnaughton
Copy link
Contributor

test this please

1 similar comment
@colemanw
Copy link
Member Author

colemanw commented Mar 8, 2020

test this please

@colemanw colemanw merged commit 3174576 into civicrm:master Mar 8, 2020
@colemanw
Copy link
Member Author

colemanw commented Mar 8, 2020

Unrelated fail

@colemanw colemanw deleted the arrayValue1 branch March 8, 2020 19:30
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.

3 participants