Index: branches/maintenance-work/AdminSettings.sample |
— | — | @@ -1,32 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * This file should be copied to AdminSettings.php, and modified |
5 | | - * to reflect local settings. It is required for the maintenance |
6 | | - * scripts which run on the command line, as an extra security |
7 | | - * measure to allow using a separate user account with higher |
8 | | - * privileges to do maintenance work. |
9 | | - * |
10 | | - * Developers: Do not check AdminSettings.php into Subversion |
11 | | - */ |
12 | | - |
13 | | -/* |
14 | | - * This data is used by all database maintenance scripts |
15 | | - * (see directory maintenance/). The SQL user MUST BE |
16 | | - * MANUALLY CREATED or set to an existing user with |
17 | | - * necessary permissions. |
18 | | - * |
19 | | - * This is not to be confused with sysop accounts for the |
20 | | - * wiki. |
21 | | - * |
22 | | - * NOTE: for PostgreSQL this should be set to the same user and |
23 | | - * password as the web user, that is, the same as $wgDBuser and |
24 | | - * $wgDBpassword in LocalSettings.php. This is necessary to |
25 | | - * ensure that the owner for new tables is set correctly. |
26 | | - */ |
27 | | -$wgDBadminuser = 'wikiadmin'; |
28 | | -$wgDBadminpassword = 'adminpass'; |
29 | | - |
30 | | -/* |
31 | | - * Whether to enable the profileinfo.php script. |
32 | | - */ |
33 | | -$wgEnableProfileInfo = false; |
Index: branches/maintenance-work/maintenance/README |
— | — | @@ -10,8 +10,8 @@ |
11 | 11 | |
12 | 12 | Certain scripts will require elevated access to the database. In order to |
13 | 13 | provide this, first create a MySQL user with "all" permissions on the wiki |
14 | | -database, and then place their username and password in an AdminSettings.php |
15 | | -file in the directory above. See AdminSettings.sample for specifics on this. |
| 14 | +database, and then set $wgDBadminuser and $wgDBadminpassword in your |
| 15 | +LocalSettings.php |
16 | 16 | |
17 | 17 | === Brief explanation of files === |
18 | 18 | |
Index: branches/maintenance-work/maintenance/Doxyfile |
— | — | @@ -135,7 +135,7 @@ |
136 | 136 | RECURSIVE = YES |
137 | 137 | EXCLUDE = |
138 | 138 | EXCLUDE_SYMLINKS = YES |
139 | | -EXCLUDE_PATTERNS = LocalSettings.php AdminSettings.php |
| 139 | +EXCLUDE_PATTERNS = LocalSettings.php |
140 | 140 | EXAMPLE_PATH = |
141 | 141 | EXAMPLE_PATTERNS = * |
142 | 142 | EXAMPLE_RECURSIVE = NO |
Index: branches/maintenance-work/maintenance/Maintenance.php |
— | — | @@ -83,10 +83,9 @@ |
84 | 84 | *
|
85 | 85 | * @param $name String The name of the param (help, version, etc)
|
86 | 86 | * @param $description String The description of the param to show on --help
|
87 | | - * @param $isFlag boolean Whether the param is a flag (like --help) or needs
|
88 | | - * a value (like --dbuser=someuser)
|
| 87 | + * @param $required boolean Is the param required?
|
89 | 88 | */
|
90 | | - protected function addParam( $name, $description, $isFlag = false, $required = true ) {
|
| 89 | + protected function addParam( $name, $description, $required = false ) {
|
91 | 90 | $this->mParams[ $name ] = array( 'desc' => $description, 'require' => $required );
|
92 | 91 | }
|
93 | 92 |
|
— | — | @@ -142,10 +141,9 @@ |
143 | 142 | * Add the default parameters to the scripts
|
144 | 143 | */
|
145 | 144 | private function addDefaultParams() {
|
146 | | - $this->addParam( 'help', "Display this help message", true );
|
147 | | - $this->addParam( 'quiet', "Whether to supress non-error output", true );
|
| 145 | + $this->addParam( 'help', "Display this help message" );
|
| 146 | + $this->addParam( 'quiet', "Whether to supress non-error output" );
|
148 | 147 | $this->addParam( 'conf', "Location of LocalSettings.php, if not default" );
|
149 | | - $this->addParam( 'aconf', "Same, but for AdminSettings.php" );
|
150 | 148 | $this->addParam( 'wiki', "For specifying the wiki ID" );
|
151 | 149 | if( $this->needsDB() ) {
|
152 | 150 | $this->addParam( 'dbuser', "The DB user to use for this script" );
|
— | — | @@ -304,8 +302,6 @@ |
305 | 303 | $this->mOptions = $options;
|
306 | 304 | $this->mArgs = $args;
|
307 | 305 | }
|
308 | | -
|
309 | | - private function validateParam(
|
310 | 306 |
|
311 | 307 | /**
|
312 | 308 | * Maybe show the help.
|
— | — | @@ -328,8 +324,9 @@ |
329 | 325 | * Handle some last-minute setup here.
|
330 | 326 | */
|
331 | 327 | private function finalSetup() {
|
332 | | - global $wgCommandLineMode, $wgUseNormalUser, $wgShowSQLErrors, $wgTitle, $wgProfiling, $IP;
|
333 | | - global $wgDBadminuser, $wgDBadminpassword, $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
|
| 328 | + global $wgCommandLineMode, $wgUseNormalUser, $wgShowSQLErrors;
|
| 329 | + global $wgTitle, $wgProfiling, $IP, $wgDBadminuser, $wgDBadminpassword;
|
| 330 | + global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
|
334 | 331 |
|
335 | 332 | # Turn off output buffering again, it might have been turned on in the settings files
|
336 | 333 | if( ob_get_level() ) {
|
— | — | @@ -337,7 +334,13 @@ |
338 | 335 | }
|
339 | 336 | # Same with these
|
340 | 337 | $wgCommandLineMode = true;
|
341 | | -
|
| 338 | +
|
| 339 | + # If these were passed, use them
|
| 340 | + if( $this->mDbUser )
|
| 341 | + $wgDBadminuser = $this->mDbUser;
|
| 342 | + if( $this->mDbPass )
|
| 343 | + $wgDBadminpass = $this->mDbPass;
|
| 344 | +
|
342 | 345 | if ( empty( $wgUseNormalUser ) && isset( $wgDBadminuser ) ) {
|
343 | 346 | $wgDBuser = $wgDBadminuser;
|
344 | 347 | $wgDBpassword = $wgDBadminpassword;
|
— | — | @@ -370,7 +373,90 @@ |
371 | 374 | }
|
372 | 375 |
|
373 | 376 | private function loadWikimediaSettings() {
|
| 377 | + global $wgWikiFarm, $cluster, $IP, $wgNoDBParam, $wgUseNormalUser;
|
| 378 | +
|
| 379 | + $wgWikiFarm = true;
|
| 380 | + $cluster = 'pmtpa';
|
| 381 | + require_once( "$IP/includes/AutoLoader.php" );
|
| 382 | + require_once( "$IP/includes/SiteConfiguration.php" );
|
| 383 | +
|
| 384 | + # Get $wgConf
|
| 385 | + require( "$IP/wgConf.php" );
|
| 386 | +
|
| 387 | + if ( empty( $wgNoDBParam ) ) {
|
| 388 | + # Check if we were passed a db name
|
| 389 | + if ( isset( $this->mOptions['wiki'] ) ) {
|
| 390 | + $db = $this->mOptions['wiki'];
|
| 391 | + } else {
|
| 392 | + $db = array_shift( $this->mArgs );
|
| 393 | + }
|
| 394 | + list( $site, $lang ) = $wgConf->siteFromDB( $db );
|
| 395 | +
|
| 396 | + # If not, work out the language and site the old way
|
| 397 | + if ( is_null( $site ) || is_null( $lang ) ) {
|
| 398 | + if ( !$db ) {
|
| 399 | + $lang = 'aa';
|
| 400 | + } else {
|
| 401 | + $lang = $db;
|
| 402 | + }
|
| 403 | + if ( isset( $this->mArgs[0] ) ) {
|
| 404 | + $site = array_shift( $this->mArgs );
|
| 405 | + } else {
|
| 406 | + $site = 'wikipedia';
|
| 407 | + }
|
| 408 | + }
|
| 409 | + } else {
|
| 410 | + $lang = 'aa';
|
| 411 | + $site = 'wikipedia';
|
| 412 | + }
|
| 413 | +
|
| 414 | + # This is for the IRC scripts, which now run as the apache user
|
| 415 | + # The apache user doesn't have access to the wikiadmin_pass command
|
| 416 | + if ( $_ENV['USER'] == 'apache' ) {
|
| 417 | + #if ( posix_geteuid() == 48 ) {
|
| 418 | + $wgUseNormalUser = true;
|
| 419 | + }
|
| 420 | +
|
| 421 | + putenv( 'wikilang='.$lang);
|
| 422 | +
|
| 423 | + $DP = $IP;
|
| 424 | + ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" );
|
| 425 | +
|
| 426 | + if ( $lang == 'test' && $site == 'wikipedia' ) {
|
| 427 | + define( 'TESTWIKI', 1 );
|
| 428 | + }
|
| 429 | +
|
| 430 | + #require_once( $IP.'/includes/ProfilerStub.php' );
|
| 431 | + require( $IP.'/includes/Defines.php' );
|
| 432 | + require( $IP.'/CommonSettings.php' );
|
374 | 433 | }
|
| 434 | +
|
375 | 435 | private function loadSettings() {
|
| 436 | + global $wgWikiFarm, $wgCommandLineMode, $IP, $DP;
|
| 437 | +
|
| 438 | + $wgWikiFarm = false;
|
| 439 | + if ( isset( $this->mOptions['conf'] ) ) {
|
| 440 | + $settingsFile = $this->mOptions['conf'];
|
| 441 | + } else {
|
| 442 | + $settingsFile = "$IP/LocalSettings.php";
|
| 443 | + }
|
| 444 | + if ( isset( $this->mOptions['wiki'] ) ) {
|
| 445 | + $bits = explode( '-', $this->mOptions['wiki'] );
|
| 446 | + if ( count( $bits ) == 1 ) {
|
| 447 | + $bits[] = '';
|
| 448 | + }
|
| 449 | + define( 'MW_DB', $bits[0] );
|
| 450 | + define( 'MW_PREFIX', $bits[1] );
|
| 451 | + }
|
| 452 | +
|
| 453 | + if ( ! is_readable( $settingsFile ) ) {
|
| 454 | + $this->error( "A copy of your installation's LocalSettings.php\n" .
|
| 455 | + "must exist and be readable in the source directory.\n", true );
|
| 456 | + }
|
| 457 | + $wgCommandLineMode = true;
|
| 458 | + $DP = $IP;
|
| 459 | + require_once( "$IP/includes/AutoLoader.php" );
|
| 460 | + require_once( "$IP/includes/Defines.php" );
|
| 461 | + require_once( $settingsFile );
|
376 | 462 | }
|
377 | | -}
|
| 463 | +} |
\ No newline at end of file |
Index: branches/maintenance-work/UPGRADE |
— | — | @@ -42,8 +42,7 @@ |
43 | 43 | repository, via a checkout or export operation. |
44 | 44 | |
45 | 45 | Replace the existing MediaWiki files with the new. You should preserve the |
46 | | -LocalSettings.php file, AdminSettings.php file (if present), and the |
47 | | -"extensions" and "images" directories. |
| 46 | +LocalSettings.php file and the "extensions" and "images" directories. |
48 | 47 | |
49 | 48 | Depending upon your configuration, you may also need to preserve additional |
50 | 49 | directories, including a custom upload directory ($wgUploadDirectory), |
— | — | @@ -51,8 +50,8 @@ |
52 | 51 | |
53 | 52 | === Perform the database upgrade === |
54 | 53 | |
55 | | -You will need an AdminSettings.php file set up in the correct format; see |
56 | | -AdminSettings.sample in the wiki root for more information and examples. |
| 54 | +You will need to have $wgDBadminuser and $wgDBadminpass set in your |
| 55 | +LocalSettings.php, see there for more info. |
57 | 56 | |
58 | 57 | From the command line, browse to the "maintenance" directory and run the |
59 | 58 | update.php script to check and update the schema. This will insert missing |
— | — | @@ -172,10 +171,10 @@ |
173 | 172 | === Web installer === |
174 | 173 | |
175 | 174 | You can use the web-based installer wizard if you first remove the |
176 | | -LocalSettings.php (and AdminSettings.php, if any) files; be sure to |
177 | | -give the installer the same information as you did on the original |
178 | | -install (language/encoding, database name, password, etc). This will |
179 | | -also generate a fresh LocalSettings.php, which you may need to customize. |
| 175 | +LocalSettings.php file; be sure to give the installer the same |
| 176 | +information as you did on the original install (language/encoding, |
| 177 | +database name, password, etc). This will also generate a fresh |
| 178 | +LocalSettings.php, which you may need to customize. |
180 | 179 | |
181 | 180 | You may change some settings during the install, but be very careful! |
182 | 181 | Changing the encoding in particular will generally leave you with a |
— | — | @@ -185,8 +184,8 @@ |
186 | 185 | |
187 | 186 | Additionally, as of 1.4.0 you can run an in-place upgrade script from |
188 | 187 | the command line, keeping your existing LocalSettings.php. This requires |
189 | | -that you create an AdminSettings.php giving an appropriate database user |
190 | | -and password with privileges to modify the database structure. |
| 188 | +that you set $wgDBadminuser and $wgDBadminpassword with an appropriate |
| 189 | +database user and password with privileges to modify the database structure. |
191 | 190 | |
192 | 191 | Once the new files are in place, go into the maintenance subdirectory and |
193 | 192 | run the script: |
Index: branches/maintenance-work/docs/scripts.txt |
— | — | @@ -35,10 +35,9 @@ |
36 | 36 | to force the profiler to save the informations in the database and apply the |
37 | 37 | maintenance/archives/patch-profiling.sql patch to the database. |
38 | 38 | |
39 | | - To enable the profileinfo.php itself, you'll need to create the |
40 | | - AdminSettings.php file (see AdminSettings.sample for more information) and |
41 | | - set $wgEnableProfileInfo to true in that file. See also |
42 | | - http://www.mediawiki.org/wiki/How_to_debug#Profiling. |
| 39 | + To enable the profileinfo.php itself, you'll need to set $wgDBadminuser |
| 40 | + and $wgDBadminpassword in your LocalSettings.php, as well as $wgEnableProfileInfo |
| 41 | + See also http://www.mediawiki.org/wiki/How_to_debug#Profiling. |
43 | 42 | |
44 | 43 | redirect.php |
45 | 44 | Script that only redirect to the article passed in the wpDropdown parameter |
Index: branches/maintenance-work/profileinfo.php |
— | — | @@ -4,7 +4,6 @@ |
5 | 5 | $wgEnableProfileInfo = $wgProfileToDatabase = false; |
6 | 6 | |
7 | 7 | require_once( './includes/WebStart.php' ); |
8 | | -@include_once( './AdminSettings.php' ); |
9 | 8 | |
10 | 9 | ?> |
11 | 10 | <!-- |
Index: branches/maintenance-work/t/Search.inc |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | require 'includes/Defines.php'; |
9 | 9 | require 'includes/ProfilerStub.php'; |
10 | 10 | require 'LocalSettings.php'; |
11 | | -require 'AdminSettings.php'; |
12 | 11 | require 'includes/Setup.php'; |
13 | 12 | |
14 | 13 | function buildTestDatabase( $tables ) { |
Index: branches/maintenance-work/config/index.php |
— | — | @@ -615,6 +615,7 @@ |
616 | 616 | $conf->RootUser = importPost( "RootUser", "root" ); |
617 | 617 | $conf->RootPW = importPost( "RootPW", "" ); |
618 | 618 | $useRoot = importCheck( 'useroot', false ); |
| 619 | + $conf->populateadmin = importCheck( 'populateadmin', false ); |
619 | 620 | $conf->LanguageCode = importPost( "LanguageCode", "en" ); |
620 | 621 | ## MySQL specific: |
621 | 622 | $conf->DBprefix = importPost( "DBprefix" ); |
— | — | @@ -1527,6 +1528,8 @@ |
1528 | 1529 | <label class="column">Superuser account:</label> |
1529 | 1530 | <input type="checkbox" name="useroot" id="useroot" <?php if( $useRoot ) { ?>checked="checked" <?php } ?> /> |
1530 | 1531 | <label for="useroot">Use superuser account</label> |
| 1532 | + <input type="checkbox" name="populateadmin" id="populateadmin" <?php if( $conf->populateadmin ) { ?>checked="checked" <?php } ?> /> |
| 1533 | + <label for="populateadmin">Set as admin user for maintenance</label> |
1531 | 1534 | </div> |
1532 | 1535 | <div class="config-input"><?php aField( $conf, "RootUser", "Superuser name:", "text" ); ?></div> |
1533 | 1536 | <div class="config-input"><?php aField( $conf, "RootPW", "Superuser password:", "password" ); ?></div> |
— | — | @@ -1792,6 +1795,11 @@ |
1793 | 1796 | # Needs literal string interpolation for the current style path |
1794 | 1797 | $slconf['RightsIcon'] = $conf->RightsIcon; |
1795 | 1798 | } |
| 1799 | + |
| 1800 | + if( $conf->populateadmin ) { |
| 1801 | + $slconf['DBadminuser'] = $conf->RootUser; |
| 1802 | + $slconf['DBadminpassword'] = $conf->RootPW; |
| 1803 | + } |
1796 | 1804 | |
1797 | 1805 | if( $conf->DBtype == 'mysql' ) { |
1798 | 1806 | $dbsettings = |
— | — | @@ -1899,6 +1907,10 @@ |
1900 | 1908 | |
1901 | 1909 | {$dbsettings} |
1902 | 1910 | |
| 1911 | +## Database admin settings, used for maintenance scripts |
| 1912 | +\$wgDBadminuser = \"{$slconf['DBadminuser']}\"; |
| 1913 | +\$wgDBadminpassword = \"{$slconf['DBadminpassword']}\"; |
| 1914 | + |
1903 | 1915 | ## Shared memory settings |
1904 | 1916 | \$wgMainCacheType = $cacheType; |
1905 | 1917 | \$wgMemCachedServers = $mcservers; |