Skip to content

Instantly share code, notes, and snippets.

@attitude
Created March 13, 2013 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attitude/5156173 to your computer and use it in GitHub Desktop.
Save attitude/5156173 to your computer and use it in GitHub Desktop.
Patch for possible fix for issue #1049 of Pods Framework.
diff --git a/classes/PodsAPI.php b/classes/PodsAPI.php
index 129badf..571bd1a 100644
--- a/classes/PodsAPI.php
+++ b/classes/PodsAPI.php
@@ -3020,9 +3020,7 @@ class PodsAPI {
if ( !empty( $related_ids ) ) {
update_metadata( $object_type, $id, '_pods_' . $related_field[ 'name' ], $related_ids );
- foreach ( $related_ids as $rel_id ) {
- add_metadata( $object_type, $id, $related_field[ 'name' ], $rel_id );
- }
+ add_metadata( $object_type, $id, $related_field[ 'name' ], $related_ids );
}
else
delete_metadata( $object_type, $id, '_pods_' . $related_field[ 'name' ] );
@sc0ttkclark
Copy link

We add individual meta records for each ID because it makes WP_Query meta_query lookups and our (advanced) JOINs more efficient. As this happens only when you update the item, it's not expensive to do it the right way as I believe we're doing right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment