r36302 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36301‎ | r36302 | r36303 >
Date:17:04, 15 June 2008
Author:ialex
Status:old
Tags:
Comment:
Added manage.php maintenance script to do maintenance with configuration files
Modified paths:
  • /trunk/extensions/Configure/CHANGELOG (modified) (history)
  • /trunk/extensions/Configure/Configure.obj.php (modified) (history)
  • /trunk/extensions/Configure/Configure.php (modified) (history)
  • /trunk/extensions/Configure/README (modified) (history)
  • /trunk/extensions/Configure/SpecialConfigure.php (modified) (history)
  • /trunk/extensions/Configure/manage.inc (added) (history)
  • /trunk/extensions/Configure/manage.php (added) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.obj.php
@@ -74,10 +74,14 @@
7575 if( !is_array( $settings ) || $settings === array() )
7676 # hmmm
7777 return false;
78 - if( !$wiki )
79 - $wiki = $this->mWiki;
8078
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+ }
8286
8387 $arch = $this->getArchiveFileName();
8488 $cur = $this->getFileName();
@@ -90,6 +94,11 @@
9195 * extract settings for this wiki in $GLOBALS
9296 */
9397 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+
94103 list( $site, $lang ) = $this->siteFromDB( $this->mWiki );
95104 $rewrites = array( 'wiki' => $this->mWiki, 'site' => $site, 'lang' => $lang );
96105 $this->extractAllGlobals( $this->mWiki, $site, $rewrites );
@@ -102,6 +111,9 @@
103112 * @return array
104113 */
105114 public function getCurrent( $wiki ){
 115+ if( !empty( $this->conf[$wiki] ) )
 116+ return $this->conf[$wiki];
 117+
106118 list( $site, $lang ) = $this->siteFromDB( $wiki );
107119 $rewrites = array( 'wiki' => $wiki, 'site' => $site, 'lang' => $lang );
108120 return $this->getAll( $wiki, $site, $rewrites );
@@ -121,7 +133,7 @@
122134 * current timestamp
123135 * @return String full path to the file
124136 */
125 - protected function getArchiveFileName( $ts = null ){
 137+ public function getArchiveFileName( $ts = null ){
126138 global $IP;
127139
128140 if( $ts === null )
Index: trunk/extensions/Configure/CHANGELOG
@@ -1,6 +1,10 @@
22 This file lists changes on this extension.
33 Localisation updates are done on betawiki and aren't listed here.
44
 5+0.4.4 - 15 June 2008
 6+ Added manage.php maintenance script to do maintenance with configuration
 7+ files.
 8+
59 0.4.3 - 12 June 2008
610 $wgEnableCascadingProtection is obsolete in 1.13 +
711
Index: trunk/extensions/Configure/README
@@ -58,9 +58,12 @@
5959 == Troubleshooting ==
6060
6161 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.
6568
6669 == To do ==
6770
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
170 + native
Index: trunk/extensions/Configure/Configure.php
@@ -17,7 +17,7 @@
1818 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure',
1919 'description' => 'Allow authorised users to configure the wiki by a web-based interface',
2020 'descriptionmsg' => 'configure-desc',
21 - 'version' => '0.4.3',
 21+ 'version' => '0.4.4',
2222 );
2323
2424 ## Adding new rights...
Index: trunk/extensions/Configure/SpecialConfigure.php
@@ -182,8 +182,10 @@
183183 $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
184184 return;
185185 }
 186+ $this->mWiki = $wiki;
 187+ } else {
 188+ $this->mWiki = $wgConf->getWiki();
186189 }
187 - $this->mWiki = $wiki;
188190
189191 $this->outputHeader();
190192
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
125 + native

Status & tagging log