gppa_query_cache_hash

  1. Description
  2. Usage
  3. Parameters
    1. $args array
  4. Examples
    1. Custom GF_Entry Query Cache
  5. Since

Description

Filter GPPA’s query cache hash.

Warning: This modifies how GPPA hashes queries for all types. Incorrect hashing may result in GPPA returning incorrect or stale results.

Usage

add_filter( 'gppa_query_cache_hash', 'my_custom_function' );

Parameters

  • query_cache_hash string

    Current hash of the query GPPA is about to execute.

  • object_type string

    The current GPPA object type (e.g. ‘gf_entry’).

  • args array

    Query arguments array (see next section).

$args array

  • filter_groups array

    Filters for querying/fetching the objects.

  • ordering array

    Ordering settings for querying/fetching (includes ‘orderby’ and ‘order’).

  • templates array

    Templates to determine how choices/values will utilize the returned objects.

  • primary_property_value mixed

    Current primary property value used for querying the objects. (Not all object types use primary properties.)

  • field_values string

    Current field values used in query.

  • field object

    Current field.

  • unique bool

    Return only unique results.

Examples

Custom GF_Entry Query Cache

This example restores the behavior of GPPA’s GF_Entry query caching prior to 1.0.15. This may improve performance but is known to return incorrect results when multiple fields are populated and chained to each other.

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

Since

This filter is available since Gravity Forms Populate Anything 1.0.18.