r25680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25679‎ | r25680 | r25681 >
Date:08:11, 9 September 2007
Author:werdna
Status:old
Tags:
Comment:
* Allow userCan to take null $user - and replace it with $wgUser if passed.
* (Bug 7027) Shift handling of deletion permissions-checking to getUserPermissionsErrors.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -926,13 +926,11 @@
927927 return;
928928 }
929929
930 - if ((!$wgUser->isAllowed('delete'))) {
931 - $wgOut->permissionRequired( 'delete' );
932 - return;
933 - }
 930+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
934931
935 - if (wfReadOnly()) {
936 - $wgOut->readOnlyPage();
 932+ if (count($permission_errors)>0)
 933+ {
 934+ $wgOut->showPermissionsErrorPage( $permission_errors );
937935 return;
938936 }
939937
@@ -1835,18 +1833,11 @@
18361834 # This code desperately needs to be totally rewritten
18371835
18381836 # Check permissions
1839 - if( $wgUser->isAllowed( 'delete' ) ) {
1840 - if( $wgUser->isBlocked( !$confirm ) ) {
1841 - $wgOut->blockedPage();
1842 - return;
1843 - }
1844 - } else {
1845 - $wgOut->permissionRequired( 'delete' );
1846 - return;
1847 - }
 1837+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
18481838
1849 - if( wfReadOnly() ) {
1850 - $wgOut->readOnlyPage();
 1839+ if (count($permission_errors)>0)
 1840+ {
 1841+ $wgOut->showPermissionsErrorPage( $permission_errors );
18511842 return;
18521843 }
18531844
Index: trunk/phase3/includes/Title.php
@@ -1030,12 +1030,16 @@
10311031 * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
10321032 * @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
10331033 */
1034 - public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true ) {
 1034+ public function getUserPermissionsErrors( $action, $user = null, $doExpensiveQueries = true ) {
10351035 $errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
10361036
10371037 global $wgContLang;
10381038 global $wgLang;
10391039
 1040+ # Be kinder to people who forget to supply a user, assuming they mean $wgUser
 1041+ if (!$user)
 1042+ $user = $wgUser;
 1043+
10401044 if ( wfReadOnly() && $action != 'read' ) {
10411045 global $wgReadOnly;
10421046 $errors[] = array( 'readonlytext', $wgReadOnly );
@@ -1043,7 +1047,7 @@
10441048
10451049 global $wgEmailConfirmToEdit, $wgUser;
10461050
1047 - if ( $wgEmailConfirmToEdit && !$wgUser->isEmailConfirmed() )
 1051+ if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() )
10481052 {
10491053 $errors[] = array( 'confirmedittext' );
10501054 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r25712* Partial revert of r25680 (The bit that allowed people to provide a null $us...werdna03:01, 10 September 2007
r25754Merged revisions 25607-25751 via svnmerge from...david23:02, 10 September 2007

Status & tagging log