summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-03-08 15:38:52 +0000
committerwn_ <[email protected]>2021-03-08 15:38:52 +0000
commitfed5158ec50788026500a3e280b52e01e6cec883 (patch)
tree2059e88347656feb54129fa33d8affb5289eab17
parent28dd255c30c7bdb528ec1fde2391705fbc9b4cf6 (diff)
Default to null 'rv' for plugin update check.
Previously 'rv' was returned as an empty JS array, causing 'p.rv.git_status != 0' to evaluate to true and a misleading 'Ready to update' appearing for certain plugins.
-rw-r--r--classes/pref/prefs.php10
-rw-r--r--js/PrefHelpers.js40
2 files changed, 27 insertions, 23 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 77b57b4d8..16c41df9d 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -1057,7 +1057,7 @@ class Pref_Prefs extends Handler_Protected {
private static function _plugin_needs_update($root_dir, $plugin_name) {
$plugin_dir = "$root_dir/plugins.local/" . basename($plugin_name);
- $rv = [];
+ $rv = null;
if (is_dir($plugin_dir) && is_dir("$plugin_dir/.git")) {
$pipes = [];
@@ -1071,9 +1071,11 @@ class Pref_Prefs extends Handler_Protected {
$proc = proc_open("git fetch -q origin -a && git log HEAD..origin/master --oneline", $descriptorspec, $pipes, $plugin_dir);
if (is_resource($proc)) {
- $rv["stdout"] = stream_get_contents($pipes[1]);
- $rv["stderr"] = stream_get_contents($pipes[2]);
- $rv["git_status"] = proc_close($proc);
+ $rv = [
+ "stdout" => stream_get_contents($pipes[1]),
+ "stderr" => stream_get_contents($pipes[2]),
+ "git_status" => proc_close($proc),
+ ];
$rv["need_update"] = !empty($rv["stdout"]);
}
}
diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js
index 651e3f609..3f738aa95 100644
--- a/js/PrefHelpers.js
+++ b/js/PrefHelpers.js
@@ -697,28 +697,30 @@ const Helpers = {
} else {
reply.forEach((p) => {
- if (p.rv.need_update) {
- dialog.plugins_to_update.push(p.plugin);
+ if (p.rv) {
+ if (p.rv.need_update) {
+ dialog.plugins_to_update.push(p.plugin);
- const update_button = dijit.getEnclosingWidget(
- App.find(`*[data-update-btn-for-plugin="${p.plugin}"]`));
+ const update_button = dijit.getEnclosingWidget(
+ App.find(`*[data-update-btn-for-plugin="${p.plugin}"]`));
- if (update_button)
- update_button.domNode.show();
- }
+ if (update_button)
+ update_button.domNode.show();
+ }
- if (p.rv.need_update || p.rv.git_status != 0) {
- container.innerHTML +=
- `
- <li><h3>${p.plugin}</h3>
- ${p.rv.stderr ? `<pre class="small text-error pre-wrap">${p.rv.stderr}</pre>` : ''}
- ${p.rv.stdout ? `<pre class="small text-success pre-wrap">${p.rv.stdout}</pre>` : ''}
- <div class="small">
- ${p.rv.git_status ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.git_status) :
- App.FormFields.icon("check") + " " + __("Ready to update")}
- </div>
- </li>
- `
+ if (p.rv.need_update || p.rv.git_status != 0) {
+ container.innerHTML +=
+ `
+ <li><h3>${p.plugin}</h3>
+ ${p.rv.stderr ? `<pre class="small text-error pre-wrap">${p.rv.stderr}</pre>` : ''}
+ ${p.rv.stdout ? `<pre class="small text-success pre-wrap">${p.rv.stdout}</pre>` : ''}
+ <div class="small">
+ ${p.rv.git_status ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.git_status) :
+ App.FormFields.icon("check") + " " + __("Ready to update")}
+ </div>
+ </li>
+ `
+ }
}
dialog.checkNextPlugin();
});