Skip to content

Commit

Permalink
Show at most 100 Dashbosard notices when purging terms
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Apr 24, 2014
1 parent 05fe726 commit e350503
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions quick-cache/quick-cache.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ public function auto_purge_post_terms_cache($id)
'\/[^\/]+\/'.preg_quote($cache_path_no_scheme_quv_ext, '/').
'(?:\/index)?(?:\.|\/(?:page|comment\-page)\/[0-9]+[.\/])/';

$_i = 0;
/** @var $_file \RecursiveDirectoryIterator For IDEs. */
foreach($this->dir_regex_iteration($cache_dir, $regex) as $_file) if($_file->isFile() || $_file->isLink())
{
Expand All @@ -772,16 +773,17 @@ public function auto_purge_post_terms_cache($id)
throw new \exception(sprintf(__('Unable to auto-purge file: `%1$s`.', $this->text_domain), $_file->getPathname()));
$counter++; // Increment counter for each file purge.

if(!empty($_notices) || !is_admin())
continue; // Stop here; we already issued a notice, or this notice is N/A.
if(!is_admin() || $_i > 100)
continue; // Stop here; we're at our max number of notices or this notice is N/A.

$_i++;
$_notices = (is_array($_notices = get_option(__NAMESPACE__.'_notices'))) ? $_notices : array();
$_notices[] = '<img src="'.esc_attr($this->url('/client-s/images/clear.png')).'" style="float:left; margin:0 10px 0 0; border:0;" />'.
sprintf(__('<strong>Quick Cache:</strong> detected changes. Found cache files for %1$s: <code>%2$s</code> (auto-purging).', $this->text_domain), $_term['taxonomy_label'], $_term['term_name']);
update_option(__NAMESPACE__.'_notices', $_notices);
}
}
unset($_term, $_file, $_notices); // Just a little housekeeping.
unset($_term, $_file, $_notices, $_i); // Just a little housekeeping.

return apply_filters(__METHOD__, $counter, get_defined_vars());
}
Expand Down

0 comments on commit e350503

Please sign in to comment.