allow uninstall of plugins which no longer exists via cmdline tool
This commit is contained in:
parent
70a0a83363
commit
b2218574ee
@ -53,10 +53,15 @@ function unload_plugin($plugin){
|
||||
* @return boolean
|
||||
*/
|
||||
function uninstall_plugin($plugin) {
|
||||
|
||||
unload_plugin($plugin);
|
||||
|
||||
if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
|
||||
if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php')) {
|
||||
q("DELETE FROM addon WHERE aname = '%s' ",
|
||||
dbesc($plugin)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger("Addons: uninstalling " . $plugin);
|
||||
//$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
|
||||
@ -73,6 +78,7 @@ function uninstall_plugin($plugin) {
|
||||
q("DELETE FROM addon WHERE aname = '%s' ",
|
||||
dbesc($plugin)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
14
util/addons
14
util/addons
@ -106,9 +106,12 @@ if($argc == 3 && $argv[1] === 'install') {
|
||||
|
||||
if($argc == 3 && $argv[1] === 'uninstall') {
|
||||
|
||||
$found = false;
|
||||
|
||||
if($plugins) {
|
||||
foreach($plugins as $p) {
|
||||
if($p[0] === $argv[2]) {
|
||||
$found = true;
|
||||
if(! $p[1])
|
||||
echo $p[0] . ' not installed.' . "\n";
|
||||
elseif($p[2]['disabled'])
|
||||
@ -125,6 +128,17 @@ if($argc == 3 && $argv[1] === 'uninstall') {
|
||||
}
|
||||
}
|
||||
|
||||
// force uninstall of addon which no longer exists
|
||||
|
||||
if(! $found) {
|
||||
$idx = array_search($argv[2], App::$plugins);
|
||||
if ($idx !== false)
|
||||
unset(App::$plugins[$idx]);
|
||||
uninstall_plugin($argv[2]);
|
||||
set_config("system","addon", implode(", ",App::$plugins));
|
||||
echo $argv[2] . ' uninstalled.' . "\n";
|
||||
}
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user