diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-01-27 19:25:21 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-01-27 19:25:21 +0100 |
commit | a64eec16d2d0bb6f36960279324ff4c67887bfbb (patch) | |
tree | aedd4f489b874814bc6284bed4883d9c4accab66 | |
parent | 8e790062800da9ede63ca6d3906c6c178beba5aa (diff) | |
download | rpg-a64eec16d2d0bb6f36960279324ff4c67887bfbb.tar.gz rpg-a64eec16d2d0bb6f36960279324ff4c67887bfbb.tar.bz2 |
reverted plugin disabling method back to old behaviour
Ignore-this: b5fadadeee9de8e52c41c056cf62be6d
With this patch plugins are now disabled by placing a disabled file in the
plugin directory again.
Even though renaming plugin directories is the method with the fewest disk
accesses it makes a lot of trouble with code revision control systems and,
more important, Linux package management systems.
Future versions of DokuWiki may use a central config file instead.
This patch also fixes the problem with the plugin manager not checking the
return values of the pugin_(dis|en)able functions correctly.
darcs-hash:20090127182521-7ad00-62018a546d49d57582d93298c8228fd71601a5e8.gz
-rw-r--r-- | inc/plugincontroller.class.php | 12 | ||||
-rw-r--r-- | lib/plugins/plugin/admin.php | 17 | ||||
-rw-r--r-- | lib/plugins/plugin/lang/en/lang.php | 5 | ||||
-rw-r--r-- | lib/plugins/upgradeplugindirectory/action.php | 110 |
4 files changed, 25 insertions, 119 deletions
diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php index 98f57f3a3..372ab4f17 100644 --- a/inc/plugincontroller.class.php +++ b/inc/plugincontroller.class.php @@ -97,14 +97,14 @@ class Doku_Plugin_Controller { function enable($plugin) { if (array_search($plugin, $this->list_disabled) !== false) { - return @rename(DOKU_PLUGIN.$plugin.'.disabled',DOKU_PLUGIN.$plugin); + return @unlink(DOKU_PLUGIN.$plugin.'/disabled'); } return false; } function disable($plugin) { - if (array_search($plugin, $this->list_enabled) !== false) { - return @rename(DOKU_PLUGIN.$plugin,DOKU_PLUGIN.$plugin.'.disabled'); + if (array_search($plugin, $this->list_enabled) !== false) { + return @touch(DOKU_PLUGIN.$plugin.'/disabled'); } return false; } @@ -120,7 +120,11 @@ class Doku_Plugin_Controller { if (is_file(DOKU_PLUGIN.$plugin)) continue; if (substr($plugin,-9) == '.disabled') { - $this->list_disabled[] = substr($plugin,0,-9); + // the plugin was disabled by rc2009-01-26 + // disabling mechanism was changed back very soon again + // to keep everything simple we just skip the plugin completely + }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')){ + $this->list_disabled[] = $plugin; } else { $this->list_enabled[] = $plugin; } diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php index ddd4081a5..c0918c70f 100644 --- a/lib/plugins/plugin/admin.php +++ b/lib/plugins/plugin/admin.php @@ -619,12 +619,20 @@ class ap_manage { switch ($new) { // enable plugin case true : - plugin_enable($plugin); - $count_enabled++; + if(plugin_enable($plugin)){ + msg(sprintf($this->lang['enabled'],$plugin),1); + $count_enabled++; + }else{ + msg(sprintf($this->lang['notenabled'],$plugin),-1); + } break; case false: - plugin_disable($plugin); - $count_disabled++; + if(plugin_disable($plugin)){ + msg(sprintf($this->lang['disabled'],$plugin),1); + $count_disabled++; + }else{ + msg(sprintf($this->lang['notdisabled'],$plugin),-1); + } break; } } @@ -632,7 +640,6 @@ class ap_manage { // refresh plugins, including expiring any dokuwiki cache(s) if ($count_enabled || $count_disabled) { - msg("Plugin state saved, $count_enabled plugins enabled, $count_disabled plugins disabled."); $this->refresh(); } } diff --git a/lib/plugins/plugin/lang/en/lang.php b/lib/plugins/plugin/lang/en/lang.php index 9414a36d5..e575d3d67 100644 --- a/lib/plugins/plugin/lang/en/lang.php +++ b/lib/plugins/plugin/lang/en/lang.php @@ -69,4 +69,9 @@ $lang['error_copy'] = 'There was a file copy error while attempting to ins $lang['error_delete'] = 'There was an error while attempting to delete plugin <em>%s</em>. '. 'The most probably cause is insufficient file or directory access permissions'; +$lang['enabled'] = 'Plugin %s enabled.'; +$lang['notenabled'] = 'Plugin %s could not be enabled, check file permissions.'; +$lang['disabled'] = 'Plugin %s disabled.'; +$lang['notdisabled'] = 'Plugin %s could not be disabled, check file permissions.'; + //Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/lib/plugins/upgradeplugindirectory/action.php b/lib/plugins/upgradeplugindirectory/action.php deleted file mode 100644 index c541db207..000000000 --- a/lib/plugins/upgradeplugindirectory/action.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Action Plugin: - * Upgrades the plugin directory from the "old style" of disabling plugins to the new style - * - * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * @author Christopher Smith <chris@jalakai.co.uk> - */ - -if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_PLUGIN.'action.php'); - -/** - * All DokuWiki plugins to extend the parser/rendering mechanism - * need to inherit from this class - */ -class action_plugin_upgradeplugindirectory extends DokuWiki_Action_Plugin { - - /** - * return some info - */ - function getInfo(){ - return array( - 'author' => 'Christopher Smith', - 'email' => 'chris@jalakai.co.uk', - 'date' => '2009-01-18', - 'name' => 'Upgrade Plugin Directory', - 'desc' => 'Silently updates plugin disabled indicator to new more efficient format', - 'url' => 'http://wiki.splitbrain.org/plugin:upgradeplugindirectory', - ); - } - - /* - * plugin should use this method to register its handlers with the dokuwiki's event controller - */ - function register(&$controller) { - $controller->register_hook('DOKUWIKI_STARTED','BEFORE', $this, 'handle_upgrade','before'); - } - - function handle_upgrade(&$event, $param) { - global $plugin_controller; - $attempts = 0; - $success = 0; - $updated = 0; - $failures = array(); - $badclean = array(); - - if (empty($plugin_controller)) return; - - if(!is_writable(DOKU_INC.'lib/plugins') && !auth_isAdmin()) { - return; - } - - $plugins = $plugin_controller->getList('',true); // get all plugins - foreach ($plugins as $plugin) { - if ($this->plugin_isdisabled_oldstyle($plugin)) { - $attempts++; - if (@$plugin_controller->disable($plugin)) { - $updated++; - if ($this->plugin_clean($plugin)) { - $success++; - } else { - $badclean[] = $plugin; - } - } else { - $failures[] = $plugin; - } - } - } - - // note: only send messages when the user is an admin - if ($attempts && auth_isAdmin()) { - $level = $failures ? -1 : ($badclean ? 2 : 1); - msg("Plugin Directory Upgrade, $updated/$attempts plugins updated, $success/$attempts cleaned.",$level); - if ($badclean) msg("- the following disabled plugins were updated, but their directories couldn't be cleaned: ".join(',',$badclean),$level); - if ($failures) { - msg("- the following disabled plugins couldn't be updated, please update by hand: ".join(',',$failures),$level); - } - $morelink = true; - } - - // no failures, our job is done, disable ourself - if (!$failures) { - if ($plugin_controller->disable($this->getPluginName())) { - // redirect to let dokuwiki start cleanly with plugins disabled. - act_redirect($ID,'upgradeplugindirectory'); - } else { - if (auth_isAdmin()) { - if (!$attempts) msg('Plugin Directory Upgrade: Your plugin directory is up-to-date.',1); - msg('Plugin Directory Upgrade: Could not disable the upgrade plugin, please disable or delete it manually.',-1); - $morelink = true; - $level = -1; - } - } - } - if ($morelink) msg('For more information see <a href="http://www.dokuwiki.org/update">http://www.dokuwiki.org/update</a>',$level); - } - - /* old style plugin isdisabled function */ - function plugin_isdisabled_oldstyle($name) { - return @file_exists(DOKU_PLUGIN.$name.'/disabled'); - } - - function plugin_clean($name) { - return @unlink(DOKU_PLUGIN.$name.'.disabled/disabled'); - } -} - -//Setup VIM: ex: et ts=4 enc=utf-8 : |