-
Notifications
You must be signed in to change notification settings - Fork 736
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
Use array_key_first() when judicious #2029
base: 8.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,9 +221,11 @@ public function refresh(array $params = []): Response | |
$this->_response = $this->getNode()->getClient()->requestEndpoint($endpoint); | ||
$data = $this->getResponse()->getData(); | ||
|
||
$this->_data = \reset($data['nodes']); | ||
$this->_id = \key($data['nodes']); | ||
$this->getNode()->setId($this->getId()); | ||
if (null !== $nodeId = \array_key_first($data['nodes'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to get my head around on what happened before when we didn't check furl null. If there are no nodes, it is expected that we keep the old values or should these be overwritten with empty values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I didn't think this case, when nodes can be empty |
||
$this->_data = $data['nodes'][$nodeId]; | ||
$this->_id = $nodeId; | ||
$this->getNode()->setId($nodeId); | ||
} | ||
|
||
return $this->_response; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice rewrite. This old code was way too complicated!