From b742c132da1e7ec62464c4f1e96366ca71c44fe8 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Thu, 26 Dec 2019 17:50:30 -0500 Subject: [PATCH] Invalidate API caches when updating analytics settings. (https://github.com/woocommerce/woocommerce-admin/pull/3465) --- .../woocommerce-admin/src/API/SettingOptions.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/woocommerce-admin/src/API/SettingOptions.php b/plugins/woocommerce-admin/src/API/SettingOptions.php index af1f39d871d..fbe71375303 100644 --- a/plugins/woocommerce-admin/src/API/SettingOptions.php +++ b/plugins/woocommerce-admin/src/API/SettingOptions.php @@ -11,6 +11,8 @@ namespace Automattic\WooCommerce\Admin\API; defined( 'ABSPATH' ) || exit; +use \Automattic\WooCommerce\Admin\API\Reports\Cache as ReportsCache; + /** * Setting Options controller. * @@ -25,4 +27,18 @@ class SettingOptions extends \WC_REST_Setting_Options_Controller { * @var string */ 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 ); + } }