diff --git a/rt-plugin-report.php b/rt-plugin-report.php index 6edaafc..b845bfb 100644 --- a/rt-plugin-report.php +++ b/rt-plugin-report.php @@ -95,8 +95,8 @@ public function settings_page() { $wp_latest = $this->check_core_updates(); // Refresh the cache, but only if nonce is valid and this is a fresh timestamp (not if the page has been refreshed with the timestamp still in the URL). - if ( isset( $_GET['clear_cache'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'plugin_report_clear_cache' ) ) { - $new_timestamp = intval( $_GET['clear_cache'] ); + if ( isset( $_GET['clear_cache'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ), 'plugin_report_clear_cache' ) ) { + $new_timestamp = absint( wp_unslash( $_GET['clear_cache'] ) ); $last_timestamp = intval( get_site_transient( 'plugin_report_cache_cleared' ) ); if ( ! $last_timestamp || $new_timestamp > $last_timestamp ) { $this->clear_cache(); @@ -360,9 +360,11 @@ private function assemble_plugin_report( $slug ) { // Add the repo info to the report. if ( isset( $returned_object ) ) { if ( ! is_wp_error( $returned_object ) ) { - $report['repo_info'] = $returned_object; - // Cache the report. - set_site_transient( $cache_key, $report, self::CACHE_LIFETIME ); + if ( isset( $returned_object->version ) ) { + $report['repo_info'] = $returned_object; + // Cache the report. + set_site_transient( $cache_key, $report, self::CACHE_LIFETIME ); + } } else { // Store the error code and message in the report. $report['repo_error_code'] = $returned_object->get_error_code(); @@ -492,7 +494,7 @@ private function render_table_row( $report ) { $html .= '