From 1ffae8fc70a49c80198bf578e5c93b3add9fa753 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 13 Apr 2017 11:48:28 -0400 Subject: [PATCH] Fixed Plugin Update code to avoid "Failed to parse" errors if key is not valid for plugin. Changed message at top of wp-admin plugins page from "Plugin is up to date." which is not appropriate if it's a bad key to "No plugin update available." Updated string in language files but did not translate. --- .../languages/plugin-update-checker-fr_FR.po | 2 +- .../languages/plugin-update-checker-hu_HU.po | 2 +- .../languages/plugin-update-checker.pot | 2 +- lib/plugin-update-checker/plugin-update-checker.php | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po b/lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po index bcbcd154..b5df93ae 100644 --- a/lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po +++ b/lib/plugin-update-checker/languages/plugin-update-checker-fr_FR.po @@ -25,7 +25,7 @@ msgid "Check for updates" msgstr "Vérifier les mises à jour" #: plugin-update-checker.php:681 -msgid "This plugin is up to date." +msgid "No plugin update available." msgstr "Ce plugin est à jour." #: plugin-update-checker.php:683 diff --git a/lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po b/lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po index df22657b..13c71f58 100644 --- a/lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po +++ b/lib/plugin-update-checker/languages/plugin-update-checker-hu_HU.po @@ -25,7 +25,7 @@ msgid "Check for updates" msgstr "Frissítés ellenőrzése" #: plugin-update-checker.php:896 -msgid "This plugin is up to date." +msgid "No plugin update available." msgstr "Ez a plugin naprakész." #: plugin-update-checker.php:898 diff --git a/lib/plugin-update-checker/languages/plugin-update-checker.pot b/lib/plugin-update-checker/languages/plugin-update-checker.pot index bcbbd84c..69236043 100644 --- a/lib/plugin-update-checker/languages/plugin-update-checker.pot +++ b/lib/plugin-update-checker/languages/plugin-update-checker.pot @@ -26,7 +26,7 @@ msgid "Check for updates" msgstr "" #: plugin-update-checker.php:896 -msgid "This plugin is up to date." +msgid "No plugin update available." msgstr "" #: plugin-update-checker.php:898 diff --git a/lib/plugin-update-checker/plugin-update-checker.php b/lib/plugin-update-checker/plugin-update-checker.php index 48556294..5f00cbc4 100644 --- a/lib/plugin-update-checker/plugin-update-checker.php +++ b/lib/plugin-update-checker/plugin-update-checker.php @@ -196,18 +196,21 @@ class PluginUpdateChecker_3_1 { //Try to parse the response $status = $this->validateApiResponse($result); $pluginInfo = null; - if ( !is_wp_error($status) ){ + if ( !is_wp_error($status) && is_array($status)){ $pluginInfo = PluginInfo_3_1::fromJson($result['body']); if ( $pluginInfo !== null ) { $pluginInfo->filename = $this->pluginFile; $pluginInfo->slug = $this->slug; } } else { + return false; + /* Not generating error at this time as this could simply be a bad or missing key submitted $this->triggerError( sprintf('The URL %s does not point to a valid plugin metadata file. ', $url) . $status->get_error_message(), E_USER_WARNING ); + */ } $pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result); @@ -805,7 +808,7 @@ class PluginUpdateChecker_3_1 { if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) { $status = strval($_GET['puc_update_check_result']); if ( $status == 'no_update' ) { - $message = __('This plugin is up to date.', 'plugin-update-checker'); + $message = __('No plugin update available.', 'plugin-update-checker'); } else if ( $status == 'update_available' ) { $message = __('A new version of this plugin is available.', 'plugin-update-checker'); } else { -- 2.17.1