Invalidate API caches when updating analytics settings. (https://github.com/woocommerce/woocommerce-admin/pull/3465)

This commit is contained in:
Jeff Stieler 2019-12-26 17:50:30 -05:00 committed by GitHub
parent 402294c500
commit b742c132da
1 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,8 @@ namespace Automattic\WooCommerce\Admin\API;
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\API\Reports\Cache as ReportsCache;
/** /**
* Setting Options controller. * Setting Options controller.
* *
@ -25,4 +27,18 @@ class SettingOptions extends \WC_REST_Setting_Options_Controller {
* @var string * @var string
*/ */
protected $namespace = 'wc-analytics'; protected $namespace = 'wc-analytics';
/**
* Invalidates API cache when updating settings options.
*
* @param WP_REST_Request $request Full details about the request.
* @return array Of WP_Error or WP_REST_Response.
*/
public function batch_items( $request ) {
// Invalidate the API cache.
ReportsCache::invalidate();
// Process the request.
return parent::batch_items( $request );
}
} }