Custom GF_Entry Query Cache

This may improve performance but is known to return incorrect results when multiple fields are populated and chained to each other.

Code

Filename: gppa-custom-gf-entry-query-cache.php

<?php
/**
 * Gravity Perks // GP Populate Anything // Custom GF_Entry Query Cache
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * This may improve performance but is known to return incorrect results when multiple fields are populated and chained to each other.
 */
add_filter( 'gppa_query_cache_hash', function( $query_cache_hash, $object_type, $args ) {
	if ( $object_type === 'gf_entry' ) {
		return sha1( sprintf( '%s-%s-%s-%s-%s',
			$args['field']->formId,
			json_encode( $args['filter_groups'] ),
			json_encode( $args['ordering'] ),
			json_encode( $args['primary_property_value'] ),
			json_encode( $args['unique'] )
		) );
	}
	return $query_cache_hash;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.