✨feature: Add reset-cache action to settings page
Adds a 'Reset cache' button to the Podcast RSS Import settings page that clears the SimplePie feed-cache rows (both the cached XML and the modification timestamp) plus the importer's per-feed import lock for the configured feed. Multisite site-transient variants are also cleared. Use this when the importer is skipping items or refusing to re-fetch a feed that has changed at the source. The next 'Import now' click will re-pull the XML from the network. clear_feed_cache() is exposed as a public method so it is unit-testable, and a do_action hook (rss2cpt_cache_cleared) lets other code react when the cache is cleared. Two smoke tests pin down the expected option and site-transient names, and a third ensures an empty feed URL is a no-op.
This commit is contained in:
@@ -55,5 +55,48 @@ function get_gmt_from_date( $date_string ) {
|
||||
return gmdate( 'Y-m-d H:i:s', $timestamp );
|
||||
}
|
||||
|
||||
/**
|
||||
* In-memory option store for isolated tests.
|
||||
*
|
||||
* @param string $name Option name.
|
||||
* @return bool Always true; the test asserts via $GLOBALS['rss2cpt_test_deleted_options'].
|
||||
*/
|
||||
function delete_option( $name ) {
|
||||
$GLOBALS['rss2cpt_test_deleted_options'][] = $name;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* In-memory site-transient store for isolated tests.
|
||||
*
|
||||
* @param string $name Transient name.
|
||||
* @return bool Always true; the test asserts via $GLOBALS['rss2cpt_test_deleted_site_transients'].
|
||||
*/
|
||||
function delete_site_transient( $name ) {
|
||||
$GLOBALS['rss2cpt_test_deleted_site_transients'][] = $name;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset recorded delete_* call logs between tests.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rss2cpt_test_reset_delete_logs() {
|
||||
$GLOBALS['rss2cpt_test_deleted_options'] = array();
|
||||
$GLOBALS['rss2cpt_test_deleted_site_transients'] = array();
|
||||
}
|
||||
rss2cpt_test_reset_delete_logs();
|
||||
|
||||
/**
|
||||
* Minimal do_action stub for isolated tests.
|
||||
*
|
||||
* @param string $hook Hook name.
|
||||
* @param mixed ...$args Hook arguments.
|
||||
*/
|
||||
function do_action( $hook, ...$args ) {
|
||||
unset( $hook, $args );
|
||||
}
|
||||
|
||||
require_once dirname( __DIR__ ) . '/src/Options.php';
|
||||
require_once dirname( __DIR__ ) . '/src/Import/Importer.php';
|
||||
|
||||
Reference in New Issue
Block a user