r89311 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89310‎ | r89311 | r89312 >
Date:01:26, 2 June 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
Make user right selection in installer actually work, thanks Krinkle for spotting this
Modified paths:
  • /trunk/phase3/includes/installer/LocalSettingsGenerator.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/BlockTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/suite.xml (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/suite.xml
@@ -9,7 +9,7 @@
1010 convertWarningsToExceptions="true"
1111 stopOnFailure="false"
1212 strict="true"
13 - verbose="true">
 13+ verbose="false">
1414 <testsuites>
1515 <testsuite name="includes">
1616 <directory>./includes</directory>
Index: trunk/phase3/tests/phpunit/includes/BlockTest.php
@@ -2,7 +2,6 @@
33
44 /**
55 * @group Database
6 - * @group Broken
76 */
87 class BlockTest extends MediaWikiLangTestCase {
98
Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -147,6 +147,10 @@
148148 );
149149
150150 $ls = new LocalSettingsGenerator( $this );
 151+ $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
 152+ foreach( $rightsProfile as $group => $rightsArr ) {
 153+ $ls->setGroupRights( $group, $rightsArr );
 154+ }
151155 echo $ls->getText();
152156 return $this->session;
153157 }
Index: trunk/phase3/includes/installer/LocalSettingsGenerator.php
@@ -16,6 +16,7 @@
1717
1818 private $extensions = array();
1919 private $values = array();
 20+ private $groupPermissions = array();
2021 private $dbSettings = '';
2122 private $safeMode = false;
2223
@@ -77,6 +78,16 @@
7879 }
7980
8081 /**
 82+ * For $wgGroupPermissions, set a given ['group']['permission'] value.
 83+ * @param $group String Group name
 84+ * @param $rightsArr Array An array of permissions, in the form of:
 85+ * array( 'right' => true, 'right2' => false )
 86+ */
 87+ public function setGroupRights( $group, $rightsArr ) {
 88+ $this->groupPermissions[$group] = $rightsArr;
 89+ }
 90+
 91+ /**
8192 * Returns the escaped version of a string of php code.
8293 *
8394 * @param $string String
@@ -176,13 +187,26 @@
177188 $locale = '';
178189 }
179190
180 - $rights = $this->values['wgRightsUrl'] ? '' : '#';
 191+ $rightsUrl = $this->values['wgRightsUrl'] ? '' : '#';
181192 $hashedUploads = $this->safeMode ? '' : '#';
182193 $metaNamespace = '';
183194 if( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) {
184195 $metaNamespace = "\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n";
185196 }
186197
 198+ $groupRights = '';
 199+ if( $this->groupPermissions ) {
 200+ $groupRights .= "# The following permissions were set based on your choice in the installer\n";
 201+ foreach( $this->groupPermissions as $group => $rightArr ) {
 202+ $group = self::escapePhpString( $group );
 203+ foreach( $rightArr as $right => $perm ) {
 204+ $right = self::escapePhpString( $right );
 205+ $groupRights .= "\$wgGroupPermissions['$group']['$right'] = " .
 206+ wfBoolToStr( $perm ) . "\n";
 207+ }
 208+ }
 209+ }
 210+
187211 switch( $this->values['wgMainCacheType'] ) {
188212 case 'anything':
189213 case 'db':
@@ -298,7 +322,7 @@
299323 ## For attaching licensing metadata to pages, and displaying an
300324 ## appropriate copyright notice / icon. GNU Free Documentation
301325 ## License and Creative Commons licenses are supported so far.
302 -{$rights}\$wgEnableCreativeCommonsRdf = true;
 326+{$rightsUrl}\$wgEnableCreativeCommonsRdf = true;
303327 \$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
304328 \$wgRightsUrl = \"{$this->values['wgRightsUrl']}\";
305329 \$wgRightsText = \"{$this->values['wgRightsText']}\";
@@ -313,7 +337,8 @@
314338 # or if you have suhosin.get.max_value_length set in php.ini (then set it to
315339 # that value)
316340 \$wgResourceLoaderMaxQueryLength = {$this->values['wgResourceLoaderMaxQueryLength']};
317 -";
 341+
 342+{$groupRights}";
318343 }
319344
320345 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89312Followup r89311: rv unrelated changesdemon01:28, 2 June 2011
r89316MFT r89311demon02:03, 2 June 2011
r89598;demon20:01, 6 June 2011
r92351MFT to REL1_18...hashar10:47, 16 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45497* Made it possible to set $wgLogo to false and have no logo. Made this the de...tstarling12:50, 7 January 2009

Comments

#Comment by Catrope (talk | contribs)   19:58, 6 June 2011
+					$groupRights .= "\$wgGroupPermissions['$group']['$right'] = " .
+						wfBoolToStr( $perm ) . "\n";

This is missing a trailing semicolon. Reported by Trilarion on IRC.

#Comment by Krinkle (talk | contribs)   10:49, 16 July 2011

Where exactly ?

#Comment by 😂 (talk | contribs)   11:28, 16 July 2011

Before the \n, see r89598.

#Comment by Krinkle (talk | contribs)   11:35, 16 July 2011

Oh, there! I was looking for a syntax error in the code, not in what it outputs :D

Status & tagging log