Index: trunk/extensions/Configure/Configure.obj.php |
— | — | @@ -74,10 +74,14 @@ |
75 | 75 | if( !is_array( $settings ) || $settings === array() ) |
76 | 76 | # hmmm |
77 | 77 | return false; |
78 | | - if( !$wiki ) |
79 | | - $wiki = $this->mWiki; |
80 | 78 | |
81 | | - $this->mConf[$wiki] = $settings; |
| 79 | + if( $wiki === null ){ |
| 80 | + $this->mConf = $settings; |
| 81 | + } else { |
| 82 | + if( $wiki === false ) |
| 83 | + $wiki = $this->mWiki; |
| 84 | + $this->mConf[$wiki] = $settings; |
| 85 | + } |
82 | 86 | |
83 | 87 | $arch = $this->getArchiveFileName(); |
84 | 88 | $cur = $this->getFileName(); |
— | — | @@ -90,6 +94,11 @@ |
91 | 95 | * extract settings for this wiki in $GLOBALS |
92 | 96 | */ |
93 | 97 | public function extract(){ |
| 98 | + // Special case for manage.php maintenance script so that it can work |
| 99 | + // even the current configuration is broken |
| 100 | + if( defined( 'EXT_CONFIGURE_NO_EXTRACT' ) ) |
| 101 | + return; |
| 102 | + |
94 | 103 | list( $site, $lang ) = $this->siteFromDB( $this->mWiki ); |
95 | 104 | $rewrites = array( 'wiki' => $this->mWiki, 'site' => $site, 'lang' => $lang ); |
96 | 105 | $this->extractAllGlobals( $this->mWiki, $site, $rewrites ); |
— | — | @@ -102,6 +111,9 @@ |
103 | 112 | * @return array |
104 | 113 | */ |
105 | 114 | public function getCurrent( $wiki ){ |
| 115 | + if( !empty( $this->conf[$wiki] ) ) |
| 116 | + return $this->conf[$wiki]; |
| 117 | + |
106 | 118 | list( $site, $lang ) = $this->siteFromDB( $wiki ); |
107 | 119 | $rewrites = array( 'wiki' => $wiki, 'site' => $site, 'lang' => $lang ); |
108 | 120 | return $this->getAll( $wiki, $site, $rewrites ); |
— | — | @@ -121,7 +133,7 @@ |
122 | 134 | * current timestamp |
123 | 135 | * @return String full path to the file |
124 | 136 | */ |
125 | | - protected function getArchiveFileName( $ts = null ){ |
| 137 | + public function getArchiveFileName( $ts = null ){ |
126 | 138 | global $IP; |
127 | 139 | |
128 | 140 | if( $ts === null ) |
Index: trunk/extensions/Configure/CHANGELOG |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | This file lists changes on this extension. |
3 | 3 | Localisation updates are done on betawiki and aren't listed here. |
4 | 4 | |
| 5 | +0.4.4 - 15 June 2008 |
| 6 | + Added manage.php maintenance script to do maintenance with configuration |
| 7 | + files. |
| 8 | + |
5 | 9 | 0.4.3 - 12 June 2008 |
6 | 10 | $wgEnableCascadingProtection is obsolete in 1.13 + |
7 | 11 | |
Index: trunk/extensions/Configure/README |
— | — | @@ -58,9 +58,12 @@ |
59 | 59 | == Troubleshooting == |
60 | 60 | |
61 | 61 | If an admin changed the settings in a way that the wiki can't work anymore, |
62 | | -you can simply drop the conf-now.ser file you'll find in $wgConfigureFilesPath |
63 | | -directory. Then it will fall back to the default configuration that is in |
64 | | -LocalSettings.php. It's why it's important to keep that file. |
| 62 | +you can do either: |
| 63 | +* use the manage.php command line script to revert the configuration to an |
| 64 | + older version |
| 65 | +* drop the conf-now.ser file you'll find in $wgConfigureFilesPath |
| 66 | + directory. Then it will fall back to the default configuration that is in |
| 67 | + LocalSettings.php. It's why it's important to keep that file. |
65 | 68 | |
66 | 69 | == To do == |
67 | 70 | |
Index: trunk/extensions/Configure/manage.inc |
— | — | @@ -0,0 +1,68 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Helper class for the manage.php script |
| 6 | + * |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Alexandre Emsenhuber |
| 9 | + */ |
| 10 | +class ConfigurationManager { |
| 11 | + public function __construct( $options ){ |
| 12 | + $this->options = $options; |
| 13 | + } |
| 14 | + |
| 15 | + public function run(){ |
| 16 | + global $wgConf; |
| 17 | + if( !$wgConf instanceof WebConfiguration ){ |
| 18 | + echo "You need to call efConfigureSetup() to use this maintenance script."; |
| 19 | + die( 1 ); |
| 20 | + } |
| 21 | + foreach( $this->options as $name => $arg ){ |
| 22 | + $function = 'Do' . ucfirst( $name ); |
| 23 | + $callback = array( $this, $function ); |
| 24 | + if( !is_callable( $callback ) ) |
| 25 | + // Ingnore silenty |
| 26 | + continue; |
| 27 | + call_user_func_array( $callback, $arg ); |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + protected function DoDelete( $version ){ |
| 32 | + global $wgConf; |
| 33 | + $file = $wgConf->getArchiveFileName( $version ); |
| 34 | + if( !file_exists( $file ) ){ |
| 35 | + fwrite( STDERR, "delete: The version given ($version) does not exist.\n" ); |
| 36 | + return; |
| 37 | + } |
| 38 | + unlink( $file ); |
| 39 | + } |
| 40 | + |
| 41 | + protected function DoList(){ |
| 42 | + global $wgConf; |
| 43 | + echo implode( "\n", $wgConf->listArchiveFiles() ) . "\n"; |
| 44 | + } |
| 45 | + |
| 46 | + protected function DoRevert( $version ){ |
| 47 | + global $wgConf; |
| 48 | + $arr = $wgConf->getOldSettings( $version ); |
| 49 | + if( !count( $arr ) ){ |
| 50 | + fwrite( STDERR, "revert: The version given ($version) is invalid\n" ); |
| 51 | + return; |
| 52 | + } |
| 53 | + $wgConf->saveNewSettings( $arr, null ); |
| 54 | + } |
| 55 | + |
| 56 | + protected function DoHelp(){ |
| 57 | + echo "Script that helps to do maintenance with configuration files.\n"; |
| 58 | + echo "\n"; |
| 59 | + echo "Usage:\n"; |
| 60 | + echo " php findSettings.php [--revert version] [--list] [--delete version] [--help]\n"; |
| 61 | + echo "\n"; |
| 62 | + echo "options:\n"; |
| 63 | + echo "--help: display this screen\n"; |
| 64 | + echo "--list: list all configurations files\n"; |
| 65 | + echo "--delete: delete the file corresponding to the given version\n"; |
| 66 | + echo "--revert: revert the working config to the given version\n"; |
| 67 | + echo "\n"; |
| 68 | + } |
| 69 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Configure/manage.inc |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 70 | + native |
Index: trunk/extensions/Configure/Configure.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure', |
19 | 19 | 'description' => 'Allow authorised users to configure the wiki by a web-based interface', |
20 | 20 | 'descriptionmsg' => 'configure-desc', |
21 | | - 'version' => '0.4.3', |
| 21 | + 'version' => '0.4.4', |
22 | 22 | ); |
23 | 23 | |
24 | 24 | ## Adding new rights... |
Index: trunk/extensions/Configure/SpecialConfigure.php |
— | — | @@ -182,8 +182,10 @@ |
183 | 183 | $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" ); |
184 | 184 | return; |
185 | 185 | } |
| 186 | + $this->mWiki = $wiki; |
| 187 | + } else { |
| 188 | + $this->mWiki = $wgConf->getWiki(); |
186 | 189 | } |
187 | | - $this->mWiki = $wiki; |
188 | 190 | |
189 | 191 | $this->outputHeader(); |
190 | 192 | |
Index: trunk/extensions/Configure/manage.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Maintenance script that helps to do maintenance with configuration files. |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + * @author Alexandre Emsenhuber |
| 10 | + * @license GPLv2 or higher |
| 11 | + */ |
| 12 | + |
| 13 | +$optionsWithArgs = array( 'revert', 'delete' ); |
| 14 | +//define( 'EXT_CONFIGURE_NO_EXTRACT', true ); |
| 15 | + |
| 16 | +$dir = dirname( __FILE__ ); |
| 17 | +$IP = "$dir/../.."; |
| 18 | +@include( "$dir/../CorePath.php" ); // Allow override |
| 19 | +require_once( "$IP/maintenance/commandLine.inc" ); |
| 20 | + |
| 21 | +require_once( dirname( __FILE__ ) . "/manage.inc" ); |
| 22 | + |
| 23 | +$obj = new ConfigurationManager( $options ); |
| 24 | +$obj->run(); |
Property changes on: trunk/extensions/Configure/manage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |