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.
This commit is contained in:
wn_ 2021-03-08 15:38:52 +00:00
parent 28dd255c30
commit fed5158ec5
2 changed files with 27 additions and 23 deletions

View File

@ -1057,7 +1057,7 @@ class Pref_Prefs extends Handler_Protected {
private static function _plugin_needs_update($root_dir, $plugin_name) { private static function _plugin_needs_update($root_dir, $plugin_name) {
$plugin_dir = "$root_dir/plugins.local/" . basename($plugin_name); $plugin_dir = "$root_dir/plugins.local/" . basename($plugin_name);
$rv = []; $rv = null;
if (is_dir($plugin_dir) && is_dir("$plugin_dir/.git")) { if (is_dir($plugin_dir) && is_dir("$plugin_dir/.git")) {
$pipes = []; $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); $proc = proc_open("git fetch -q origin -a && git log HEAD..origin/master --oneline", $descriptorspec, $pipes, $plugin_dir);
if (is_resource($proc)) { if (is_resource($proc)) {
$rv["stdout"] = stream_get_contents($pipes[1]); $rv = [
$rv["stderr"] = stream_get_contents($pipes[2]); "stdout" => stream_get_contents($pipes[1]),
$rv["git_status"] = proc_close($proc); "stderr" => stream_get_contents($pipes[2]),
"git_status" => proc_close($proc),
];
$rv["need_update"] = !empty($rv["stdout"]); $rv["need_update"] = !empty($rv["stdout"]);
} }
} }

View File

@ -697,6 +697,7 @@ const Helpers = {
} else { } else {
reply.forEach((p) => { reply.forEach((p) => {
if (p.rv) {
if (p.rv.need_update) { if (p.rv.need_update) {
dialog.plugins_to_update.push(p.plugin); dialog.plugins_to_update.push(p.plugin);
@ -720,6 +721,7 @@ const Helpers = {
</li> </li>
` `
} }
}
dialog.checkNextPlugin(); dialog.checkNextPlugin();
}); });
} }