Skip to content

Hotfix: Fix term list retrieval in itinerary connected field#1183

Merged
krugazul merged 2 commits into
developfrom
hotfix-itinerary-type
Jun 11, 2026
Merged

Hotfix: Fix term list retrieval in itinerary connected field#1183
krugazul merged 2 commits into
developfrom
hotfix-itinerary-type

Conversation

@krugazul

@krugazul krugazul commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed term list retrieval in lsx_to_itinerary_connected_field() — normalises the $data array with array_values() before accessing the first element, ensuring get_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

  • Confirm itinerary connected fields (e.g. accommodation type, activity type) render correctly on frontend
  • Verify term list displays correctly when a single term is connected
  • Verify term list displays correctly when multiple terms are connected
  • Check no regression on itinerary day-by-day output

⚠️ Note: The diff includes do_action( 'qm/debug', [ $field, $data ] ); in includes/functions.php — this is a Query Monitor debug line that should be removed before merging.

🤖 Generated with Claude Code

@krugazul krugazul added this to the v2.1.0 milestone Jun 11, 2026
@krugazul krugazul self-assigned this Jun 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Tour Operator Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@krugazul, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89cb018c-6cae-476a-9998-77bd35de4e53

📥 Commits

Reviewing files that changed from the base of the PR and between 65bb76c and 1777ba3.

📒 Files selected for processing (2)
  • changelog.md
  • includes/functions.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix-itinerary-type

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added lang:php PHP code lang:md Markdown content/docs status:needs-review Awaiting code review meta:needs-changelog Requires a changelog entry before merge and removed status:needs-review Awaiting code review labels Jun 11, 2026
@krugazul krugazul moved this from Needs Triage to ✅ Done in Tour Operator Jun 11, 2026
@github-actions github-actions Bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Jun 11, 2026
@krugazul krugazul merged commit 5770bde into develop Jun 11, 2026
10 of 16 checks passed
@krugazul krugazul deleted the hotfix-itinerary-type branch June 11, 2026 10:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread includes/functions.php
Comment on lines +318 to +322
$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 );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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 );

@github-actions github-actions Bot added status:needs-review Awaiting code review and removed status:needs-review Awaiting code review labels Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang:md Markdown content/docs lang:php PHP code meta:needs-changelog Requires a changelog entry before merge status:needs-review Awaiting code review

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant