Hotfix: Fix term list retrieval in itinerary connected field#1183
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 43 minutes and 41 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request normalizes the $data array using array_values() in lsx_to_itinerary_connected_field() to ensure a valid post ID is retrieved even if the array is not zero-indexed, and adds a corresponding changelog entry. Review feedback suggests simplifying this logic by removing redundant array checks and renaming the misleading $first_term variable to $post_id to better reflect that it represents a post ID.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| $first_term = array_values( $data ); | ||
| if ( is_array( $first_term ) && ! empty( $first_term ) ) { | ||
| $first_term = $first_term[0]; | ||
| } | ||
| $return = get_the_term_list( $first_term, $type, $before, ', ', $after ); |
There was a problem hiding this comment.
The variable $first_term is misleadingly named because it actually holds a post ID (which is passed as the first argument to get_the_term_list()), not a term.
Additionally, the conditional checks is_array( $first_term ) and ! empty( $first_term ) are redundant. Since $data is guaranteed to be a non-empty array at this point (due to the empty( $data ) check on line 311 and the (array) cast on line 315), array_values( $data ) will always return a non-empty array.
We can simplify this code significantly by directly retrieving the first element of the array values and using a clearer variable name like $post_id.
$post_id = array_values( $data )[0];
$return = get_the_term_list( $post_id, $type, $before, ', ', $after );
Summary
lsx_to_itinerary_connected_field()— normalises the$dataarray witharray_values()before accessing the first element, ensuringget_the_term_list()always receives a valid post ID. Previously$data[0]could fail if the array had non-zero-indexed keys (e.g. from a meta value stored as an associative or non-sequential array).Test plan
🤖 Generated with Claude Code