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 |
1 | 42 | + native |
Index: trunk/extensions/Configure/Configure.api.php |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | if( in_array( 'versionlist', $params['prop'] ) ) { |
22 | 22 | if( !$wgUser->isAllowed( 'viewconfig' ) ) |
23 | 23 | $this->dieUsage( 'viewconfig right required', 'noright' ); |
24 | | - $versions = $wgConf->listArchiveFiles(); |
| 24 | + $versions = $wgConf->listArchiveVersions(); |
25 | 25 | if( $wgUser->isAllowed( 'viewconfig-interwiki' ) ) { |
26 | 26 | $oldVersions = $versions; |
27 | 27 | $versions = array(); |
— | — | @@ -213,13 +213,7 @@ |
214 | 214 | case 'group-bool': |
215 | 215 | $settingRet['values'] = array(); |
216 | 216 | $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(); |
224 | 218 | foreach( $settingVal as $group => $rights ){ |
225 | 219 | $arr = array( 'name' => $group, 'rights' => array() ); |
226 | 220 | $result->setIndexedTagName( $arr['rights'], 'permission' ); |
— | — | @@ -239,16 +233,13 @@ |
240 | 234 | $iter = array(); |
241 | 235 | foreach( $all as $group ) |
242 | 236 | $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'] ); |
248 | 238 | foreach( $iter as $group => $value ){ |
249 | 239 | $arr = array( 'name' => $group, 'values' => $value ); |
250 | 240 | $result->setIndexedTagName( $arr['values'], 'value' ); |
251 | 241 | $settingRet['values'][] = $arr; |
252 | 242 | } |
| 243 | + } |
253 | 244 | break; |
254 | 245 | default: |
255 | 246 | if( is_array( $type ) ){ |
Index: trunk/extensions/Configure/Configure.obj.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * @ingroup Extensions |
14 | 14 | */ |
15 | 15 | class WebConfiguration extends SiteConfiguration { |
16 | | - protected $mDir; // Directory of files, *with* leading / |
| 16 | + protected $mHandler; // Configuration handler |
17 | 17 | protected $mWiki; // Wiki name |
18 | 18 | protected $mConf = array(); // Our array of settings |
19 | 19 | protected $mOldSettings = array(); // Old settings (before applying our overrides) |
— | — | @@ -24,14 +24,10 @@ |
25 | 25 | * @param string $path path to the directory that contains the configuration |
26 | 26 | * files |
27 | 27 | */ |
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(); |
36 | 32 | $this->mWiki = $wiki; |
37 | 33 | } |
38 | 34 | |
— | — | @@ -41,20 +37,7 @@ |
42 | 38 | */ |
43 | 39 | public function initialise(){ |
44 | 40 | 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(); |
59 | 42 | $this->mOldSettings = $this->settings; |
60 | 43 | |
61 | 44 | # We'll need to invert the order of keys as SiteConfiguration uses |
— | — | @@ -154,20 +137,7 @@ |
155 | 138 | * @return array |
156 | 139 | */ |
157 | 140 | 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 ); |
172 | 142 | } |
173 | 143 | |
174 | 144 | /** |
— | — | @@ -231,69 +201,40 @@ |
232 | 202 | |
233 | 203 | if( $wiki === null ){ |
234 | 204 | $this->mConf = $settings; |
| 205 | + $wiki = true; |
235 | 206 | } else { |
236 | 207 | if( $wiki === false ) |
237 | | - $wiki = $this->mWiki; |
| 208 | + $wiki = $this->getWiki(); |
238 | 209 | $this->mConf[$wiki] = $settings; |
239 | 210 | } |
240 | 211 | |
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 ); |
246 | 213 | } |
247 | 214 | |
248 | 215 | /** |
249 | 216 | * List all archived files that are like conf-{$ts}.ser |
250 | 217 | * @return array of timestamps |
251 | 218 | */ |
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(); |
262 | 221 | } |
263 | 222 | |
264 | 223 | /** |
265 | | - * Get the current file name |
266 | | - * @return String full path to the file |
| 224 | + * Do some checks |
267 | 225 | */ |
268 | | - protected function getFileName(){ |
269 | | - return "{$this->mDir}conf-now.ser"; |
| 226 | + public function doChecks(){ |
| 227 | + return $this->mHandler->doChecks(); |
270 | 228 | } |
271 | 229 | |
272 | 230 | /** |
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 |
277 | 233 | */ |
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(); |
286 | 236 | } |
287 | 237 | |
288 | 238 | /** |
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 | | - /** |
298 | 239 | * Get the wiki in use |
299 | 240 | * |
300 | 241 | * @return String |
— | — | @@ -301,6 +242,14 @@ |
302 | 243 | public function getWiki(){ |
303 | 244 | return $this->mWiki; |
304 | 245 | } |
| 246 | + |
| 247 | + /** |
| 248 | + * Get the configuration handler |
| 249 | + * @return ConfigurationHandler |
| 250 | + */ |
| 251 | + public function getHandler(){ |
| 252 | + return $this->mHandler; |
| 253 | + } |
305 | 254 | |
306 | 255 | /** |
307 | 256 | * Merge array settings |
Index: trunk/extensions/Configure/Configure.page.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | * Constructor |
19 | 19 | */ |
20 | 20 | public function __construct( $name, $right ) { |
21 | | - efConfigureLoadMessages(); |
| 21 | + wfLoadExtensionMessages( 'Configure' ); |
22 | 22 | $this->mConfSettings = ConfigurationSettings::singleton( $this->getSettingMask() ); |
23 | 23 | parent::__construct( $name, $right ); |
24 | 24 | } |
— | — | @@ -41,37 +41,27 @@ |
42 | 42 | // Since efConfigureSetup() should be explicitely called, don't go |
43 | 43 | // further if that function wasn't called |
44 | 44 | 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' ); |
47 | 46 | return; |
48 | 47 | } |
49 | 48 | |
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 ); |
54 | 52 | return; |
55 | 53 | } |
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 | | - } |
63 | 54 | } |
64 | 55 | |
65 | 56 | $wikiParam = ( $this->mCanEdit && $wgRequest->wasPosted() ) ? 'wpWiki' : 'wiki'; |
66 | 57 | if( $wiki = $wgRequest->getVal( $wikiParam, false ) ){ |
67 | 58 | if( $wgConf->getWiki() != $wiki ){ |
68 | 59 | 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' ); |
71 | 61 | return; |
72 | 62 | } |
73 | 63 | 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 ) ) ); |
76 | 66 | return; |
77 | 67 | } |
78 | 68 | } |
— | — | @@ -96,7 +86,7 @@ |
97 | 87 | $type = 'diff'; |
98 | 88 | } |
99 | 89 | } else { |
100 | | - $wgOut->addWikiText( wfMsgNoTrans( 'sessionfailure' ) ); |
| 90 | + $wgOut->addWikiMsg( 'sessionfailure' ); |
101 | 91 | $type = 'diff'; |
102 | 92 | } |
103 | 93 | } else { |
— | — | @@ -296,13 +286,12 @@ |
297 | 287 | global $wgConf, $wgOut, $wgRequest; |
298 | 288 | |
299 | 289 | if( $version = $wgRequest->getVal( 'version' ) ){ |
300 | | - $versions = $wgConf->listArchiveFiles(); |
| 290 | + $versions = $wgConf->listArchiveVersions(); |
301 | 291 | if( in_array( $version, $versions ) ){ |
302 | 292 | $conf = $wgConf->getOldSettings( $version ); |
303 | 293 | $this->conf = $conf[$this->mWiki]; |
304 | 294 | 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 ) ); |
307 | 296 | return false; |
308 | 297 | } |
309 | 298 | $current = null; |
— | — | @@ -313,10 +302,9 @@ |
314 | 303 | $this->conf[$name] += $current[$name]; |
315 | 304 | } |
316 | 305 | } |
317 | | - $wgOut->addWikiText( wfMsgNoTrans( 'configure-edit-old' ) ); |
| 306 | + $wgOut->addWikiMsg( 'configure-edit-old' ); |
318 | 307 | } 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 ) ); |
321 | 309 | return false; |
322 | 310 | } |
323 | 311 | } else { |
— | — | @@ -330,7 +318,7 @@ |
331 | 319 | */ |
332 | 320 | protected function buildOldVersionSelect(){ |
333 | 321 | global $wgConf, $wgLang, $wgUser; |
334 | | - $versions = $wgConf->listArchiveFiles(); |
| 322 | + $versions = $wgConf->listArchiveVersions(); |
335 | 323 | $text = '<fieldset><legend>' . wfMsgHtml( 'configure-old' ) . '</legend>'; |
336 | 324 | if( empty( $versions ) ){ |
337 | 325 | $text .= wfMsgExt( 'configure-no-old', array( 'parse' ) ); |
— | — | @@ -341,9 +329,7 @@ |
342 | 330 | $title = $this->getTitle(); |
343 | 331 | if( count( $versions ) > 10 ){ |
344 | 332 | $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' ); |
348 | 334 | $moreLink = $skin->makeKnownLinkObj( $link, wfMsgHtml( 'configure-view-all-versions' ) ); |
349 | 335 | } else { |
350 | 336 | $moreLink = ''; |
— | — | @@ -488,18 +474,9 @@ |
489 | 475 | $iter = array_keys( $this->getSettingValue( 'wgGroupPermissions' ) ); |
490 | 476 | } |
491 | 477 | 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(); |
499 | 479 | } 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' ) ); |
504 | 481 | } |
505 | 482 | foreach( $iter as $group ){ |
506 | 483 | foreach( $all as $right ){ |
— | — | @@ -674,7 +651,7 @@ |
675 | 652 | protected function injectScriptsAndStyles() { |
676 | 653 | global $wgOut, $wgScriptPath, $wgUseAjax, $wgJsMimeType, $wgConfigureStyleVersion; |
677 | 654 | $href = "{$wgScriptPath}/extensions/Configure/Configure.css?{$wgConfigureStyleVersion}"; |
678 | | - if( is_callable( array( $wgOut, 'addExtensionStyle' ) ) ){ |
| 655 | + if( is_callable( array( $wgOut, 'addExtensionStyle' ) ) ){ # 1.14+ |
679 | 656 | $wgOut->addExtensionStyle( $href ); |
680 | 657 | } else { |
681 | 658 | $wgOut->addLink( |
— | — | @@ -685,19 +662,11 @@ |
686 | 663 | ) |
687 | 664 | ); |
688 | 665 | } |
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' ) ); |
702 | 671 | $ajax = isset( $wgUseAjax ) && $wgUseAjax ? 'true' : 'false'; |
703 | 672 | $script = array( |
704 | 673 | "<script type=\"$wgJsMimeType\">/*<![CDATA[*/", |
— | — | @@ -760,7 +729,6 @@ |
761 | 730 | return $this->buildArrayInput( $conf, $default, $allowed ); |
762 | 731 | } |
763 | 732 | if( $type == 'lang' ){ |
764 | | - // Code taken from Xml.php, Xml::LanguageSelector only available since 1.11 and Xml::option since 1.8 |
765 | 733 | $languages = Language::getLanguageNames( true ); |
766 | 734 | |
767 | 735 | if( $allowed ){ |
— | — | @@ -961,23 +929,14 @@ |
962 | 930 | $all = array(); |
963 | 931 | $attr = ( !$allowed ) ? array( 'disabled' => 'disabled' ) : array(); |
964 | 932 | 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(); |
972 | 934 | $iter = $default; |
973 | 935 | } else { |
974 | 936 | $all = array_keys( $this->getSettingValue( 'wgGroupPermissions' ) ); |
975 | 937 | $iter = array(); |
976 | 938 | foreach( $all as $group ) |
977 | 939 | $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' ) ); |
982 | 941 | } |
983 | 942 | $groupdesc = wfMsgHtml( 'configure-desc-group' ); |
984 | 943 | $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 |
1 | 162 | + 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 |
1 | 57 | + native |
Index: trunk/extensions/Configure/Configure.i18n.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | |
12 | 12 | $messages['en'] = array( |
13 | 13 | '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', |
15 | 15 | 'configure-desc-group' => 'Groups', |
16 | 16 | 'configure-desc-key' => 'Key', |
17 | 17 | 'configure-desc-ns' => 'Namespaces', |
— | — | @@ -27,6 +27,9 @@ |
28 | 28 | |
29 | 29 | '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.', |
30 | 30 | '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.', |
31 | 34 | 'configure-directory-not-writable' => 'The directory used to store the settings, <tt>$1</tt>, is not writable. |
32 | 35 | Please make it writable by PHP to use this extension.', |
33 | 36 | '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 |
1 | 23 | + native |
Index: trunk/extensions/Configure/SpecialViewConfig.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $this->isWebConfig = $wgConf instanceof WebConfiguration; |
31 | 31 | |
32 | 32 | if( $this->isWebConfig && $version = $wgRequest->getVal( 'version' ) ){ |
33 | | - $versions = $wgConf->listArchiveFiles(); |
| 33 | + $versions = $wgConf->listArchiveVersions(); |
34 | 34 | if( in_array( $version, $versions ) ){ |
35 | 35 | $conf = $wgConf->getOldSettings( $version ); |
36 | 36 | if( $this->isUserAllowedAll() ){ |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | if( !$this->isWebConfig ) |
120 | 120 | return ''; |
121 | 121 | |
122 | | - $versions = $wgConf->listArchiveFiles(); |
| 122 | + $versions = $wgConf->listArchiveVersions(); |
123 | 123 | if( empty( $versions ) ){ |
124 | 124 | return wfMsgExt( 'configure-no-old', array( 'parse' ) ); |
125 | 125 | } |
— | — | @@ -135,14 +135,10 @@ |
136 | 136 | $allowedExtensionsAll = $wgUser->isAllowed( 'extensions-interwiki' ); |
137 | 137 | |
138 | 138 | 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' ); |
142 | 140 | |
143 | 141 | 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' ); |
147 | 143 | |
148 | 144 | $text = wfMsgExt( 'configure-old-versions', array( 'parse' ) ); |
149 | 145 | if( $showDiff ) |
Index: trunk/extensions/Configure/Configure.settings-core.php |
— | — | @@ -70,7 +70,6 @@ |
71 | 71 | 'wgSharedTables' => 'array', |
72 | 72 | ), |
73 | 73 | 'load-balancing' => array( |
74 | | - 'wgAlternateMaster' => 'array', |
75 | 74 | 'wgDBClusterTimeout' => 'int', |
76 | 75 | 'wgDBservers' => 'array', |
77 | 76 | 'wgDefaultExternalStore' => 'array', |
— | — | @@ -116,7 +115,6 @@ |
117 | 116 | 'wgEnotifUseJobQ' => 'bool', |
118 | 117 | 'wgEnotifUserTalk' => 'bool', |
119 | 118 | 'wgEnotifWatchlist' => 'bool', |
120 | | - 'wgUsersNotifedOnAllChanges' => 'array', |
121 | 119 | 'wgUsersNotifiedOnAllChanges' => 'array', |
122 | 120 | ), |
123 | 121 | ), |
— | — | @@ -177,10 +175,7 @@ |
178 | 176 | 'wgProfileLimit' => 'int', |
179 | 177 | 'wgProfileOnly' => 'bool', |
180 | 178 | 'wgProfilePerHost' => 'bool', |
181 | | - 'wgProfileSampleRate' => 'int', |
182 | 179 | 'wgProfileToDatabase' => 'bool', |
183 | | - 'wgProfilerType' => 'text', |
184 | | - 'wgProfiling' => 'bool', |
185 | 180 | 'wgUDPProfilerHost' => 'text', |
186 | 181 | 'wgUDPProfilerPort' => 'int', |
187 | 182 | ), |
— | — | @@ -285,8 +280,6 @@ |
286 | 281 | 'wgTranscludeCacheExpiry' => 'int', |
287 | 282 | 'wgUseFileCache' => 'bool', |
288 | 283 | 'wgUseGzip' => 'bool', |
289 | | - 'wgUseWatchlistCache' => 'bool', |
290 | | - 'wgWLCacheTimeout' => 'int', |
291 | 284 | ), |
292 | 285 | 'pcache' => array( |
293 | 286 | 'wgParserCacheType' => array( -1 => 'Anything', 0 => 'None', |
— | — | @@ -304,13 +297,11 @@ |
305 | 298 | 3 => 'Accel', 4 => 'DBA' ), |
306 | 299 | 'wgLocalMessageCache' => 'text', |
307 | 300 | 'wgMsgCacheExpiry' => 'int', |
308 | | - 'wgCachedMessageArrays' => 'text', |
309 | 301 | 'wgCheckSerialized' => 'bool', |
310 | 302 | 'wgLocalMessageCacheSerialized' => 'bool', |
311 | 303 | 'wgMaxMsgCacheEntrySize' => 'int', |
312 | 304 | ), |
313 | 305 | 'memcached' => array( |
314 | | - 'wgLinkCacheMemcached' => 'bool', |
315 | 306 | 'wgMemCachedDebug' => 'bool', |
316 | 307 | 'wgMemCachedPersistent' => 'bool', |
317 | 308 | 'wgMemCachedServers' => 'array', |
— | — | @@ -340,7 +331,6 @@ |
341 | 332 | 'wgDeleteRevisionsLimit' => 'int', |
342 | 333 | 'wgDisabledActions' => 'array', |
343 | 334 | 'wgEmailConfirmToEdit' => 'bool', |
344 | | - 'wgEnableCascadingProtection' => 'bool', |
345 | 335 | 'wgEnableAPI' => 'bool', |
346 | 336 | 'wgEnableWriteAPI' => 'bool', |
347 | 337 | 'wgFilterCallback' => 'text', |
— | — | @@ -448,7 +438,6 @@ |
449 | 439 | 'wgMaxUploadSize' => 'int', |
450 | 440 | 'wgHTTPTimeout' => 'int', |
451 | 441 | 'wgHTTPProxy' => 'text', |
452 | | - 'wgSaveDeletedFiles' => 'bool', |
453 | 442 | ), |
454 | 443 | 'sharedupload' => array( |
455 | 444 | 'wgCacheSharedUploads' => 'bool', |
— | — | @@ -478,7 +467,6 @@ |
479 | 468 | 'images' => array( |
480 | 469 | 'wgAllowImageMoving' => 'bool', |
481 | 470 | 'wgCustomConvertCommand' => 'text', |
482 | | - 'wgFileRedirects' => 'bool', |
483 | 471 | 'wgGenerateThumbnailOnParse' => 'bool', |
484 | 472 | 'wgIgnoreImageErrors' => 'bool', |
485 | 473 | 'wgImageLimits' => 'array', |
— | — | @@ -488,7 +476,6 @@ |
489 | 477 | 'wgThumbnailScriptPath' => 'text', |
490 | 478 | 'wgThumbUpright' => 'text', |
491 | 479 | 'wgShowEXIF' => 'bool', |
492 | | - 'wgUseImageResize' => 'bool', |
493 | 480 | 'wgThumbLimits' => 'array', |
494 | 481 | 'wgTrustedMediaFormats' => 'array', |
495 | 482 | ), |
— | — | @@ -537,11 +524,9 @@ |
538 | 525 | 'wgParserCacheExpireTime' => 'int', |
539 | 526 | 'wgParserTestFiles' => 'array', |
540 | 527 | 'wgRestrictDisplayTitle' => 'bool', |
541 | | - 'wgUseXMLparser' => 'bool', |
542 | 528 | ), |
543 | 529 | 'html' => array( |
544 | 530 | 'wgRawHtml' => 'bool', |
545 | | - 'wgUserHtml' => 'bool', |
546 | 531 | ), |
547 | 532 | 'tex' => array( |
548 | 533 | 'wgTexvc' => 'text', |
— | — | @@ -727,7 +712,6 @@ |
728 | 713 | $arrayDefs = array( |
729 | 714 | 'wgActionPaths' => 'assoc', |
730 | 715 | # Db |
731 | | - 'wgAlternateMaster' => 'assoc', |
732 | 716 | 'wgDBservers' => 'array', |
733 | 717 | 'wgDefaultExternalStore' => 'simple', |
734 | 718 | 'wgLocalDatabases' => 'simple', |
— | — | @@ -736,7 +720,6 @@ |
737 | 721 | 'wgSharedTables' => 'simple', |
738 | 722 | # Email |
739 | 723 | 'wgSMTP' => 'assoc', |
740 | | - 'wgUsersNotifedOnAllChanges' => 'simple', |
741 | 724 | 'wgUsersNotifiedOnAllChanges' => 'simple', |
742 | 725 | # Localization |
743 | 726 | 'wgForceUIMsgAsContentMsg' => 'simple', |
— | — | @@ -923,7 +906,6 @@ |
924 | 907 | 'wgVariantArticlePath', |
925 | 908 | # Db |
926 | 909 | 'wgAllDBsAreLocalhost', |
927 | | - 'wgAlternateMaster', |
928 | 910 | 'wgCheckDBSchema', |
929 | 911 | 'wgDBAvgStatusPoll', |
930 | 912 | 'wgDBClusterTimeout', |
— | — | @@ -1071,132 +1053,6 @@ |
1072 | 1054 | * Array of settings depending of the Core version |
1073 | 1055 | */ |
1074 | 1056 | $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', '>=' ) ), |
1201 | 1057 | # 1.14 |
1202 | 1058 | 'wgExemptFromUserRobotsControl' => array( array( '1.14alpha', '>=' ) ), |
1203 | 1059 | 'wgHandheldStyle' => array( array( '1.14alpha', '>=' ) ), |
— | — | @@ -1225,37 +1081,5 @@ |
1226 | 1082 | 'wgFilterLogTypes' => array( array( '1.14alpha', '>=' ) ), |
1227 | 1083 | 'wgRC2UDPInterwikiPrefix' => array( array( '1.14alpha', '>=' ) ), |
1228 | 1084 | ## 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', '<' ) ), |
1262 | 1086 | ); |
Index: trunk/extensions/Configure/README |
— | — | @@ -17,14 +17,22 @@ |
18 | 18 | |
19 | 19 | == Configuration == |
20 | 20 | |
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. |
27 | 35 | |
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 |
29 | 37 | directory is publicly viewable, and users will be able to see the whole |
30 | 38 | configuration, so PLEASE MAKE IT UNREADABLE BY WEB USERS OR CHANGE IT TO A |
31 | 39 | DIRECTORY THAT ISN'T ACCESSIBLE VIA THE WEB. |
— | — | @@ -50,13 +58,18 @@ |
51 | 59 | you can do either: |
52 | 60 | * use the manage.php command line script to revert the configuration to an |
53 | 61 | 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. |
57 | 70 | |
58 | 71 | == To do == |
59 | 72 | |
60 | 73 | * Some settings are still uneditable because of their array usage, this will |
61 | 74 | need to develop some specific method to change them. |
62 | 75 | |
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 @@ |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
| 31 | + protected function getDeleter(){ |
| 32 | + global $wgConf, $wgConfigureHandler; |
| 33 | + $class = 'ConfigurationDeleter' . ucfirst( $wgConfigureHandler ); |
| 34 | + return new $class( $wgConf ); |
| 35 | + } |
| 36 | + |
31 | 37 | 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 ); |
39 | 40 | } |
40 | 41 | |
41 | 42 | protected function DoList(){ |
42 | 43 | global $wgConf; |
43 | | - echo implode( "\n", $wgConf->listArchiveFiles() ) . "\n"; |
| 44 | + echo implode( "\n", $wgConf->listArchiveVersions() ) . "\n"; |
44 | 45 | } |
45 | 46 | |
46 | 47 | protected function DoRevert( $version ){ |
— | — | @@ -65,4 +66,50 @@ |
66 | 67 | echo "--revert: revert the working config to the given version\n"; |
67 | 68 | echo "\n"; |
68 | 69 | } |
| 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 | + } |
69 | 116 | } |
\ No newline at end of file |
Index: trunk/extensions/Configure/Configure.func.php |
— | — | @@ -24,14 +24,7 @@ |
25 | 25 | if( isset( $wgGroupPermissions[$group] ) ){ |
26 | 26 | $html = '<err#>'; |
27 | 27 | } 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(); |
36 | 29 | $row = '<div style="-moz-column-count:2"><ul>'; |
37 | 30 | foreach( $all as $right ){ |
38 | 31 | $id = Sanitizer::escapeId( 'wpwgGroupPermissions-'.$group.'-'.$right ); |
— | — | @@ -80,40 +73,7 @@ |
81 | 74 | } |
82 | 75 | |
83 | 76 | /** |
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 | | -/** |
116 | 77 | * Add custom rights defined in $wgRestrictionLevels |
117 | | - * Note that this only works on 1.13+ |
118 | 78 | */ |
119 | 79 | function efConfigureGetAllRights( &$rights ){ |
120 | 80 | 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 |
1 | 242 | + native |
Index: trunk/extensions/Configure/Configure.settings.php |
— | — | @@ -177,6 +177,8 @@ |
178 | 178 | if( ( $this->types & CONF_SETTINGS_EXT ) == CONF_SETTINGS_EXT ){ |
179 | 179 | $ret += array(); // Nothing for extensions |
180 | 180 | } |
| 181 | + global $wgConf; |
| 182 | + $ret = array_merge( $ret, $wgConf->getNotEditableSettings() ); |
181 | 183 | return $ret; |
182 | 184 | } |
183 | 185 | |
Index: trunk/extensions/Configure/Configure.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | |
5 | 5 | /** |
6 | 6 | * 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 |
8 | 8 | * |
9 | 9 | * @file |
10 | 10 | * @ingroup Extensions |
— | — | @@ -17,18 +17,28 @@ |
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.8.12', |
| 21 | + 'version' => '0.9.0', |
22 | 22 | ); |
23 | 23 | |
24 | 24 | ## Configuration part |
25 | 25 | |
26 | 26 | /** |
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' |
28 | 33 | * Be sure that this directory is *not* accessible by the web |
29 | 34 | */ |
30 | 35 | $wgConfigureFilesPath = "$IP/serialized"; |
31 | 36 | |
32 | 37 | /** |
| 38 | + * Database used to store the configuration, if $wgConfigureHandler is 'db' |
| 39 | + */ |
| 40 | +$wgConfigureDatabase = 'config'; |
| 41 | + |
| 42 | +/** |
33 | 43 | * Allow foreign wiki configuration? either: |
34 | 44 | * - true: allow any wiki |
35 | 45 | * - false: don't allow any wiki |
— | — | @@ -117,25 +127,19 @@ |
118 | 128 | require_once( $dir . 'Configure.func.php' ); |
119 | 129 | |
120 | 130 | ## 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'; |
126 | 132 | |
127 | 133 | ## 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'; |
136 | 135 | |
137 | 136 | ## Add custom rights defined in $wgRestrictionLevels |
138 | 137 | $wgHooks['UserGetAllRights'][] = 'efConfigureGetAllRights'; |
139 | 138 | |
| 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 | + |
140 | 144 | ## Adding the new special pages... |
141 | 145 | ## Common code |
142 | 146 | $wgAutoloadClasses['ConfigurationPage'] = $dir . 'Configure.page.php'; |
— | — | @@ -165,11 +169,9 @@ |
166 | 170 | $wgAutoloadClasses['ConfigurationSettings'] = $dir . 'Configure.settings.php'; |
167 | 171 | |
168 | 172 | ## 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'; |
174 | 176 | |
175 | 177 | ## Diff stuff |
176 | 178 | $wgAutoloadClasses['ConfigurationDiff'] = $dir . 'Configure.diff.php'; |
— | — | @@ -178,10 +180,8 @@ |
179 | 181 | $wgAutoloadClasses['HistoryConfigurationDiff'] = $dir . 'Configure.diff.php'; |
180 | 182 | |
181 | 183 | ## 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'; |
186 | 186 | |
187 | 187 | ## Adding the ajax function |
188 | 188 | $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 |
1 | 93 | + native |
Index: trunk/extensions/Configure/Configure.diff.php |
— | — | @@ -114,8 +114,7 @@ |
115 | 115 | */ |
116 | 116 | function getHTML(){ |
117 | 117 | global $wgOut; |
118 | | - if( is_callable( array( $wgOut, 'addStyle' ) ) ) # 1.11 + |
119 | | - $wgOut->addStyle( 'common/diff.css' ); |
| 118 | + $wgOut->addStyle( 'common/diff.css' ); |
120 | 119 | $old = $this->getOldVersion(); |
121 | 120 | $new = $this->getNewVersion(); |
122 | 121 | if( !( $wikis = $this->cleanWikis( $old, $new ) ) ){ |