Change constant for post__(not)_in arguments

This commit is contained in:
Tetrakern 2024-01-29 00:00:44 +01:00
parent 470b4174bd
commit f7e25e5008
4 changed files with 9 additions and 9 deletions

View File

@ -1224,7 +1224,7 @@ define( 'CONSTANT_NAME', value );
| FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION | integer | Expiration duration for shortcode Transients in seconds. Default `300`.
| FICTIONEER_STORY_COMMENT_COUNT_TIMEOUT | integer | Timeout between comment count refreshes for stories in _seconds_. Default `900`.
| FICTIONEER_REQUESTS_PER_MINUTE | integer | Maximum requests per minute and action if the rate limit is enabled. Default `5`.
| FICTIONEER_POST_NOT_IN_LIMIT | integer | Maximum allowed IDs in the 'post__not_in' query argument. Default `100`.
| FICTIONEER_QUERY_ID_ARRAY_LIMIT | integer | Maximum allowed IDs in 'post__{not}_in' query arguments. Default `100`.
| FICTIONEER_OLD_POST_THRESHOLD | integer | Age of published post that is considered "old" in seconds. Default `30`.
| FICTIONEER_CACHE_PURGE_ASSIST | boolean | Whether to call the cache purge assist function on post updates. Default `true`.
| FICTIONEER_RELATIONSHIP_PURGE_ASSIST | boolean | Whether to purge related post caches. Default `true`.

View File

@ -259,11 +259,11 @@ if ( ! defined( 'FICTIONEER_REQUESTS_PER_MINUTE' ) ) {
define( 'FICTIONEER_REQUESTS_PER_MINUTE', 5 );
}
// Integer: Maximum of 'post__not_in' query argument to prevent performance degradation.
// If exceeded, the whole argument will be ignored in certain queries, which account for
// this case in the view.
if ( ! defined( 'FICTIONEER_POST_NOT_IN_LIMIT' ) ) {
define( 'FICTIONEER_POST_NOT_IN_LIMIT', 100 );
// Integer: Maximum number of IDs in 'post__in' and 'post__not_in' query arguments
// to prevent performance degradation. If exceeded, the whole argument will be
// ignored in certain queries, which account for.
if ( ! defined( 'FICTIONEER_QUERY_ID_ARRAY_LIMIT' ) ) {
define( 'FICTIONEER_QUERY_ID_ARRAY_LIMIT', 100 );
}
// Integer: After how many seconds after saving is a post considered "old"

View File

@ -78,7 +78,7 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) {
if ( ! ( isset( $the_query_args['post__in'] ) && empty( $the_query_args['post__in'] ) ) ) {
// Look for IDs to exclude if story or chapter...
if ( in_array( $post_type, ['fcn_story', 'fcn_chapter'] ) && FICTIONEER_POST_NOT_IN_LIMIT > 0 ) {
if ( in_array( $post_type, ['fcn_story', 'fcn_chapter'] ) && FICTIONEER_QUERY_ID_ARRAY_LIMIT > 0 ) {
// Get complete set for filtering (required due to pagination)
$all_query = new WP_Query(
array_merge( $the_query_args, array( 'posts_per_page' => -1, 'no_found_rows' => true ) )
@ -105,7 +105,7 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) {
}
}
if ( ! empty( $excluded ) && count( $excluded ) <= FICTIONEER_POST_NOT_IN_LIMIT ) {
if ( ! empty( $excluded ) && count( $excluded ) <= FICTIONEER_QUERY_ID_ARRAY_LIMIT ) {
$the_query_args['post__not_in'] = array_merge( $excluded, ( $the_query_args['post__not_in'] ?? [] ) );
}

View File

@ -186,7 +186,7 @@ function fictioneer_get_story_chapter_posts( $story_id ) {
}
// Few chapters?
if ( count( $chapter_ids ) < 50 ) {
if ( count( $chapter_ids ) <= FICTIONEER_QUERY_ID_ARRAY_LIMIT ) {
// Query with post__in, which should be faster than meta query
// as long as the ID array is not too large.
$chapter_query = new WP_Query(