r84266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84265‎ | r84266 | r84267 >
Date:21:07, 18 March 2011
Author:happy-melon
Status:resolved (Comments)
Tags:
Comment:
Follow-up r84249: reimplement isAllowedAny(), and restore isAllowed() to only-accepting-one-parameter mode for the time being.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/ProtectionForm.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialImport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ProtectionForm.php
@@ -133,7 +133,7 @@
134134 // Prevent users from setting levels that they cannot later unset
135135 if( $val == 'sysop' ) {
136136 // Special case, rewrite sysop to either protect and editprotected
137 - if( !$wgUser->isAllowed( 'protect', 'editprotected' ) )
 137+ if( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) )
138138 continue;
139139 } else {
140140 if( !$wgUser->isAllowed($val) )
@@ -527,7 +527,7 @@
528528 //don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled
529529 if( $key == 'sysop' ) {
530530 //special case, rewrite sysop to protect and editprotected
531 - if( !$wgUser->isAllowed( 'protect', 'editprotected' ) && !$this->disabled )
 531+ if( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled )
532532 continue;
533533 } else {
534534 if( !$wgUser->isAllowed($key) && !$this->disabled )
Index: trunk/phase3/includes/User.php
@@ -2248,7 +2248,7 @@
22492249 * @param varargs String permissions to test
22502250 * @return Boolean: True if user is allowed to perform *any* of the given actions
22512251 */
2252 - public function isAllowed( /*...*/ ){
 2252+ public function isAllowedAny( /*...*/ ){
22532253 $permissions = func_get_args();
22542254 foreach( $permissions as $permission ){
22552255 if( $this->isAllowedInternal( $permission ) ){
@@ -2277,7 +2277,7 @@
22782278 * @param $action String
22792279 * @return bool
22802280 */
2281 - private function isAllowedInternal( $action = '' ) {
 2281+ public function isAllowed( $action = '' ) {
22822282 if ( $action === '' ) {
22832283 return true; // In the spirit of DWIM
22842284 }
Index: trunk/phase3/includes/Article.php
@@ -3458,7 +3458,7 @@
34593459 $flags |= EDIT_MINOR;
34603460 }
34613461
3462 - if ( $bot && ( $wgUser->isAllowed( 'markbotedits', 'bot' ) ) ) {
 3462+ if ( $bot && ( $wgUser->isAllowedAny( 'markbotedits', 'bot' ) ) ) {
34633463 $flags |= EDIT_FORCE_BOT;
34643464 }
34653465
Index: trunk/phase3/includes/ImagePage.php
@@ -930,7 +930,7 @@
931931 . $navLinks . "\n"
932932 . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
933933 . '<tr><td></td>'
934 - . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
 934+ . ( $this->current->isLocal() && ( $wgUser->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
935935 . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
936936 . ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
937937 . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
@@ -961,7 +961,7 @@
962962 $row = $selected = '';
963963
964964 // Deletion link
965 - if ( $local && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ) {
 965+ if ( $local && ( $wgUser->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
966966 $row .= '<td>';
967967 # Link to remove from history
968968 if ( $wgUser->isAllowed( 'delete' ) ) {
Index: trunk/phase3/includes/HistoryPage.php
@@ -510,7 +510,7 @@
511511
512512 $del = '';
513513 // Show checkboxes for each revision
514 - if ( $wgUser->isAllowed( 'deleterevision', 'revisionmove' ) ) {
 514+ if ( $wgUser->isAllowedAny( 'deleterevision', 'revisionmove' ) ) {
515515 $this->preventClickjacking();
516516 // If revision was hidden from sysops, disable the checkbox
517517 // However, if the user has revisionmove rights, we cannot disable the checkbox
Index: trunk/phase3/includes/specials/SpecialImport.php
@@ -144,7 +144,7 @@
145145
146146 private function showForm() {
147147 global $wgUser, $wgOut, $wgImportSources, $wgExportMaxLinkDepth;
148 - if( !$wgUser->isAllowed( 'import', 'importupload' ) )
 148+ if( !$wgUser->isAllowedAny( 'import', 'importupload' ) )
149149 return $wgOut->permissionRequired( 'import' );
150150
151151 $action = $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r84268Fix borked r84266.happy-melon21:31, 18 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84249Allow User::isAllowed() to take varargs. "is allowed X or Y" is by far the m...happy-melon14:48, 18 March 2011

Comments

#Comment by IAlex (talk | contribs)   21:27, 18 March 2011

Fatal error: Call to undefined method User::isAllowedInternal() in includes/User.php on line 2254

Seems that the calls to that function should be updated accordingly.

#Comment by Hashar (talk | contribs)   21:28, 18 March 2011

Same, while browsing RecentChanges.

PHP Stack trace: PHP 1. {main}() /var/www/mediawiki-trunk/index.php:0 PHP 2. MediaWiki->performRequestForTitle() /var/www/mediawiki-trunk/index.php:104 PHP 3. MediaWiki->handleSpecialCases() /var/www/mediawiki-trunk/includes/Wiki.php:63 PHP 4. SpecialPage::executePath() /var/www/mediawiki-trunk/includes/Wiki.php:245 PHP 5. SpecialRecentChanges->execute() /var/www/mediawiki-trunk/includes/SpecialPage.php:607 PHP 6. SpecialRecentChanges->checkLastModified() /var/www/mediawiki-trunk/includes/specials/SpecialRecentchanges.php:126 PHP 7. User->useRCPatrol() /var/www/mediawiki-trunk/includes/specials/SpecialRecentchanges.php:218 PHP 8. User->isAllowedAny() /var/www/mediawiki-trunk/includes/User.php:2301

#Comment by Hashar (talk | contribs)   21:28, 18 March 2011

preview :(

PHP Stack trace:
PHP   1. {main}() /var/www/mediawiki-trunk/index.php:0
PHP   2. MediaWiki->performRequestForTitle() /var/www/mediawiki-trunk/index.php:104
PHP   3. MediaWiki->handleSpecialCases() /var/www/mediawiki-trunk/includes/Wiki.php:63
PHP   4. SpecialPage::executePath() /var/www/mediawiki-trunk/includes/Wiki.php:245
PHP   5. SpecialRecentChanges->execute() /var/www/mediawiki-trunk/includes/SpecialPage.php:607
PHP   6. SpecialRecentChanges->checkLastModified() /var/www/mediawiki-trunk/includes/specials/SpecialRecentchanges.php:126
PHP   7. User->useRCPatrol() /var/www/mediawiki-trunk/includes/specials/SpecialRecentchanges.php:218
PHP   8. User->isAllowedAny() /var/www/mediawiki-trunk/includes/User.php:2301
#Comment by Happy-melon (talk | contribs)   21:31, 18 March 2011

Far too much going on in my working copy at the moment. Sorry guys... :(

#Comment by Hashar (talk | contribs)   07:09, 22 March 2011

You should have different local trees. Either using a local git repository or different directories.

Status & tagging log