Skip to content

Commit 5281d84

Browse files
committed
Merge pull request #92 from Automattic/cache-no-ad-codes
Store an empty array in cache when no ad codes exist.
2 parents 794fc75 + 4faf96a commit 5281d84

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ad-code-manager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ function get_ad_codes( $query_args = array() ) {
392392

393393
$ad_codes_formatted = wp_cache_get( 'ad_codes' , 'acm' );
394394
if ( false === $ad_codes_formatted ) {
395+
// Store an empty array when no ad codes exist so this block doesn't run on each page load
396+
$ad_codes_formatted = array();
395397
$ad_codes = get_posts( $args );
396398
foreach ( $ad_codes as $ad_code_cpt ) {
397399
$provider_url_vars = array();

0 commit comments

Comments
 (0)