r43002 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43001‎ | r43002 | r43003 >
Date:17:52, 1 November 2008
Author:ialex
Status:old
Tags:
Comment:
Added database-based storage (inspired by ConfigureWMF extension):
* Users are able to choose beetween file-based and database-based storage
* a new maintenance script migrateToDB.php has been added to migrate configuration files to database storage
* database settings and memcached settings are not editable with it since they are required to get the configuration
* default storage is files for backward compatibility (don't forget that there's migrateToDB.php ;)
* dropped MediaWiki < 1.13 compatibility (requires r32578+)

Also updated configure-desc message, not sure if it should be fuzzied.
Modified paths:
  • /trunk/extensions/Configure/Configure.api.php (modified) (history)
  • /trunk/extensions/Configure/Configure.diff.php (modified) (history)
  • /trunk/extensions/Configure/Configure.func.php (modified) (history)
  • /trunk/extensions/Configure/Configure.handler-db.php (added) (history)
  • /trunk/extensions/Configure/Configure.handler-files.php (added) (history)
  • /trunk/extensions/Configure/Configure.handler.php (added) (history)
  • /trunk/extensions/Configure/Configure.i18n.php (modified) (history)
  • /trunk/extensions/Configure/Configure.obj.php (modified) (history)
  • /trunk/extensions/Configure/Configure.page.php (modified) (history)
  • /trunk/extensions/Configure/Configure.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings-core.php (modified) (history)
  • /trunk/extensions/Configure/Configure.settings.php (modified) (history)
  • /trunk/extensions/Configure/README (modified) (history)
  • /trunk/extensions/Configure/SpecialViewConfig.php (modified) (history)
  • /trunk/extensions/Configure/configure.sql (added) (history)
  • /trunk/extensions/Configure/manage.inc (modified) (history)
  • /trunk/extensions/Configure/migrateToDB.inc (added) (history)
  • /trunk/extensions/Configure/migrateToDB.php (added) (history)

Diff [purge]

Index: trunk/extensions/Configure/configure.sql
@@ -0,0 +1,40 @@
 2+--
 3+-- SQL schema for Configure extension
 4+--
 5+
 6+-- Information about each configuration version
 7+CREATE TABLE config_version (
 8+
 9+ -- Primary key, used for joins with config_setting table
 10+ cv_id int(11) NOT NULL auto_increment,
 11+
 12+ -- wiki concerned by this version
 13+ cv_wiki varbinary(32) NOT NULL,
 14+
 15+ -- TS_MV timestamp of the version
 16+ cv_timestamp varbinary(14) NOT NULL,
 17+
 18+ -- Whether this is the latest version for cv_wiki, will be used to get
 19+ -- all curent version when loading all the configuration at startup
 20+ cv_is_latest tinyint NOT NULL DEFAULT 0,
 21+
 22+ PRIMARY KEY ( cv_id ),
 23+ KEY cv_timestamp( cv_timestamp ),
 24+ KEY cv_is_latest( cv_is_latest )
 25+) /*$wgDBTableOptions*/;
 26+
 27+-- Configuration settings
 28+CREATE TABLE config_setting (
 29+
 30+ -- foreign key to config_version.cv_id, used for joins
 31+ cs_id int(11) NOT NULL,
 32+
 33+ -- setting's name
 34+ cs_name varbinary(255) NOT NULL,
 35+
 36+ -- setting's value, in php serialized format
 37+ cs_value blob,
 38+
 39+ PRIMARY KEY ( cs_id, cs_name ),
 40+ KEY cs_id( cs_id )
 41+) /*$wgDBTableOptions*/;
\ No newline at end of file
Property changes on: trunk/extensions/Configure/configure.sql
___________________________________________________________________
Name: svn:eol-style
142 + native
Index: trunk/extensions/Configure/Configure.api.php
@@ -20,7 +20,7 @@
2121 if( in_array( 'versionlist', $params['prop'] ) ) {
2222 if( !$wgUser->isAllowed( 'viewconfig' ) )
2323 $this->dieUsage( 'viewconfig right required', 'noright' );
24 - $versions = $wgConf->listArchiveFiles();
 24+ $versions = $wgConf->listArchiveVersions();
2525 if( $wgUser->isAllowed( 'viewconfig-interwiki' ) ) {
2626 $oldVersions = $versions;
2727 $versions = array();
@@ -213,13 +213,7 @@
214214 case 'group-bool':
215215 $settingRet['values'] = array();
216216 $result->setIndexedTagName( $settingRet['values'], 'group' );
217 - if( is_callable( array( 'User', 'getAllRights' ) ) ){ // 1.13 +
218 - $all = User::getAllRights();
219 - } else {
220 - foreach( $settingVal as $rights )
221 - $all = array_merge( $all, array_keys( $rights ) );
222 - $all = array_unique( $all );
223 - }
 217+ $all = User::getAllRights();
224218 foreach( $settingVal as $group => $rights ){
225219 $arr = array( 'name' => $group, 'rights' => array() );
226220 $result->setIndexedTagName( $arr['rights'], 'permission' );
@@ -239,16 +233,13 @@
240234 $iter = array();
241235 foreach( $all as $group )
242236 $iter[$group] = isset( $settingVal[$group] ) && is_array( $settingVal[$group] ) ? $settingVal[$group] : array();
243 - if( $conf->isSettingAvailable( 'wgImplicitGroups' ) ) // 1.12 +
244 - $all = array_diff( $all, $settingsValues['wgImplicitGroups'] );
245 - else
246 - $all = array_diff( $all, User::getImplicitGroups() );
247 - }
 237+ $all = array_diff( $all, $settingsValues['wgImplicitGroups'] );
248238 foreach( $iter as $group => $value ){
249239 $arr = array( 'name' => $group, 'values' => $value );
250240 $result->setIndexedTagName( $arr['values'], 'value' );
251241 $settingRet['values'][] = $arr;
252242 }
 243+ }
253244 break;
254245 default:
255246 if( is_array( $type ) ){
Index: trunk/extensions/Configure/Configure.obj.php
@@ -12,7 +12,7 @@
1313 * @ingroup Extensions
1414 */
1515 class WebConfiguration extends SiteConfiguration {
16 - protected $mDir; // Directory of files, *with* leading /
 16+ protected $mHandler; // Configuration handler
1717 protected $mWiki; // Wiki name
1818 protected $mConf = array(); // Our array of settings
1919 protected $mOldSettings = array(); // Old settings (before applying our overrides)
@@ -24,14 +24,10 @@
2525 * @param string $path path to the directory that contains the configuration
2626 * files
2727 */
28 - public function __construct( $wiki = 'default', $path = null ){
29 - if( $path === null ){
30 - global $IP;
31 - $path = "$IP/serialized/";
32 - } else if( substr( $path, -1 ) != '/' && substr( $path, -1 ) != '\\' ) {
33 - $path .= '/';
34 - }
35 - $this->mDir = $path;
 28+ public function __construct( $wiki = 'default' ){
 29+ global $wgConfigureHandler;
 30+ $class = 'ConfigureHandler' . ucfirst( $wgConfigureHandler );
 31+ $this->mHandler = new $class();
3632 $this->mWiki = $wiki;
3733 }
3834
@@ -41,20 +37,7 @@
4238 */
4339 public function initialise(){
4440 parent::initialise();
45 - $file = $this->getFileName();
46 - if( !file_exists( $file ) )
47 - # maybe the first time the user use this extensions, do not override
48 - # anything
49 - return;
50 - $cont = file_get_contents( $file );
51 - if( empty( $cont ) )
52 - # Weird, should not happen
53 - return;
54 - $arr = unserialize( $cont );
55 - if( !is_array( $arr ) || $arr === array() )
56 - # Weird, should not happen too
57 - return;
58 - $this->mConf = $arr;
 41+ $this->mConf = $this->mHandler->getCurrent();
5942 $this->mOldSettings = $this->settings;
6043
6144 # We'll need to invert the order of keys as SiteConfiguration uses
@@ -154,20 +137,7 @@
155138 * @return array
156139 */
157140 public function getOldSettings( $ts ){
158 - $file = $this->getArchiveFileName( $ts );
159 - if( !file_exists( $file ) )
160 - # maybe the time the user use this extensions, do not override
161 - # anything
162 - return array();
163 - $cont = file_get_contents( $file );
164 - if( empty( $cont ) )
165 - # Weird, should not happen
166 - return array();
167 - $arr = unserialize( $cont );
168 - if( !is_array( $arr ) )
169 - # Weird, should not happen too
170 - return array();
171 - return $arr;
 141+ return $this->mHandler->getOldSettings( $ts );
172142 }
173143
174144 /**
@@ -231,69 +201,40 @@
232202
233203 if( $wiki === null ){
234204 $this->mConf = $settings;
 205+ $wiki = true;
235206 } else {
236207 if( $wiki === false )
237 - $wiki = $this->mWiki;
 208+ $wiki = $this->getWiki();
238209 $this->mConf[$wiki] = $settings;
239210 }
240211
241 - $arch = $this->getArchiveFileName();
242 - $cur = $this->getFileName();
243 - $cont = serialize( $this->mConf );
244 - file_put_contents( $arch, $cont );
245 - return ( file_put_contents( $cur, $cont ) !== false );
 212+ return $this->mHandler->saveNewSettings( $this->mConf, $wiki );
246213 }
247214
248215 /**
249216 * List all archived files that are like conf-{$ts}.ser
250217 * @return array of timestamps
251218 */
252 - public function listArchiveFiles(){
253 - if( !$dir = opendir( $this->mDir ) )
254 - return array();
255 - $files = array();
256 - while( ( $file = readdir( $dir ) ) !== false ) {
257 - if( preg_match( '/conf-(\d{14}).ser$/', $file, $m ) )
258 - $files[] = $m[1];
259 - }
260 - sort( $files, SORT_NUMERIC );
261 - return array_reverse( $files );
 219+ public function listArchiveVersions(){
 220+ return $this->mHandler->listArchiveVersions();
262221 }
263222
264223 /**
265 - * Get the current file name
266 - * @return String full path to the file
 224+ * Do some checks
267225 */
268 - protected function getFileName(){
269 - return "{$this->mDir}conf-now.ser";
 226+ public function doChecks(){
 227+ return $this->mHandler->doChecks();
270228 }
271229
272230 /**
273 - * Get the an archive file
274 - * @param $ts String: 14 char timestamp (YYYYMMDDHHMMSS) or null to use the
275 - * current timestamp
276 - * @return String full path to the file
 231+ * Get not editable settings with the current handler
 232+ * @return array
277233 */
278 - public function getArchiveFileName( $ts = null ){
279 - global $IP;
280 -
281 - if( $ts === null )
282 - $ts = wfTimestampNow();
283 -
284 - $file = "{$this->mDir}conf-$ts.ser";
285 - return $file;
 234+ public function getNotEditableSettings(){
 235+ return $this->mHandler->getNotEditableSettings();
286236 }
287237
288238 /**
289 - * Get the directory used to store the files
290 - *
291 - * @return String
292 - */
293 - public function getDir(){
294 - return $this->mDir;
295 - }
296 -
297 - /**
298239 * Get the wiki in use
299240 *
300241 * @return String
@@ -301,6 +242,14 @@
302243 public function getWiki(){
303244 return $this->mWiki;
304245 }
 246+
 247+ /**
 248+ * Get the configuration handler
 249+ * @return ConfigurationHandler
 250+ */
 251+ public function getHandler(){
 252+ return $this->mHandler;
 253+ }
305254
306255 /**
307256 * Merge array settings
Index: trunk/extensions/Configure/Configure.page.php
@@ -17,7 +17,7 @@
1818 * Constructor
1919 */
2020 public function __construct( $name, $right ) {
21 - efConfigureLoadMessages();
 21+ wfLoadExtensionMessages( 'Configure' );
2222 $this->mConfSettings = ConfigurationSettings::singleton( $this->getSettingMask() );
2323 parent::__construct( $name, $right );
2424 }
@@ -41,37 +41,27 @@
4242 // Since efConfigureSetup() should be explicitely called, don't go
4343 // further if that function wasn't called
4444 if( !$wgConf instanceof WebConfiguration ){
45 - $msg = wfMsgNoTrans( 'configure-no-setup' );
46 - $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
 45+ $wgOut->wrapWikiMsg( '<div class="errorbox"><strong>$1</strong></div>', 'configure-no-setup' );
4746 return;
4847 }
4948
50 - // Check that the directory exists...
51 - if( !is_dir( $wgConf->getDir() ) ){
52 - $msg = wfMsgNoTrans( 'configure-no-directory', $wgConf->getDir() );
53 - $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
 49+ $ret = $wgConf->doChecks();
 50+ if( count( $ret ) ) {
 51+ $wgOut->wrapWikiMsg( '<div class="errorbox"><strong>$1</strong></div>', $ret );
5452 return;
5553 }
56 -
57 - // And that it's writable by PHP
58 - if( !is_writable( $wgConf->getDir() ) ){
59 - $msg = wfMsgNoTrans( 'configure-directory-not-writable', $wgConf->getDir() );
60 - $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
61 - return;
62 - }
6354 }
6455
6556 $wikiParam = ( $this->mCanEdit && $wgRequest->wasPosted() ) ? 'wpWiki' : 'wiki';
6657 if( $wiki = $wgRequest->getVal( $wikiParam, false ) ){
6758 if( $wgConf->getWiki() != $wiki ){
6859 if( !$this->isUserAllowedInterwiki() || $wgConfigureWikis === false ){
69 - $msg = wfMsgNoTrans( 'configure-no-transwiki' );
70 - $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
 60+ $wgOut->wrapWikiMsg( '<div class="errorbox"><strong>$1</strong></div>', 'configure-no-transwiki' );
7161 return;
7262 }
7363 if( is_array( $wgConfigureWikis ) && !in_array( $wiki, $wgConfigureWikis ) ){
74 - $msg = wfMsgNoTrans( 'configure-transwiki-not-in-range', $wiki, implode( ', ', $wgConfigureWikis ) );
75 - $wgOut->addWikiText( "<div class='errorbox'><strong>$msg</strong></div>" );
 64+ $wgOut->wrapWikiMsg( '<div class="errorbox"><strong>$1</strong></div>',
 65+ array( 'configure-transwiki-not-in-range', $wiki, implode( ', ', $wgConfigureWikis ) ) );
7666 return;
7767 }
7868 }
@@ -96,7 +86,7 @@
9787 $type = 'diff';
9888 }
9989 } else {
100 - $wgOut->addWikiText( wfMsgNoTrans( 'sessionfailure' ) );
 90+ $wgOut->addWikiMsg( 'sessionfailure' );
10191 $type = 'diff';
10292 }
10393 } else {
@@ -296,13 +286,12 @@
297287 global $wgConf, $wgOut, $wgRequest;
298288
299289 if( $version = $wgRequest->getVal( 'version' ) ){
300 - $versions = $wgConf->listArchiveFiles();
 290+ $versions = $wgConf->listArchiveVersions();
301291 if( in_array( $version, $versions ) ){
302292 $conf = $wgConf->getOldSettings( $version );
303293 $this->conf = $conf[$this->mWiki];
304294 if( !isset( $conf[$this->mWiki] ) ){
305 - $msg = wfMsgNoTrans( 'configure-old-not-available', $version );
306 - $wgOut->addWikiText( "<div class='errorbox'>$msg</div>" );
 295+ $wgOut->addWikiText( '<div class="errorbox">$1</div>', array( 'configure-old-not-available', $version ) );
307296 return false;
308297 }
309298 $current = null;
@@ -313,10 +302,9 @@
314303 $this->conf[$name] += $current[$name];
315304 }
316305 }
317 - $wgOut->addWikiText( wfMsgNoTrans( 'configure-edit-old' ) );
 306+ $wgOut->addWikiMsg( 'configure-edit-old' );
318307 } else {
319 - $msg = wfMsgNoTrans( 'configure-old-not-available', $version );
320 - $wgOut->addWikiText( "<div class='errorbox'>$msg</div>" );
 308+ $wgOut->addWikiText( '<div class="errorbox">$1</div>', array( 'configure-old-not-available', $version ) );
321309 return false;
322310 }
323311 } else {
@@ -330,7 +318,7 @@
331319 */
332320 protected function buildOldVersionSelect(){
333321 global $wgConf, $wgLang, $wgUser;
334 - $versions = $wgConf->listArchiveFiles();
 322+ $versions = $wgConf->listArchiveVersions();
335323 $text = '<fieldset><legend>' . wfMsgHtml( 'configure-old' ) . '</legend>';
336324 if( empty( $versions ) ){
337325 $text .= wfMsgExt( 'configure-no-old', array( 'parse' ) );
@@ -341,9 +329,7 @@
342330 $title = $this->getTitle();
343331 if( count( $versions ) > 10 ){
344332 $versions = array_slice( $versions, 0, 10 );
345 - $link = is_callable( array( 'SpecialPage', 'getTitleFor' ) ) ? # 1.9 +
346 - SpecialPage::getTitleFor( 'ViewConfig' ) :
347 - Title::makeTitle( NS_SPECIAL, 'ViewConfig' );
 333+ $link = SpecialPage::getTitleFor( 'ViewConfig' );
348334 $moreLink = $skin->makeKnownLinkObj( $link, wfMsgHtml( 'configure-view-all-versions' ) );
349335 } else {
350336 $moreLink = '';
@@ -488,18 +474,9 @@
489475 $iter = array_keys( $this->getSettingValue( 'wgGroupPermissions' ) );
490476 }
491477 if( $arrType == 'group-bool' ){
492 - if( is_callable( array( 'User', 'getAllRights' ) ) ){ // 1.13 +
493 - $all = User::getAllRights();
494 - } else {
495 - foreach( $this->getSettingValue( 'wgGroupPermissions' ) as $rights )
496 - $all = array_merge( $all, array_keys( $rights ) );
497 - $all = array_unique( $all );
498 - }
 478+ $all = User::getAllRights();
499479 } else {
500 - if( $this->isSettingAvailable( 'wgImplicitGroups' ) ) // 1.12 +
501 - $all = array_diff( $iter, $this->getSettingValue( 'wgImplicitGroups' ) );
502 - else
503 - $all = array_diff( $all, User::getImplicitGroups() );
 480+ $all = array_diff( $iter, $this->getSettingValue( 'wgImplicitGroups' ) );
504481 }
505482 foreach( $iter as $group ){
506483 foreach( $all as $right ){
@@ -674,7 +651,7 @@
675652 protected function injectScriptsAndStyles() {
676653 global $wgOut, $wgScriptPath, $wgUseAjax, $wgJsMimeType, $wgConfigureStyleVersion;
677654 $href = "{$wgScriptPath}/extensions/Configure/Configure.css?{$wgConfigureStyleVersion}";
678 - if( is_callable( array( $wgOut, 'addExtensionStyle' ) ) ){
 655+ if( is_callable( array( $wgOut, 'addExtensionStyle' ) ) ){ # 1.14+
679656 $wgOut->addExtensionStyle( $href );
680657 } else {
681658 $wgOut->addLink(
@@ -685,19 +662,11 @@
686663 )
687664 );
688665 }
689 - if( is_callable( array( 'Xml', 'encodeJsVar' ) ) ){ # 1.9 +
690 - $add = Xml::encodeJsVar( wfMsg( 'configure-js-add' ) );
691 - $remove = Xml::encodeJsVar( wfMsg( 'configure-js-remove' ) );
692 - $removeRow = Xml::encodeJsVar( wfMsg( 'configure-js-remove-row' ) );
693 - $promptGroup = Xml::encodeJsVar( wfMsg( 'configure-js-prompt-group' ) );
694 - $groupExists = Xml::encodeJsVar( wfMsg( 'configure-js-group-exists' ) );
695 - } else {
696 - $add = '"' . Xml::escapeJsString( wfMsg( 'configure-js-add' ) ). '"';
697 - $remove = '"' . Xml::escapeJsString( wfMsg( 'configure-js-remove' ) ) . '"';
698 - $removeRow = '"' . Xml::escapeJsString( wfMsg( 'configure-js-remove-row' ) ) . '"';
699 - $promptGroup = '"' . Xml::escapeJsString( wfMsg( 'configure-js-prompt-group' ) ) . '"';
700 - $groupExists = '"' . Xml::escapeJsString( wfMsg( 'configure-js-group-exists' ) ) . '"';
701 - }
 666+ $add = Xml::encodeJsVar( wfMsg( 'configure-js-add' ) );
 667+ $remove = Xml::encodeJsVar( wfMsg( 'configure-js-remove' ) );
 668+ $removeRow = Xml::encodeJsVar( wfMsg( 'configure-js-remove-row' ) );
 669+ $promptGroup = Xml::encodeJsVar( wfMsg( 'configure-js-prompt-group' ) );
 670+ $groupExists = Xml::encodeJsVar( wfMsg( 'configure-js-group-exists' ) );
702671 $ajax = isset( $wgUseAjax ) && $wgUseAjax ? 'true' : 'false';
703672 $script = array(
704673 "<script type=\"$wgJsMimeType\">/*<![CDATA[*/",
@@ -760,7 +729,6 @@
761730 return $this->buildArrayInput( $conf, $default, $allowed );
762731 }
763732 if( $type == 'lang' ){
764 - // Code taken from Xml.php, Xml::LanguageSelector only available since 1.11 and Xml::option since 1.8
765733 $languages = Language::getLanguageNames( true );
766734
767735 if( $allowed ){
@@ -961,23 +929,14 @@
962930 $all = array();
963931 $attr = ( !$allowed ) ? array( 'disabled' => 'disabled' ) : array();
964932 if( $type == 'group-bool' ){
965 - if( is_callable( array( 'User', 'getAllRights' ) ) ){ // 1.13 +
966 - $all = User::getAllRights();
967 - } else {
968 - foreach( $default as $rights )
969 - $all = array_merge( $all, array_keys( $rights ) );
970 - $all = array_unique( $all );
971 - }
 933+ $all = User::getAllRights();
972934 $iter = $default;
973935 } else {
974936 $all = array_keys( $this->getSettingValue( 'wgGroupPermissions' ) );
975937 $iter = array();
976938 foreach( $all as $group )
977939 $iter[$group] = isset( $default[$group] ) && is_array( $default[$group] ) ? $default[$group] : array();
978 - if( $this->isSettingAvailable( 'wgImplicitGroups' ) ) // 1.12 +
979 - $all = array_diff( $all, $this->getSettingValue( 'wgImplicitGroups' ) );
980 - else
981 - $all = array_diff( $all, User::getImplicitGroups() );
 940+ $all = array_diff( $all, $this->getSettingValue( 'wgImplicitGroups' ) );
982941 }
983942 $groupdesc = wfMsgHtml( 'configure-desc-group' );
984943 $valdesc = wfMsgHtml( 'configure-desc-val' );
Index: trunk/extensions/Configure/Configure.handler-files.php
@@ -0,0 +1,160 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+
 5+/**
 6+ * Class that hold the configuration
 7+ *
 8+ * @ingroup Extensions
 9+ */
 10+class ConfigureHandlerFiles implements ConfigureHandler {
 11+ protected $mDir; // Directory of files, *with* leading /
 12+
 13+ /**
 14+ * Construct a new object.
 15+ *
 16+ * @param string $path path to the directory that contains the configuration
 17+ * files
 18+ */
 19+ public function __construct(){
 20+ global $wgConfigureFilesPath;
 21+ if( $wgConfigureFilesPath === null ){
 22+ global $IP;
 23+ $wgConfigureFilesPath = "$IP/serialized/";
 24+ } else if( substr( $wgConfigureFilesPath, -1 ) != '/' && substr( $wgConfigureFilesPath, -1 ) != '\\' ) {
 25+ $wgConfigureFilesPath .= '/';
 26+ }
 27+ $this->mDir = $wgConfigureFilesPath;
 28+ }
 29+
 30+ /**
 31+ * Load the configuration from the conf-now.ser file in the $this->mDir
 32+ * directory
 33+ */
 34+ public function getCurrent(){
 35+ $file = $this->getFileName();
 36+ if( !file_exists( $file ) )
 37+ # maybe the first time the user use this extensions, do not override
 38+ # anything
 39+ return array();
 40+ $cont = file_get_contents( $file );
 41+ if( empty( $cont ) )
 42+ # Weird, should not happen
 43+ return array();
 44+ $arr = unserialize( $cont );
 45+ if( !is_array( $arr ) )
 46+ # Weird, should not happen too
 47+ return;
 48+ return $arr;
 49+ }
 50+
 51+ /**
 52+ * Return the configuration from the conf-{$ts}.ser file in the $this->mDir
 53+ * Does *not* return site specific settings but *all* settings
 54+ *
 55+ * @param $ts timestamp
 56+ * @return array
 57+ */
 58+ public function getOldSettings( $ts ){
 59+ $file = $this->getArchiveFileName( $ts );
 60+ if( !file_exists( $file ) )
 61+ # maybe the time the user use this extensions, do not override
 62+ # anything
 63+ return array();
 64+ $cont = file_get_contents( $file );
 65+ if( empty( $cont ) )
 66+ # Weird, should not happen
 67+ return array();
 68+ $arr = unserialize( $cont );
 69+ if( !is_array( $arr ) )
 70+ # Weird, should not happen too
 71+ return array();
 72+ return $arr;
 73+ }
 74+
 75+ /**
 76+ * Save a new configuration
 77+ * @param $settings array of settings
 78+ * @param $wiki String: wiki name or true for all
 79+ * @return bool true on success
 80+ */
 81+ public function saveNewSettings( $settings, $wiki ){
 82+ $arch = $this->getArchiveFileName();
 83+ $cur = $this->getFileName();
 84+ $cont = serialize( $settings );
 85+ file_put_contents( $arch, $cont );
 86+ return ( file_put_contents( $cur, $cont ) !== false );
 87+ }
 88+
 89+ /**
 90+ * List all archived files that are like conf-{$ts}.ser
 91+ * @return array of timestamps
 92+ */
 93+ public function listArchiveVersions(){
 94+ if( !$dir = opendir( $this->mDir ) )
 95+ return array();
 96+ $files = array();
 97+ while( ( $file = readdir( $dir ) ) !== false ) {
 98+ if( preg_match( '/conf-(\d{14}).ser$/', $file, $m ) )
 99+ $files[] = $m[1];
 100+ }
 101+ sort( $files, SORT_NUMERIC );
 102+ return array_reverse( $files );
 103+ }
 104+
 105+ /**
 106+ * Do some checks
 107+ */
 108+ public function doChecks(){
 109+ // Check that the directory exists...
 110+ if( !is_dir( $this->getDir() ) ){
 111+ return array( 'configure-no-directory', $this->getDir() );
 112+ }
 113+
 114+ // And that it's writable by PHP
 115+ if( !is_writable( $this->getDir() ) ){
 116+ return array( 'configure-directory-not-writable', $this->getDir() );
 117+ }
 118+
 119+ return array();
 120+ }
 121+
 122+ /**
 123+ * All settings are editable!
 124+ */
 125+ public function getNotEditableSettings(){
 126+ return array();
 127+ }
 128+
 129+ /**
 130+ * Get the current file name
 131+ * @return String full path to the file
 132+ */
 133+ protected function getFileName(){
 134+ return "{$this->mDir}conf-now.ser";
 135+ }
 136+
 137+ /**
 138+ * Get the an archive file
 139+ * @param $ts String: 14 char timestamp (YYYYMMDDHHMMSS) or null to use the
 140+ * current timestamp
 141+ * @return String full path to the file
 142+ */
 143+ public function getArchiveFileName( $ts = null ){
 144+ global $IP;
 145+
 146+ if( $ts === null )
 147+ $ts = wfTimestampNow();
 148+
 149+ $file = "{$this->mDir}conf-$ts.ser";
 150+ return $file;
 151+ }
 152+
 153+ /**
 154+ * Get the directory used to store the files
 155+ *
 156+ * @return String
 157+ */
 158+ public function getDir(){
 159+ return $this->mDir;
 160+ }
 161+}
Property changes on: trunk/extensions/Configure/Configure.handler-files.php
___________________________________________________________________
Name: svn:eol-style
1162 + native
Index: trunk/extensions/Configure/Configure.handler.php
@@ -0,0 +1,55 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+
 5+/**
 6+ * Interface for configuration handler
 7+ *
 8+ * @ingroup Extensions
 9+ */
 10+interface ConfigureHandler {
 11+
 12+ /**
 13+ * Construct a new object.
 14+ */
 15+ public function __construct();
 16+
 17+ /**
 18+ * Load the current configuration
 19+ */
 20+ public function getCurrent();
 21+
 22+ /**
 23+ * Return the old configuration from $ts timestamp
 24+ * Does *not* return site specific settings but *all* settings
 25+ *
 26+ * @param $ts timestamp
 27+ * @return array
 28+ */
 29+ public function getOldSettings( $ts );
 30+
 31+ /**
 32+ * Save a new configuration
 33+ * @param $settings array of settings
 34+ * @param $wiki String: wiki name or false to use the current one
 35+ * @return bool true on success
 36+ */
 37+ public function saveNewSettings( $settings, $wiki );
 38+
 39+ /**
 40+ * List all archived versions
 41+ * @return array of timestamps
 42+ */
 43+ public function listArchiveVersions();
 44+
 45+ /**
 46+ * Do some checks
 47+ * @return array
 48+ */
 49+ public function doChecks();
 50+
 51+ /**
 52+ * Get settings that are not editable with this handler
 53+ * @return array
 54+ */
 55+ public function getNotEditableSettings();
 56+}
Property changes on: trunk/extensions/Configure/Configure.handler.php
___________________________________________________________________
Name: svn:eol-style
157 + native
Index: trunk/extensions/Configure/Configure.i18n.php
@@ -10,7 +10,7 @@
1111
1212 $messages['en'] = array(
1313 'configure' => 'Configure the wiki',
14 - 'configure-desc' => 'Allow authorised users to [[Special:Configure|configure]] the wiki by a web-based interface',
 14+ 'configure-desc' => 'Allow authorised users to [[Special:Configure|configure]] the wiki via a web-based interface',
1515 'configure-desc-group' => 'Groups',
1616 'configure-desc-key' => 'Key',
1717 'configure-desc-ns' => 'Namespaces',
@@ -27,6 +27,9 @@
2828
2929 'configure-summary' => 'This special page allow you to configure this wiki, see [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings] for more information.',
3030 'configure-btn-save' => 'Save settings',
 31+ 'configure-db-error' => 'The database you specified to hold the configuration ($1) does not exist.
 32+Please create it and apply configure.sql or correct its name.',
 33+ 'configure-db-table-error' => 'The database you specified does not have the required tables. Please apply configure.sql in that database.',
3134 'configure-directory-not-writable' => 'The directory used to store the settings, <tt>$1</tt>, is not writable.
3235 Please make it writable by PHP to use this extension.',
3336 'configure-edit-old' => 'Warning: you are editing an <strong>old</strong> version of the configuration.',
Index: trunk/extensions/Configure/migrateToDB.php
@@ -0,0 +1,21 @@
 2+<?php
 3+
 4+/**
 5+ * Maintenance script that migrate configuration from files to database.
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @author Alexandre Emsenhuber
 10+ * @license GPLv2 or higher
 11+ */
 12+
 13+$IP = getenv( 'MW_INSTALL_PATH' );
 14+if( $IP === false )
 15+ $IP = dirname( __FILE__ ). '/../..';
 16+
 17+require_once( "$IP/maintenance/commandLine.inc" );
 18+
 19+require_once( dirname( __FILE__ ) . "/migrateToDB.inc" );
 20+
 21+$obj = new FilesToDB( $options );
 22+$obj->run();
Property changes on: trunk/extensions/Configure/migrateToDB.php
___________________________________________________________________
Name: svn:eol-style
123 + native
Index: trunk/extensions/Configure/SpecialViewConfig.php
@@ -29,7 +29,7 @@
3030 $this->isWebConfig = $wgConf instanceof WebConfiguration;
3131
3232 if( $this->isWebConfig && $version = $wgRequest->getVal( 'version' ) ){
33 - $versions = $wgConf->listArchiveFiles();
 33+ $versions = $wgConf->listArchiveVersions();
3434 if( in_array( $version, $versions ) ){
3535 $conf = $wgConf->getOldSettings( $version );
3636 if( $this->isUserAllowedAll() ){
@@ -118,7 +118,7 @@
119119 if( !$this->isWebConfig )
120120 return '';
121121
122 - $versions = $wgConf->listArchiveFiles();
 122+ $versions = $wgConf->listArchiveVersions();
123123 if( empty( $versions ) ){
124124 return wfMsgExt( 'configure-no-old', array( 'parse' ) );
125125 }
@@ -135,14 +135,10 @@
136136 $allowedExtensionsAll = $wgUser->isAllowed( 'extensions-interwiki' );
137137
138138 if( $allowedConfig )
139 - $configTitle = is_callable( array( 'SpecialPage', 'getTitleFor' ) ) ? # 1.9 +
140 - SpecialPage::getTitleFor( 'Configure' ) :
141 - Title::makeTitle( NS_SPECIAL, 'Configure' );
 139+ $configTitle = SpecialPage::getTitleFor( 'Configure' );
142140
143141 if( $allowedExtensions )
144 - $extTitle = is_callable( array( 'SpecialPage', 'getTitleFor' ) ) ? # 1.9 +
145 - SpecialPage::getTitleFor( 'Extensions' ) :
146 - Title::makeTitle( NS_SPECIAL, 'Extensions' );
 142+ $extTitle = SpecialPage::getTitleFor( 'Extensions' );
147143
148144 $text = wfMsgExt( 'configure-old-versions', array( 'parse' ) );
149145 if( $showDiff )
Index: trunk/extensions/Configure/Configure.settings-core.php
@@ -70,7 +70,6 @@
7171 'wgSharedTables' => 'array',
7272 ),
7373 'load-balancing' => array(
74 - 'wgAlternateMaster' => 'array',
7574 'wgDBClusterTimeout' => 'int',
7675 'wgDBservers' => 'array',
7776 'wgDefaultExternalStore' => 'array',
@@ -116,7 +115,6 @@
117116 'wgEnotifUseJobQ' => 'bool',
118117 'wgEnotifUserTalk' => 'bool',
119118 'wgEnotifWatchlist' => 'bool',
120 - 'wgUsersNotifedOnAllChanges' => 'array',
121119 'wgUsersNotifiedOnAllChanges' => 'array',
122120 ),
123121 ),
@@ -177,10 +175,7 @@
178176 'wgProfileLimit' => 'int',
179177 'wgProfileOnly' => 'bool',
180178 'wgProfilePerHost' => 'bool',
181 - 'wgProfileSampleRate' => 'int',
182179 'wgProfileToDatabase' => 'bool',
183 - 'wgProfilerType' => 'text',
184 - 'wgProfiling' => 'bool',
185180 'wgUDPProfilerHost' => 'text',
186181 'wgUDPProfilerPort' => 'int',
187182 ),
@@ -285,8 +280,6 @@
286281 'wgTranscludeCacheExpiry' => 'int',
287282 'wgUseFileCache' => 'bool',
288283 'wgUseGzip' => 'bool',
289 - 'wgUseWatchlistCache' => 'bool',
290 - 'wgWLCacheTimeout' => 'int',
291284 ),
292285 'pcache' => array(
293286 'wgParserCacheType' => array( -1 => 'Anything', 0 => 'None',
@@ -304,13 +297,11 @@
305298 3 => 'Accel', 4 => 'DBA' ),
306299 'wgLocalMessageCache' => 'text',
307300 'wgMsgCacheExpiry' => 'int',
308 - 'wgCachedMessageArrays' => 'text',
309301 'wgCheckSerialized' => 'bool',
310302 'wgLocalMessageCacheSerialized' => 'bool',
311303 'wgMaxMsgCacheEntrySize' => 'int',
312304 ),
313305 'memcached' => array(
314 - 'wgLinkCacheMemcached' => 'bool',
315306 'wgMemCachedDebug' => 'bool',
316307 'wgMemCachedPersistent' => 'bool',
317308 'wgMemCachedServers' => 'array',
@@ -340,7 +331,6 @@
341332 'wgDeleteRevisionsLimit' => 'int',
342333 'wgDisabledActions' => 'array',
343334 'wgEmailConfirmToEdit' => 'bool',
344 - 'wgEnableCascadingProtection' => 'bool',
345335 'wgEnableAPI' => 'bool',
346336 'wgEnableWriteAPI' => 'bool',
347337 'wgFilterCallback' => 'text',
@@ -448,7 +438,6 @@
449439 'wgMaxUploadSize' => 'int',
450440 'wgHTTPTimeout' => 'int',
451441 'wgHTTPProxy' => 'text',
452 - 'wgSaveDeletedFiles' => 'bool',
453442 ),
454443 'sharedupload' => array(
455444 'wgCacheSharedUploads' => 'bool',
@@ -478,7 +467,6 @@
479468 'images' => array(
480469 'wgAllowImageMoving' => 'bool',
481470 'wgCustomConvertCommand' => 'text',
482 - 'wgFileRedirects' => 'bool',
483471 'wgGenerateThumbnailOnParse' => 'bool',
484472 'wgIgnoreImageErrors' => 'bool',
485473 'wgImageLimits' => 'array',
@@ -488,7 +476,6 @@
489477 'wgThumbnailScriptPath' => 'text',
490478 'wgThumbUpright' => 'text',
491479 'wgShowEXIF' => 'bool',
492 - 'wgUseImageResize' => 'bool',
493480 'wgThumbLimits' => 'array',
494481 'wgTrustedMediaFormats' => 'array',
495482 ),
@@ -537,11 +524,9 @@
538525 'wgParserCacheExpireTime' => 'int',
539526 'wgParserTestFiles' => 'array',
540527 'wgRestrictDisplayTitle' => 'bool',
541 - 'wgUseXMLparser' => 'bool',
542528 ),
543529 'html' => array(
544530 'wgRawHtml' => 'bool',
545 - 'wgUserHtml' => 'bool',
546531 ),
547532 'tex' => array(
548533 'wgTexvc' => 'text',
@@ -727,7 +712,6 @@
728713 $arrayDefs = array(
729714 'wgActionPaths' => 'assoc',
730715 # Db
731 - 'wgAlternateMaster' => 'assoc',
732716 'wgDBservers' => 'array',
733717 'wgDefaultExternalStore' => 'simple',
734718 'wgLocalDatabases' => 'simple',
@@ -736,7 +720,6 @@
737721 'wgSharedTables' => 'simple',
738722 # Email
739723 'wgSMTP' => 'assoc',
740 - 'wgUsersNotifedOnAllChanges' => 'simple',
741724 'wgUsersNotifiedOnAllChanges' => 'simple',
742725 # Localization
743726 'wgForceUIMsgAsContentMsg' => 'simple',
@@ -923,7 +906,6 @@
924907 'wgVariantArticlePath',
925908 # Db
926909 'wgAllDBsAreLocalhost',
927 - 'wgAlternateMaster',
928910 'wgCheckDBSchema',
929911 'wgDBAvgStatusPoll',
930912 'wgDBClusterTimeout',
@@ -1071,132 +1053,6 @@
10721054 * Array of settings depending of the Core version
10731055 */
10741056 $settingsVersion = array(
1075 -# 1.8.0
1076 - 'wgAllowCopyUploads' => array( array( '1.8alpha', '>=' ) ),
1077 - 'wgDBmwschema' => array( array( '1.8alpha', '>=' ) ),
1078 - 'wgDBts2schema' => array( array( '1.8alpha', '>=' ) ),
1079 - 'wgDjvuPostProcessor' => array( array( '1.8alpha', '>=' ) ),
1080 - 'wgDjvuRenderer' => array( array( '1.8alpha', '>=' ) ),
1081 - 'wgDjvuToXML' => array( array( '1.8alpha', '>=' ) ),
1082 - 'wgMaxShellFileSize' => array( array( '1.8alpha', '>=' ) ),
1083 - 'wgMaxUploadSize' => array( array( '1.8alpha', '>=' ) ),
1084 - 'wgRevisionCacheExpiry' => array( array( '1.8alpha', '>=' ) ),
1085 - 'wgUseETag' => array( array( '1.8alpha', '>=' ) ),
1086 -# 1.8.1
1087 - 'wgEnableAPI' => array( array( '1.8.1', '>=' ) ),
1088 - 'wgEnableWriteAPI' => array( array( '1.8.1', '>=' ) ),
1089 - 'wgShowExceptionDetails' => array( array( '1.8.1', '>=' ) ),
1090 -# 1.9
1091 - 'wgAjaxWatch' => array( array( '1.9alpha', '>=' ) ),
1092 - 'wgBreakFrames' => array( array( '1.9alpha', '>=' ) ),
1093 - 'wgDefaultLanguageVariant' => array( array( '1.9alpha', '>=' ) ),
1094 - 'wgDisableQueryPageUpdate' => array( array( '1.9alpha', '>=' ) ),
1095 - 'wgMaxMsgCacheEntrySize' => array( array( '1.9alpha', '>=' ) ),
1096 - 'wgParserTestFiles' => array( array( '1.9alpha', '>=' ) ),
1097 - 'wgPasswordReminderResendTime' => array( array( '1.9alpha', '>=' ) ),
1098 - 'wgQueryCacheLimit' => array( array( '1.9alpha', '>=' ) ),
1099 - 'wgRCChangedSizeThreshold' => array( array( '1.9alpha', '>=' ) ),
1100 - 'wgRCShowChangedSize' => array( array( '1.9alpha', '>=' ) ),
1101 - 'wgStyleVersion' => array( array( '1.9alpha', '>=' ) ),
1102 - 'wgVariantArticlePath' => array( array( '1.9alpha', '>=' ) ),
1103 - 'wgXhtmlDefaultNamespace' => array( array( '1.9alpha', '>=' ) ),
1104 - 'wgXhtmlNamespaces' => array( array( '1.9alpha', '>=' ) ),
1105 - 'wgSorbsUrl' => array( array( '1.9alpha', '>=' ) ),
1106 -# 1.10
1107 - 'wgAutoConfirmCount' => array( array( '1.10alpha', '>=' ) ),
1108 - 'wgCommandLineDarkBg' => array( array( '1.10alpha', '>=' ) ),
1109 - 'wgDBTableOptions' => array( array( '1.10alpha', '>=' ) ),
1110 - 'wgDisableOutputCompression' => array( array( '1.10alpha', '>=' ) ),
1111 - 'wgMediaHandlers' => array( array( '1.10alpha', '>=' ) ),
1112 - 'wgNamespaceAliases' => array( array( '1.10alpha', '>=' ) ),
1113 - 'wgNamespaceProtection' => array( array( '1.10alpha', '>=' ) ),
1114 - 'wgNonincludableNamespaces' => array( array( '1.10alpha', '>=' ) ),
1115 - 'wgSharpenReductionThreshold' => array( array( '1.10alpha', '>=' ) ),
1116 - 'wgSharpenParameter' => array( array( '1.10alpha', '>=' ) ),
1117 - 'wgDjvuDump' => array( array( '1.10alpha', '>=' ) ),
1118 - 'wgDjvuOutputExtension' => array( array( '1.10alpha', '>=' ) ),
1119 -# 1.11
1120 - 'wgAPIModules' => array( array( '1.11alpha', '>=' ) ),
1121 - 'wgAddGroups' => array( array( '1.11alpha', '>=' ) ),
1122 - 'wgAjaxLicensePreview' => array( array( '1.11alpha', '>=' ) ),
1123 - 'wgAjaxUploadDestCheck' => array( array( '1.11alpha', '>=' ) ),
1124 - 'wgArticleRobotPolicies' => array( array( '1.11alpha', '>=' ) ),
1125 - 'wgEnotifImpersonal' => array( array( '1.11alpha', '>=' ) ),
1126 - 'wgEnotifMaxRecips' => array( array( '1.11alpha', '>=' ) ),
1127 - 'wgEnotifUseJobQ' => array( array( '1.11alpha', '>=' ) ),
1128 - 'wgExtensionMessagesFiles' => array( array( '1.11alpha', '>=' ) ),
1129 - 'wgForeignFileRepos' => array( array( '1.11alpha', '>=' ) ),
1130 - 'wgJobClasses' => array( array( '1.11alpha', '>=' ) ),
1131 - 'wgLocalFileRepo' => array( array( '1.11alpha', '>=' ) ),
1132 - 'wgMaxSigChars' => array( array( '1.11alpha', '>=' ) ),
1133 - 'wgParserOutputHooks' => array( array( '1.11alpha', '>=' ) ),
1134 - 'wgRemoveGroups' => array( array( '1.11alpha', '>=' ) ),
1135 - 'wgScriptExtension' => array( array( '1.11alpha', '>=' ) ),
1136 - 'wgShowHostnames' => array( array( '1.11alpha', '>=' ) ),
1137 - 'wgSlaveLagCritical' => array( array( '1.11alpha', '>=' ) ),
1138 - 'wgSlaveLagWarning' => array( array( '1.11alpha', '>=' ) ),
1139 - 'wgSysopEmailBans' => array( array( '1.11alpha', '>=' ) ),
1140 - 'wgThumbUpright' => array( array( '1.11alpha', '>=' ) ),
1141 -# 1.12
1142 - 'wgAppleTouchIcon' => array( array( '1.12alpha', '>=' ) ),
1143 - 'wgAutopromote' => array( array( '1.12alpha', '>=' ) ),
1144 - 'wgImplicitGroups' => array( array( '1.12alpha', '>=' ) ),
1145 - 'wgCheckSerialized' => array( array( '1.12alpha', '>=' ) ),
1146 - 'wgDBAvgStatusPoll' => array( array( '1.12alpha', '>=' ) ),
1147 - 'wgDebugTidy' => array( array( '1.12alpha', '>=' ) ),
1148 - 'wgDefaultRobotPolicy' => array( array( '1.12alpha', '>=' ) ),
1149 - 'wgDeleteRevisionsLimit' => array( array( '1.12alpha', '>=' ) ),
1150 - 'wgExtraLanguageNames' => array( array( '1.12alpha', '>=' ) ),
1151 - 'wgGroupsAddToSelf' => array( array( '1.12alpha', '>=' ) ),
1152 - 'wgGroupsRemoveFromSelf' => array( array( '1.12alpha', '>=' ) ),
1153 - 'wgForcedRawSMaxage' => array( array( '1.12alpha', '>=' ) ),
1154 - 'wgMaxPPNodeCount' => array( array( '1.12alpha', '>=' ) ),
1155 - 'wgParserConf' => array( array( '1.12alpha', '>=' ) ),
1156 - 'wgMaxTemplateDepth' => array( array( '1.12alpha', '>=' ) ),
1157 - 'wgSidebarCacheExpiry' => array( array( '1.12alpha', '>=' ) ),
1158 - 'wgStatsMethod' => array( array( '1.12alpha', '>=' ) ),
1159 - 'wgUseNPPatrol' => array( array( '1.12alpha', '>=' ) ),
1160 - 'wgUserEmailUseReplyTo' => array( array( '1.12alpha', '>=' ) ),
1161 - 'wgValidateAllHtml' => array( array( '1.12alpha', '>=' ) ),
1162 -# 1.13
1163 - 'wgFeed' => array( array( '1.13alpha', '>=' ) ),
1164 - 'wgPagePropLinkInvalidations' => array( array( '1.13alpha', '>=' ) ),
1165 - 'wgMaxRedirectLinksRetrieved' => array( array( '1.13alpha', '>=' ) ),
1166 - 'wgMaxPPExpandDepth' => array( array( '1.13alpha', '>=' ) ),
1167 - 'wgLBFactoryConf' => array( array( '1.13alpha', '>=' ) ),
1168 - 'wgExpensiveParserFunctionLimit' => array( array( '1.13alpha', '>=' ) ),
1169 - 'wgUsersNotifiedOnAllChanges' => array( array( '1.13alpha', '>=' ) ),
1170 - 'wgAllDBsAreLocalhost' => array( array( '1.13alpha', '>=' ) ),
1171 - 'wgCookieHttpOnly' => array( array( '1.13alpha', '>=' ) ),
1172 - 'wgLogRestrictions' => array( array( '1.13alpha', '>=' ) ),
1173 - 'wgEnableMWSuggest' => array( array( '1.13alpha', '>=' ) ),
1174 - 'wgMWSuggestTemplate' => array( array( '1.13alpha', '>=' ) ),
1175 - 'wgOpenSearchTemplate' => array( array( '1.13alpha', '>=' ) ),
1176 - 'wgAPIMaxDBRows' => array( array( '1.13alpha', '>=' ) ),
1177 - 'wgSitemapNamespaces' => array( array( '1.13alpha', '>=' ) ),
1178 - 'wgCacheVaryCookies' => array( array( '1.13alpha', '>=' ) ),
1179 - 'wgHttpOnlyBlacklist' => array( array( '1.13alpha', '>=' ) ),
1180 - 'wgSpecialPageGroups' => array( array( '1.13alpha', '>=' ) ),
1181 - 'wgAllowImageMoving' => array( array( '1.13alpha', '>=' ) ),
1182 - 'wgAdvancedSearchHighlighting' => array( array( '1.13alpha', '>=' ) ),
1183 - 'wgSearchHighlightBoundaries' => array( array( '1.13alpha', '>=' ) ),
1184 - 'wgAvailableRights' => array( array( '1.13alpha', '>=' ) ),
1185 - 'wgSharedPrefix' => array( array( '1.13alpha', '>=' ) ),
1186 - 'wgSharedTables' => array( array( '1.13alpha', '>=' ) ),
1187 - 'wgSQLiteDataDir' => array( array( '1.13alpha', '>=' ) ),
1188 - 'wgUseAutomaticEditSummaries' => array( array( '1.13alpha', '>=' ) ),
1189 - 'wgRCFilterByAge' => array( array( '1.13alpha', '>=' ) ),
1190 - 'wgRCLinkLimits' => array( array( '1.13alpha', '>=' ) ),
1191 - 'wgRCLinkDays' => array( array( '1.13alpha', '>=' ) ),
1192 - 'wgMaximumMovedPages' => array( array( '1.13alpha', '>=' ) ),
1193 - 'wgSpecialVersionShowHooks' => array( array( '1.13alpha', '>=' ) ),
1194 - 'wgActiveUserDays' => array( array( '1.13alpha', '>=' ) ),
1195 - 'wgActiveUserEditCount' => array( array( '1.13alpha', '>=' ) ),
1196 - 'wgRC2UDPOmitBots' => array( array( '1.13alpha', '>=' ) ),
1197 - 'wgExtensionAliasesFiles' => array( array( '1.13alpha', '>=' ) ),
1198 - 'wgXMLMimeTypes' => array( array( '1.13alpha', '>=' ) ),
1199 - 'wgDirectoryMode' => array( array( '1.13alpha', '>=' ) ),
1200 - 'wgDiff' => array( array( '1.13alpha', '>=' ) ),
12011057 # 1.14
12021058 'wgExemptFromUserRobotsControl' => array( array( '1.14alpha', '>=' ) ),
12031059 'wgHandheldStyle' => array( array( '1.14alpha', '>=' ) ),
@@ -1225,37 +1081,5 @@
12261082 'wgFilterLogTypes' => array( array( '1.14alpha', '>=' ) ),
12271083 'wgRC2UDPInterwikiPrefix' => array( array( '1.14alpha', '>=' ) ),
12281084 ## Obsolete
1229 - 'wgProfileSampleRate' => array( array( '1.8alpha', '<' ) ),
1230 - 'wgProfilerType' => array( array( '1.8alpha', '<' ) ),
1231 - 'wgProfiling' => array( array( '1.8alpha', '<' ) ),
1232 - 'wgUseXMLparser' => array( array( '1.8alpha', '<' ) ),
1233 - 'wgCachedMessageArrays' => array( array( '1.8alpha', '<' ) ),
1234 - 'wgUseWatchlistCache' => array( array( '1.9alpha', '<' ) ),
1235 - 'wgWLCacheTimeout' => array( array( '1.9alpha', '<' ) ),
1236 - 'wgUseImageResize' => array( array( '1.10alpha', '<' ) ),
1237 - 'wgUserHtml' => array( array( '1.10alpha', '<' ) ),
1238 - 'wgSaveDeletedFiles' => array( array( '1.11alpha', '<' ) ),
1239 - 'wgAlternateMaster' => array( array( '1.13alpha', '<' ) ),
1240 - 'wgLinkCacheMemcached' => array( array( '1.13alpha', '<' ) ),
1241 -## Both
1242 - 'wgAjaxSearch' => array(
1243 - array( '1.8alpha', '>=' ),
1244 - array( '1.14alpha', '<' ),
1245 - ),
1246 - 'wgAlternateMaster' => array(
1247 - array( '1.10alpha', '>=' ),
1248 - array( '1.13alpha', '<' ),
1249 - ),
1250 - 'wgEnableCascadingProtection' => array(
1251 - array( '1.10alpha', '>=' ),
1252 - array( '1.13alpha', '<' ),
1253 - ),
1254 - 'wgUsersNotifedOnAllChanges' => array(
1255 - array( '1.10alpha', '>=' ),
1256 - array( '1.13alpha', '<' ),
1257 - ),
1258 - 'wgFileRedirects' => array(
1259 - array( '1.12alpha', '>=' ),
1260 - array( '1.13alpha', '<' ),
1261 - ),
 1085+ 'wgAjaxSearch' => array( array( '1.14alpha', '<' ) ),
12621086 );
Index: trunk/extensions/Configure/README
@@ -17,14 +17,22 @@
1818
1919 == Configuration ==
2020
21 -The extension will require a directory to store the configuration and this
22 -directory have to be writable by the web server. The default path is the
23 -$IP/serialized directory, that means the "serialized" directory in the wiki
24 -root path. You can change it in $wgConfigureFilesPath. Don't forget to override
25 -this variable between the time you include the Configure.php file and the time
26 -you call efConfigureSetup(), otherwise your changes won't be used.
 21+The extension will require to store the configuration either:
 22+* a directory that have to be writable by the web server. The default path is
 23+ the $IP/serialized directory, that means the "serialized" directory in the
 24+ wiki root path. You can change it in $wgConfigureFilesPath.
 25+* a database in which the configure.sql patch is applied, by default the
 26+ database is "config", you can change its name in $wgConfigureDatabase. To use
 27+ this, you'll need to define all your database and memcached settings before
 28+ calling efConfigureSetup() or it simply won't work. Those settings will not be
 29+ editable in Special:Configure.
 30+You can select file storage or database storage by changing $wgConfigureHandler
 31+to "files" (default) to use files or "db" to use the database.
 32+Don't forget to override all that variables between the time you include the
 33+Configure.php file and the time you call efConfigureSetup(), otherwise your
 34+changes won't have any effect.
2735
28 -Note: on MediaWiki < 1.13 or a web server other than apache, the serialized
 36+Note for file storage: on a web server other than apache, the serialized
2937 directory is publicly viewable, and users will be able to see the whole
3038 configuration, so PLEASE MAKE IT UNREADABLE BY WEB USERS OR CHANGE IT TO A
3139 DIRECTORY THAT ISN'T ACCESSIBLE VIA THE WEB.
@@ -50,13 +58,18 @@
5159 you can do either:
5260 * use the manage.php command line script to revert the configuration to an
5361 older version
54 -* drop the conf-now.ser file you'll find in $wgConfigureFilesPath
55 - directory. Then it will fall back to the default configuration that is in
56 - LocalSettings.php. It's why it's important to keep that file.
 62+* directly update the configuration to fall back to the default configuration
 63+ that is in LocalSettings.php:
 64+** if you have file-based storage: drop the conf-now.ser file you'll find in
 65+ $wgConfigureFilesPath directory.
 66+** if you have database-based storage: set cv_is_latest field to 0 in the
 67+ config_version table for the versions you don't want to be "active".
 68+ Note: since data are cached, to might take a while before it produces any
 69+ effect.
5770
5871 == To do ==
5972
6073 * Some settings are still uneditable because of their array usage, this will
6174 need to develop some specific method to change them.
6275
63 -See http://www.mediawiki.org/wiki/Extension:Configure for more information.
 76+More information available at http://www.mediawiki.org/wiki/Extension:Configure.
Index: trunk/extensions/Configure/manage.inc
@@ -27,19 +27,20 @@
2828 }
2929 }
3030
 31+ protected function getDeleter(){
 32+ global $wgConf, $wgConfigureHandler;
 33+ $class = 'ConfigurationDeleter' . ucfirst( $wgConfigureHandler );
 34+ return new $class( $wgConf );
 35+ }
 36+
3137 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 );
 38+ $deleter = $this->getDeleter();
 39+ $deleter->doDelete( $version );
3940 }
4041
4142 protected function DoList(){
4243 global $wgConf;
43 - echo implode( "\n", $wgConf->listArchiveFiles() ) . "\n";
 44+ echo implode( "\n", $wgConf->listArchiveVersions() ) . "\n";
4445 }
4546
4647 protected function DoRevert( $version ){
@@ -65,4 +66,50 @@
6667 echo "--revert: revert the working config to the given version\n";
6768 echo "\n";
6869 }
 70+}
 71+
 72+/**
 73+ * Class used to delete configuration files
 74+ */
 75+class ConfigurationDeleterFiles {
 76+ protected $mConf;
 77+
 78+ function __construct( WebConfiguration $conf ){
 79+ $this->mConf = $conf;
 80+ }
 81+
 82+ function doDelete( $version ){
 83+ $file = $this->mConf->getHandler()->getArchiveFileName( $version );
 84+ if( !file_exists( $file ) ){
 85+ fwrite( STDERR, "delete: The version given ($version) does not exist.\n" );
 86+ return;
 87+ }
 88+ unlink( $file );
 89+ }
 90+}
 91+
 92+/**
 93+ * Class used to delete configuration stored in the database
 94+ */
 95+class ConfigurationDeleterDb {
 96+ protected $mConf;
 97+
 98+ function __construct( WebConfiguration $conf ){
 99+ $this->mConf = $conf;
 100+ }
 101+
 102+ function doDelete( $version ){
 103+ $dbw = $this->mConf->getHandler()->getMasterDB();
 104+ $rev = $dbw->selectRow( 'config_version', '*', array( 'cv_timestamp' => $version ), __METHOD__ );
 105+ if( !isset( $rev->cv_id ) ){
 106+ fwrite( STDERR, "delete: The version given ($version) does not exist.\n" );
 107+ return;
 108+ }
 109+
 110+ $id = $rev->cv_id;
 111+ $dbw->begin();
 112+ $dbw->delete( 'config_version', array( 'cv_id' => $id ), __METHOD__ );
 113+ $dbw->delete( 'config_setting', array( 'cs_id' => $id ), __METHOD__ );
 114+ $dbw->commit();
 115+ }
69116 }
\ No newline at end of file
Index: trunk/extensions/Configure/Configure.func.php
@@ -24,14 +24,7 @@
2525 if( isset( $wgGroupPermissions[$group] ) ){
2626 $html = '<err#>';
2727 } else {
28 - if( is_callable( array( 'User', 'getAllRights' ) ) ){ // 1.13 +
29 - $all = User::getAllRights();
30 - } else {
31 - $all = array();
32 - foreach( $wgGroupPermissions as $rights )
33 - $all = array_merge( $all, array_keys( $rights ) );
34 - $all = array_unique( $all );
35 - }
 28+ $all = User::getAllRights();
3629 $row = '<div style="-moz-column-count:2"><ul>';
3730 foreach( $all as $right ){
3831 $id = Sanitizer::escapeId( 'wpwgGroupPermissions-'.$group.'-'.$right );
@@ -80,40 +73,7 @@
8174 }
8275
8376 /**
84 - * Function that loads the messages in $wgMessageCache, it is used for backward
85 - * compatibility with 1.10 and older versions
86 - */
87 -function efConfigureLoadMessages(){
88 - if( function_exists( 'wfLoadExtensionMessages' ) ){
89 - wfLoadExtensionMessages( 'Configure' );
90 - } else {
91 - global $wgMessageCache;
92 - require( dirname( __FILE__ ) . '/Configure.i18n.php' );
93 - foreach( $messages as $lang => $messages ){
94 - $wgMessageCache->addMessages( $messages, $lang );
95 - }
96 - }
97 -}
98 -
99 -/**
100 - * Loads special pages aliases, for backward compatibility with < 1.13
101 - */
102 -function efConfigureLoadAliases( &$spAliases, $code ){
103 - require( dirname( __FILE__ ) . '/Configure.alias.php' );
104 - do {
105 - if( isset( $aliases[$code] ) ){
106 - foreach( $aliases[$code] as $can => $aliasArr ){
107 - foreach( $aliasArr as $alias )
108 - $spAliases[$can][] = str_replace( ' ', '_', $alias );
109 - }
110 - }
111 - } while( $code = Language::getFallbackFor( $code ) );
112 - return true;
113 -}
114 -
115 -/**
11677 * Add custom rights defined in $wgRestrictionLevels
117 - * Note that this only works on 1.13+
11878 */
11979 function efConfigureGetAllRights( &$rights ){
12080 global $wgRestrictionLevels;
Index: trunk/extensions/Configure/Configure.handler-db.php
@@ -0,0 +1,240 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+
 5+/**
 6+ * Class that hold the configuration
 7+ *
 8+ * @ingroup Extensions
 9+ */
 10+class ConfigureHandlerDb implements ConfigureHandler {
 11+ protected $mDb; // Database name
 12+
 13+ /**
 14+ * Construct a new object.
 15+ *
 16+ * @param string $path path to the directory that contains the configuration
 17+ * files
 18+ */
 19+ public function __construct(){
 20+ global $IP, $wgConfigureDatabase;
 21+ require_once( "$IP/includes/GlobalFunctions.php" );
 22+ require_once( "$IP/includes/ObjectCache.php" );
 23+ $this->mDb = $wgConfigureDatabase;
 24+ }
 25+
 26+ /**
 27+ * Get a slave DB connection, used for reads
 28+ * @return Database object
 29+ */
 30+ public function getSlaveDB() {
 31+ return wfGetDB( DB_SLAVE, 'config', $this->mDb );
 32+ }
 33+
 34+ /**
 35+ * Get a master DB connection, used for writes
 36+ * @return Database object
 37+ */
 38+ public function getMasterDB() {
 39+ return wfGetDB( DB_MASTER, 'config', $this->mDb );
 40+ }
 41+
 42+ /**
 43+ * Get cache key
 44+ */
 45+ protected function cacheKey( /* ... */ ){
 46+ $args = func_get_args();
 47+ $args = array_merge( wfSplitWikiID( $this->mDb ), $args );
 48+ return call_user_func_array( 'wfForeignMemcKey', $args );
 49+ }
 50+
 51+ /**
 52+ * Returns a cache object
 53+ */
 54+ protected function getCache() {
 55+ return wfGetMainCache();
 56+ }
 57+
 58+ /**
 59+ * Load the current configuration the database (i.e. cv_is_latest == 1)
 60+ * directory
 61+ */
 62+ public function getCurrent(){
 63+ $cacheKey = $this->cacheKey( 'configure', 'current' );
 64+ $cached = $this->getCache()->get( $cacheKey );
 65+ if( is_array( $cached ) ){
 66+ #var_dump( $cached ); die;
 67+ return $cached;
 68+ } else {
 69+ #var_dump( $this->getCache() ); die;
 70+ }
 71+
 72+ try {
 73+ $dbr = $this->getSlaveDB();
 74+ $ret = $dbr->select(
 75+ array( 'config_setting', 'config_version' ),
 76+ array( 'cs_name', 'cv_wiki', 'cs_value' ),
 77+ array( 'cv_is_latest' => 1 ),
 78+ __METHOD__,
 79+ array(),
 80+ array( 'config_version' => array( 'LEFT JOIN', 'cs_id = cv_id' ) )
 81+ );
 82+ $arr = array();
 83+ foreach( $ret as $row ){
 84+ $arr[$row->cv_wiki][$row->cs_name] = unserialize( $row->cs_value );
 85+ }
 86+ $this->getCache()->set( $cacheKey, $arr, 3600 );
 87+ return $arr;
 88+ } catch( MWException $e ) {
 89+ return array();
 90+ }
 91+ }
 92+
 93+ /**
 94+ * Return the old configuration from $ts
 95+ * Does *not* return site specific settings but *all* settings
 96+ *
 97+ * @param $ts timestamp
 98+ * @return array
 99+ */
 100+ public function getOldSettings( $ts ){
 101+ $db = $this->getSlaveDB();
 102+ $ret = $db->select(
 103+ array( 'config_setting', 'config_version' ),
 104+ array( 'cs_name', 'cv_wiki', 'cs_value' ),
 105+ array( 'cv_timestamp' => $ts ),
 106+ __METHOD__,
 107+ array(),
 108+ array( 'config_version' => array( 'LEFT JOIN', 'cs_id = cv_id' ) )
 109+ );
 110+ $arr = array();
 111+ foreach( $ret as $row ){
 112+ $arr[$row->cv_wiki][$row->cs_name] = unserialize( $row->cs_value );
 113+ }
 114+ return $arr;
 115+ }
 116+
 117+ /**
 118+ * Save a new configuration
 119+ * @param $settings array of settings
 120+ * @param $wiki String: wiki name or true for all
 121+ * @param $ts
 122+ * @return bool true on success
 123+ */
 124+ public function saveNewSettings( $settings, $wiki, $ts = false ){
 125+ if( $wiki === true ){
 126+ foreach( $settings as $name => $val ){
 127+ $this->saveSettingsForWiki( $val, $name, $ts );
 128+ }
 129+ } else {
 130+ if( !isset( $settings[$wiki] ) )
 131+ return false;
 132+ $this->saveSettingsForWiki( $settings[$wiki], $wiki, $ts );
 133+ }
 134+ $this->getCache()->delete( $this->cacheKey( 'configure', 'current' ) );
 135+ return true;
 136+ }
 137+
 138+ /**
 139+ * save the configuration for $wiki
 140+ */
 141+ protected function saveSettingsForWiki( $settings, $wiki, $ts ){
 142+ $dbw = $this->getMasterDB();
 143+ if( !$ts )
 144+ $ts = wfTimestampNow();
 145+ $dbw->begin();
 146+ $dbw->insert( 'config_version',
 147+ array(
 148+ 'cv_wiki' => $wiki,
 149+ 'cv_timestamp' => $ts,
 150+ 'cv_is_latest' => 1,
 151+ ),
 152+ __METHOD__
 153+ );
 154+ $newId = $dbw->insertId();
 155+ $dbw->update( 'config_version', array( 'cv_is_latest' => 0 ), array( 'cv_wiki' => $wiki, 'cv_timestamp <> '.$dbw->addQuotes( $ts ) ), __METHOD__ );
 156+ $insert = array();
 157+ foreach( $settings as $name => $val ){
 158+ $insert[] = array(
 159+ 'cs_id' => $newId,
 160+ 'cs_name' => $name,
 161+ 'cs_value' => serialize( $val ),
 162+ );
 163+ }
 164+ $dbw->insert( 'config_setting', $insert, __METHOD__ );
 165+ $dbw->commit();
 166+ return true;
 167+ }
 168+
 169+ /**
 170+ * List all archived versions
 171+ * @return array of timestamps
 172+ */
 173+ public function listArchiveVersions(){
 174+ $db = $this->getSlaveDB();
 175+ $ret = $db->select(
 176+ array( 'config_version' ),
 177+ array( 'cv_timestamp' ),
 178+ array(),
 179+ __METHOD__,
 180+ array( 'ORDER BY' => 'cv_timestamp DESC' )
 181+ );
 182+ $arr = array();
 183+ foreach( $ret as $row ){
 184+ $arr[] = $row->cv_timestamp;
 185+ }
 186+ return $arr;
 187+ }
 188+
 189+ /**
 190+ * Do some checks
 191+ */
 192+ public function doChecks(){
 193+ try {
 194+ $dbw = $this->getMasterDB();
 195+ } catch( MWException $e ) {
 196+ return array( 'configure-db-error', $this->mDb );
 197+ }
 198+ if( !$dbw->tableExists( 'config_version' ) )
 199+ return array( 'configure-db-table-error' );
 200+ return array();
 201+ }
 202+
 203+ /**
 204+ * Get settings that are not editable with the database handler
 205+ */
 206+ public function getNotEditableSettings(){
 207+ return array(
 208+ # Database
 209+ 'wgAllDBsAreLocalhost',
 210+ 'wgCheckDBSchema',
 211+ 'wgDBAvgStatusPoll',
 212+ 'wgDBerrorLog',
 213+ 'wgDBname',
 214+ 'wgDBpassword',
 215+ 'wgDBport',
 216+ 'wgDBserver',
 217+ 'wgDBtype',
 218+ 'wgDBuser',
 219+ 'wgLegacySchemaConversion',
 220+ 'wgSharedDB',
 221+ 'wgSharedPrefix',
 222+ 'wgSharedTables',
 223+ 'wgDBClusterTimeout',
 224+ 'wgDBservers',
 225+ 'wgLBFactoryConf',
 226+ 'wgMasterWaitTimeout',
 227+ 'wgDBmysql5',
 228+ 'wgDBprefix',
 229+ 'wgDBTableOptions',
 230+ 'wgDBtransactions',
 231+ 'wgDBmwschema',
 232+ 'wgDBts2schema',
 233+ 'wgSQLiteDataDir',
 234+ # Memcached
 235+ 'wgMainCacheType',
 236+ 'wgMemCachedDebug',
 237+ 'wgMemCachedPersistent',
 238+ 'wgMemCachedServers',
 239+ );
 240+ }
 241+}
Property changes on: trunk/extensions/Configure/Configure.handler-db.php
___________________________________________________________________
Name: svn:eol-style
1242 + native
Index: trunk/extensions/Configure/Configure.settings.php
@@ -177,6 +177,8 @@
178178 if( ( $this->types & CONF_SETTINGS_EXT ) == CONF_SETTINGS_EXT ){
179179 $ret += array(); // Nothing for extensions
180180 }
 181+ global $wgConf;
 182+ $ret = array_merge( $ret, $wgConf->getNotEditableSettings() );
181183 return $ret;
182184 }
183185
Index: trunk/extensions/Configure/Configure.php
@@ -3,7 +3,7 @@
44
55 /**
66 * Special page to allow users to configure the wiki by a web based interface
7 - * Require MediaWiki version 1.7.0 or greater
 7+ * Require MediaWiki version 1.13.0 or greater
88 *
99 * @file
1010 * @ingroup Extensions
@@ -17,18 +17,28 @@
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.8.12',
 21+ 'version' => '0.9.0',
2222 );
2323
2424 ## Configuration part
2525
2626 /**
27 - * Default path for the serialized files
 27+ * Configuration handler, either "files" or "db"
 28+ */
 29+$wgConfigureHandler = 'files';
 30+
 31+/**
 32+ * Default path for the serialized files, if $wgConfigureHandler is 'files'
2833 * Be sure that this directory is *not* accessible by the web
2934 */
3035 $wgConfigureFilesPath = "$IP/serialized";
3136
3237 /**
 38+ * Database used to store the configuration, if $wgConfigureHandler is 'db'
 39+ */
 40+$wgConfigureDatabase = 'config';
 41+
 42+/**
3343 * Allow foreign wiki configuration? either:
3444 * - true: allow any wiki
3545 * - false: don't allow any wiki
@@ -117,25 +127,19 @@
118128 require_once( $dir . 'Configure.func.php' );
119129
120130 ## Adding internationalisation...
121 -if( isset( $wgExtensionMessagesFiles ) && is_array( $wgExtensionMessagesFiles ) ){
122 - $wgExtensionMessagesFiles['Configure'] = $dir . 'Configure.i18n.php';
123 -} else {
124 - $wgHooks['LoadAllMessages'][] = 'efConfigureLoadMessages';
125 -}
 131+$wgExtensionMessagesFiles['Configure'] = $dir . 'Configure.i18n.php';
126132
127133 ## And special pages aliases...
128 -if( isset( $wgExtensionAliasesFiles ) && is_array( $wgExtensionAliasesFiles ) ){
129 - $wgExtensionAliasesFiles['Configure'] = $dir . 'Configure.alias.php';
130 -} else {
131 - # For 1.12 and 1.11
132 - $wgHooks['LanguageGetSpecialPageAliases'][] = 'efConfigureLoadAliases';
133 - # And for 1.10 and 1.9 :)
134 - $wgHooks['LangugeGetSpecialPageAliases'][] = 'efConfigureLoadAliases';
135 -}
 134+$wgExtensionAliasesFiles['Configure'] = $dir . 'Configure.alias.php';
136135
137136 ## Add custom rights defined in $wgRestrictionLevels
138137 $wgHooks['UserGetAllRights'][] = 'efConfigureGetAllRights';
139138
 139+## Handlers
 140+$wgAutoloadClasses['ConfigureHandler'] = $dir . 'Configure.handler.php';
 141+$wgAutoloadClasses['ConfigureHandlerFiles'] = $dir . 'Configure.handler-files.php';
 142+$wgAutoloadClasses['ConfigureHandlerDb'] = $dir . 'Configure.handler-db.php';
 143+
140144 ## Adding the new special pages...
141145 ## Common code
142146 $wgAutoloadClasses['ConfigurationPage'] = $dir . 'Configure.page.php';
@@ -165,11 +169,9 @@
166170 $wgAutoloadClasses['ConfigurationSettings'] = $dir . 'Configure.settings.php';
167171
168172 ## Groups
169 -if( isset( $wgSpecialPageGroups ) && is_array( $wgSpecialPageGroups ) ){
170 - $wgSpecialPageGroups['Configure'] = 'wiki';
171 - $wgSpecialPageGroups['Extensions'] = 'wiki';
172 - $wgSpecialPageGroups['ViewConfig'] = 'wiki';
173 -}
 173+$wgSpecialPageGroups['Configure'] = 'wiki';
 174+$wgSpecialPageGroups['Extensions'] = 'wiki';
 175+$wgSpecialPageGroups['ViewConfig'] = 'wiki';
174176
175177 ## Diff stuff
176178 $wgAutoloadClasses['ConfigurationDiff'] = $dir . 'Configure.diff.php';
@@ -178,10 +180,8 @@
179181 $wgAutoloadClasses['HistoryConfigurationDiff'] = $dir . 'Configure.diff.php';
180182
181183 ## API module
182 -if( version_compare( $wgVersion, '1.11alpha', '>=' ) ){
183 - $wgAutoloadClasses['ApiConfigure'] = $dir . 'Configure.api.php';
184 - $wgAPIModules['configure'] = 'ApiConfigure';
185 -}
 184+$wgAutoloadClasses['ApiConfigure'] = $dir . 'Configure.api.php';
 185+$wgAPIModules['configure'] = 'ApiConfigure';
186186
187187 ## Adding the ajax function
188188 $wgAjaxExportList[] = 'efConfigureAjax';
Index: trunk/extensions/Configure/migrateToDB.inc
@@ -0,0 +1,91 @@
 2+<?php
 3+
 4+/**
 5+ * Helper class for the migrateToDB.php script
 6+ *
 7+ * @ingroup Extensions
 8+ * @author Alexandre Emsenhuber
 9+ */
 10+class FilesToDB {
 11+ protected $mFilesHandler;
 12+ protected $mDBHandler;
 13+ protected $mOptions;
 14+ protected $mPreviousVersion = array();
 15+ protected $mLatest = array();
 16+
 17+ public function __construct( $options ){
 18+ $this->mOptions = $options;
 19+ $this->mFilesHandler = new ConfigureHandlerFiles();
 20+ $this->mDBHandler = new ConfigureHandlerDb();
 21+ }
 22+
 23+ public function run(){
 24+ if( isset( $this->mOptions['help'] ) ){
 25+ $this->doHelp();
 26+ return;
 27+ }
 28+ if( !$this->doChecks() )
 29+ return;
 30+ $this->saveLatest();
 31+ foreach( $this->getVersions() as $version ){
 32+ $this->migrateVersion( $version );
 33+ }
 34+ $this->restoreLatest();
 35+ echo "done\n";
 36+ }
 37+
 38+ protected function doChecks(){
 39+ $ret = $this->mDBHandler->doChecks();
 40+ if( count( $ret ) ){
 41+ fwrite( STDERR, "You have an error with your database, please check it and then run this script again.\n" );
 42+ return false;
 43+ } else {
 44+ return true;
 45+ }
 46+ }
 47+
 48+ protected function saveLatest(){
 49+ $db = $this->mDBHandler->getMasterDB();
 50+ $res = $db->select( 'config_version', array( 'cv_id', 'cv_wiki' ), array( 'cv_is_latest' => 1 ), __METHOD__ );
 51+ foreach( $res as $row ){
 52+ $this->mLatest[$row->cv_wiki] = $row->cv_id;
 53+ echo "{$row->cv_wiki}: {$row->cv_id}\n";
 54+ }
 55+ }
 56+
 57+ protected function restoreLatest(){
 58+ $dbw = $this->mDBHandler->getMasterDB();
 59+ foreach( $this->mLatest as $wiki => $id ){
 60+ $dbw->update( 'config_version', array( 'cv_is_latest' => 0 ), array( 'cv_wiki' => $wiki ), __METHOD__ );
 61+ $dbw->update( 'config_version', array( 'cv_is_latest' => 1 ), array( 'cv_id' => $id ), __METHOD__ );
 62+ }
 63+ }
 64+
 65+ protected function getVersions(){
 66+ return array_reverse( $this->mFilesHandler->listArchiveVersions() );
 67+ }
 68+
 69+ protected function migrateVersion( $version ){
 70+ $now = $this->mFilesHandler->getOldSettings( $version );
 71+ echo "doing $version...\n";
 72+ foreach( $now as $wiki => $settings ){
 73+ if( !isset( $this->mPreviousVersion[$wiki] ) || $this->mPreviousVersion[$wiki] != $settings ){
 74+ echo " $wiki...";
 75+ $this->mDBHandler->saveNewSettings( $now, $wiki, $version );
 76+ echo "ok\n";
 77+ }
 78+ }
 79+ $this->mPreviousVersion = $now;
 80+ }
 81+
 82+ protected function doHelp(){
 83+ echo "Maintenance script that migrate configuration from files to database.\n";
 84+ echo "\n";
 85+ echo "Usage:\n";
 86+ echo " php migrateToDB.php [--help]\n";
 87+ echo "\n";
 88+ echo "options:\n";
 89+ echo "--help: display this screen\n";
 90+ echo "\n";
 91+ }
 92+}
Property changes on: trunk/extensions/Configure/migrateToDB.inc
___________________________________________________________________
Name: svn:eol-style
193 + native
Index: trunk/extensions/Configure/Configure.diff.php
@@ -114,8 +114,7 @@
115115 */
116116 function getHTML(){
117117 global $wgOut;
118 - if( is_callable( array( $wgOut, 'addStyle' ) ) ) # 1.11 +
119 - $wgOut->addStyle( 'common/diff.css' );
 118+ $wgOut->addStyle( 'common/diff.css' );
120119 $old = $this->getOldVersion();
121120 $new = $this->getNewVersion();
122121 if( !( $wikis = $this->cleanWikis( $old, $new ) ) ){

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r32578* Introduced LBFactory -- an abstract class for configuring database load bal...tstarling09:48, 30 March 2008

Status & tagging log