Fix PHP warnings when using taxonomy sync without bidirectional relationship #7485
+52
−36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes PHP warnings that flood the log file when saving a post with a relationship field that has the "Sync associated taxonomy with this relationship" option enabled, but no bidirectional relationship (sister_id) is configured.
Fixes #7477
The Problem
When
pick_sync_taxonomyis enabled but there is no bidirectional relationship set up:$related_podisnull$related_fieldisnullThe original code at line 1959-1967 had this condition:
This means the function only returns early if BOTH conditions are true:
So when taxonomy sync IS enabled (but no bidirectional relationship exists), the code continues past this check and then tries to access
$related_pod['type']on line 1974, which triggers the PHP warning.The Solution
Move the taxonomy sync logic to run first (it does not need
$related_podor$related_field), then add an early return if no bidirectional relationship exists.Before
After
Why This Works
$related_podor$related_field- it only uses$pod,$options, and$value_ids$related_podis nullTesting Done
Files Changed
classes/fields/pick.php- Reordered logic in thesave()methodPlugin zip
pods-fix-7477.zip