r41405 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41404‎ | r41405 | r41406 >
Date:00:07, 30 September 2008
Author:brion
Status:old (Comments)
Tags:
Comment:
Revert r41352-41355, r41362-41363: unauthorized schema change breaks parser tests
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/LogPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/UserRestriction.php (deleted) (history)
  • /trunk/phase3/includes/specials/SpecialListUserRestrictions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListusers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRemoveRestrictions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRestrictUser.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-user_restrictions.sql (deleted) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -440,9 +440,6 @@
441441 'Blankpage' => array( 'BlankPage' ),
442442 'LinkSearch' => array( 'LinkSearch' ),
443443 'DeletedContributions' => array( 'DeletedContributions' ),
444 - 'ListUserRestrictions' => array( 'ListUserRestrictions' ),
445 - 'RemoveRestrictions' => array( 'RemoveRestrictions' ),
446 - 'RestrictUser' => array( 'RestrictUser' ),
447444 );
448445
449446 /**
@@ -1201,39 +1198,7 @@
12021199 'edit-no-change' => 'Your edit was ignored, because no change was made to the text.',
12031200 'edit-already-exists' => 'Could not create a new page.
12041201 It already exists.',
1205 -'userrestricted-page' => '<big>\'\'\'Your user name or IP address has been restricted from editing page "$1".\'\'\'</big>
12061202
1207 -The restriction was put by [[User:$2|$2]].
1208 -The reason given is \'\'$3\'\'.
1209 -
1210 -Restriction was put on $4 at $5 and expires on $6 at $7.
1211 -
1212 -You can contact [[User:$2|$2]] or another [[{{MediaWiki:Grouppage-sysop}}|administrator]] to discuss the restriction.',
1213 -'userrestricted-namespace' => "<big>'''Your user name or IP address has been restricted from editing $1 namespace.'''</big>
1214 -
1215 -The restriction was put by [[User:$2|$2]].
1216 -The reason given is ''$3''.
1217 -
1218 -Restriction was put on $4 at $5 and expires on $6 at $7.
1219 -
1220 -You can contact [[User:$2|$2]] or another [[{{MediaWiki:Grouppage-sysop}}|administrator]] to discuss the restriction.",
1221 -'userrestricted-page-indef' => '<big>\'\'\'Your user name or IP address has been restricted from editing page "$1".\'\'\'</big>
1222 -
1223 -The restriction was put by [[User:$2|$2]].
1224 -The reason given is \'\'$3\'\'.
1225 -
1226 -Restriction was put on $4 at $5 and will not expire.
1227 -
1228 -You can contact [[User:$2|$2]] or another [[{{MediaWiki:Grouppage-sysop}}|administrator]] to discuss the restriction.',
1229 -'userrestricted-namespace-indef' => "<big>'''Your user name or IP address has been restricted from editing $1 namespace.'''</big>
1230 -
1231 -The restriction was put by [[User:$2|$2]].
1232 -The reason given is ''$3''.
1233 -
1234 -Restriction was put on $4 at $5 and will not expire.
1235 -
1236 -You can contact [[User:$2|$2]] or another [[{{MediaWiki:Grouppage-sysop}}|administrator]] to discuss the restriction.",
1237 -
12381203 # Parser/template warnings
12391204 'expensive-parserfunction-warning' => 'Warning: This page contains too many expensive parser function calls.
12401205
@@ -2537,7 +2502,6 @@
25382503 'ipbsubmit' => 'Block this user',
25392504 'ipbother' => 'Other time:',
25402505 'ipboptions' => '2 hours:2 hours,1 day:1 day,3 days:3 days,1 week:1 week,2 weeks:2 weeks,1 month:1 month,3 months:3 months,6 months:6 months,1 year:1 year,infinite:infinite', # display1:time1,display2:time2,...
2541 -'ipbinfinite' => 'infinite',
25422506 'ipbotheroption' => 'other',
25432507 'ipbotherreason' => 'Other/additional reason:',
25442508 'ipbhidename' => 'Hide username from the block log, active block list and user list',
@@ -2610,70 +2574,6 @@
26112575 You cannot create an account',
26122576 'cant-block-while-blocked' => 'You cannot block other users while you are blocked.',
26132577
2614 -# Special:ListUserRestrictions
2615 -'listuserrestrictions' => 'List of user restrictions',
2616 -'listuserrestrictions-intro' => 'This list contains all restrictions from editing certain pages and namespaces put on users.
2617 -[[Special:Ipblocklist|Blocks]] are not listed here.',
2618 -'listuserrestrictions-row-ns' => 'restricted $1 from editing $2 namespace ($3)',
2619 -'listuserrestrictions-row-page' => 'restricted $1 from editing $2 ($3)',
2620 -'listuserrestrictions-row-expiry' => 'expires on $1 at $2',
2621 -'listuserrestrictions-legend' => 'Find a restriction',
2622 -'listuserrestrictions-type' => 'Type:',
2623 -'listuserrestrictions-user' => 'User:',
2624 -'listuserrestrictions-namespace' => 'Namespace:',
2625 -'listuserrestrictions-page' => 'Page:',
2626 -'listuserrestrictions-submit' => 'Go',
2627 -'listuserrestrictions-notfound' => 'There is no restriction that matches specified criteria.',
2628 -'listuserrestrictions-empty' => 'This list is empty.',
2629 -'listuserrestrictions-remove' => 'remove',
2630 -'userrestrictiontype-none' => '(none)',
2631 -'userrestrictiontype-namespace' => 'Namespace',
2632 -'userrestrictiontype-page' => 'Page',
2633 -
2634 -# Special:RemoveRestrictions
2635 -'removerestrictions' => 'Remove restriction from a user',
2636 -'removerestrictions-intro' => 'Use the form below to remove a restriction from a certain user.',
2637 -'removerestrictions-noid' => 'No restriction ID was specified.',
2638 -'removerestrictions-wrongid' => 'Restriction with that ID not found.
2639 -Most probably someone has removed it or it expired.',
2640 -'removerestrictions-legend' => 'Remove a restriction',
2641 -'removerestrictions-user' => 'Restricted user:',
2642 -'removerestrictions-type' => 'Restriction type:',
2643 -'removerestrictions-page' => 'Page:',
2644 -'removerestrictions-namespace' => 'Namespace:',
2645 -'removerestrictions-reason' => 'Reason:',
2646 -'removerestrictions-submit' => 'Remove the restriction',
2647 -'removerestrictions-success' => 'Successfully removed the restriction from [[User:$1|$1]].',
2648 -
2649 -# Special:RestrictUser
2650 -'restrictuser' => 'Restrict user',
2651 -'restrictuser-userselect' => 'Select a user',
2652 -'restrictuser-user' => 'User:',
2653 -'restrictuser-go' => 'Restrict user',
2654 -'restrictuser-notfound' => 'User not found',
2655 -'restrictuser-existing' => 'Existing restrictions',
2656 -'restrictuser-legend-page' => 'Restrict from editing certain page',
2657 -'restrictuser-legend-namespace' => 'Restrict from editing certain namespace',
2658 -'restrictuser-title' => 'Page to restrict:',
2659 -'restrictuser-namespace' => 'Namespace:',
2660 -'restrictuser-expiry' => 'Expires:',
2661 -'restrictuser-reason' => 'Reason:',
2662 -'restrictuser-submit' => 'Restrict user',
2663 -'restrictuser-badtitle' => 'Invalid title specified: $1.',
2664 -'restrictuser-badnamespace' => 'Invalid namespace specified.',
2665 -'restrictuser-badexpiry' => 'Invalid expiry specified: $1.',
2666 -'restrictuser-duptitle' => 'User is already restricted from editing this title.',
2667 -'restrictuser-dupnamespace' => 'User is already restricted from editing this namespace.',
2668 -'restrictuser-success' => 'Successfully restricted user $1.',
2669 -
2670 -# Special:Log/restrict
2671 -'restrictionlog' => 'User restriction log',
2672 -'restrictionlogtext' => 'This log contains all restrictions put on users by administrators.',
2673 -'restrictentry' => 'restricted $1 from editing $2 (expiry set to $3)',
2674 -'restrictremoveentry' => 'removed restriction from $1 for editing $2',
2675 -'restrictlognamespace' => '$1 namespace',
2676 -'restrictlogpage' => '[[$1]]', # do not translate or duplicate this message to other languages
2677 -
26782578 # Developer tools
26792579 'lockdb' => 'Lock database',
26802580 'unlockdb' => 'Unlock database',
Index: trunk/phase3/languages/Language.php
@@ -265,20 +265,6 @@
266266 }
267267
268268 /**
269 - * A convenience function that returns the same thing as
270 - * getFormattedNsText() except with '(Main)' for zero namespace.
271 - *
272 - * @return array
273 - */
274 - function getDisplayNsText( $index ) {
275 - if( $index == 0 ) {
276 - return wfMsg( 'blanknamespace' );
277 - } else {
278 - return $this->getFormattedNsText( $index );
279 - }
280 - }
281 -
282 - /**
283269 * Get a namespace key by value, case insensitive.
284270 * Only matches namespace names for the current language, not the
285271 * canonical ones defined in Namespace.php.
Index: trunk/phase3/RELEASE-NOTES
@@ -142,11 +142,10 @@
143143 * Improved upload file type detection for OpenDocument formats
144144 * Added the ability to set the target attribute on external links with
145145 $wgExternalLinkTarget
146 -* (bug 674) Allow admins to block users from editing specific articles and
147 - namespaces
148146 * (bug 368) Don't use caption for alt attribute; allow manual specification
149147 using new "alt=" parameter for images
150148
 149+
151150 === Bug fixes in 1.14 ===
152151
153152 * (bug 14907) DatabasePostgres::fieldType now defined.
Index: trunk/phase3/maintenance/updaters.inc
@@ -145,10 +145,9 @@
146146 array( 'update_password_format' ),
147147
148148 // 1.14
149 - array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
 149+ array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
150150 array( 'do_active_users_init' ),
151 - array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
152 - array( 'add_table', 'user_restrictions', 'patch-user_restrictions.sql' ),
 151+ array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' )
153152 );
154153
155154
Index: trunk/phase3/maintenance/tables.sql
@@ -1243,44 +1243,4 @@
12441244 PRIMARY KEY (ul_key)
12451245 ) /*$wgDBTableOptions*/;
12461246
1247 -CREATE TABLE /*$wgDBprefix*/user_restrictions (
1248 - -- ID of the restriction
1249 - ur_id int NOT NULL auto_increment,
1250 -
1251 - -- Restriction type. Block from either editing namespace or page
1252 - ur_type varbinary(255) NOT NULL,
1253 - -- Namespace to restrict if ur_type = namespace
1254 - ur_namespace int default NULL,
1255 - -- Page to restrict if ur_type = page
1256 - ur_page_namespace int default NULL,
1257 - ur_page_title varchar(255) binary default '',
1258 -
1259 - -- User that is restricted
1260 - ur_user int unsigned NOT NULL,
1261 - ur_user_text tinyblob NOT NULL,
1262 -
1263 - -- User who has done this restriction
1264 - ur_by int unsigned NOT NULL,
1265 - ur_by_text varchar(255) binary NOT NULL default '',
1266 - -- Reason for this restriction
1267 - ur_reason tinyblob NOT NULL,
1268 -
1269 - -- Time when this restriction was made
1270 - ur_timestamp varbinary(14) NOT NULL default '',
1271 - -- Expiry or "infinity"
1272 - ur_expiry varbinary(14) NOT NULL default '',
1273 -
1274 - PRIMARY KEY ur_id (ur_id),
1275 - -- For looking up restrictions for user
1276 - INDEX ur_user (ur_user,ur_user_text(255)),
1277 - -- For Special:ListUserRestrictions
1278 - INDEX ur_type (ur_type(255),ur_timestamp),
1279 - INDEX ur_namespace (ur_namespace,ur_timestamp),
1280 - INDEX ur_page (ur_page_namespace,ur_page_title,ur_timestamp),
1281 - INDEX ur_timestamp (ur_timestamp),
1282 - -- For quick removal of expired restrictions
1283 - INDEX ur_expiry (ur_expiry)
1284 -) /*$wgDBTableOptions*/;
1285 -
12861247 -- vim: sw=2 sts=2 et
Index: trunk/phase3/maintenance/archives/patch-user_restrictions.sql
@@ -1,40 +0,0 @@
2 -
3 -CREATE TABLE /*$wgDBprefix*/user_restrictions (
4 - -- ID of the restriction
5 - ur_id int NOT NULL auto_increment,
6 -
7 - -- Restriction type. Block from either editing namespace or page
8 - ur_type varbinary(255) NOT NULL,
9 - -- Namespace to restrict if ur_type = namespace
10 - ur_namespace int default NULL,
11 - -- Page to restrict if ur_type = page
12 - ur_page_namespace int default NULL,
13 - ur_page_title varchar(255) binary default '',
14 -
15 - -- User that is restricted
16 - ur_user int unsigned NOT NULL,
17 - ur_user_text tinyblob NOT NULL,
18 -
19 - -- User who has done this restriction
20 - ur_by int unsigned NOT NULL,
21 - ur_by_text varchar(255) binary NOT NULL default '',
22 - -- Reason for this restriction
23 - ur_reason tinyblob NOT NULL,
24 -
25 - -- Time when this restriction was made
26 - ur_timestamp varbinary(14) NOT NULL default '',
27 - -- Expiry or "infinity"
28 - ur_expiry varbinary(14) NOT NULL default '',
29 -
30 - PRIMARY KEY ur_id (ur_id),
31 - -- For looking up restrictions for user
32 - INDEX ur_user (ur_user,ur_user_text(255)),
33 - -- For Special:ListUserRestrictions
34 - INDEX ur_type (ur_type(255),ur_timestamp),
35 - INDEX ur_namespace (ur_namespace,ur_timestamp),
36 - INDEX ur_page (ur_page_namespace,ur_page_title,ur_timestamp),
37 - INDEX ur_timestamp (ur_timestamp),
38 - -- For quick removal of expired restrictions
39 - INDEX ur_expiry (ur_expiry)
40 -) /*$wgDBTableOptions*/;
Index: trunk/phase3/includes/UserRestriction.php
@@ -1,158 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Object that represents a user restriction
6 - */
7 -class UserRestriction {
8 - const PAGE = 'page';
9 - const NAMESPACE = 'namespace';
10 -
11 - private $mId, $mType, $mNamespace, $mPage, $mSubjectText, $mSubjectId,
12 - $mBlockerId, $mBlockerText, $mReason, $mTimestamp, $mExpiry;
13 -
14 - public static function newFromRow( $row ) {
15 - if( !$row )
16 - return null;
17 -
18 - $obj = new UserRestriction();
19 - $obj->mId = $row->ur_id;
20 - $obj->mType = $row->ur_type;
21 - if( $obj->mType == self::PAGE ) {
22 - $obj->mPage = Title::makeTitle( $row->ur_page_namespace, $row->ur_page_title );
23 - } elseif( $obj->mType == self::NAMESPACE ) {
24 - $obj->mNamespace = $row->ur_namespace;
25 - } else {
26 - throw new MWException( "Unknown user restriction type: {$row->ur_type}" );
27 - }
28 -
29 - $obj->mSubjectId = $row->ur_user;
30 - $obj->mSubjectText = $row->ur_user_text;
31 - $obj->mBlockerId = $row->ur_by;
32 - $obj->mBlockerText = $row->ur_by_text;
33 - $obj->mReason = $row->ur_reason;
34 - $obj->mTimestamp = wfTimestamp( TS_MW, $row->ur_timestamp );
35 - $obj->mExpiry = $row->ur_expiry;
36 - return $obj;
37 - }
38 -
39 - public static function fetchForUser( $user, $forWrite = false ) {
40 - $dbr = wfGetDB( $forWrite ? DB_MASTER : DB_SLAVE );
41 - if( is_int( $user ) )
42 - $query = array( 'ur_user' => $user );
43 - else
44 - $query = array( 'ur_user_text' => $user );
45 - $res = $dbr->select( 'user_restrictions', '*', $query, __METHOD__ );
46 - $result = array();
47 - foreach( $res as $row ) {
48 - $result[] = self::newFromRow( $row );
49 - }
50 - return $result;
51 - }
52 -
53 - public static function newFromId( $id, $forWrite = false ) {
54 - $dbr = wfGetDB( $forWrite ? DB_MASTER : DB_SLAVE );
55 - if( !$id || !is_numeric( $id ) )
56 - return null;
57 - $res = $dbr->selectRow( 'user_restrictions', '*', array( 'ur_id' => $id ), __METHOD__ );
58 - return self::newFromRow( $res );
59 - }
60 -
61 - public function getId() { return $this->mId; }
62 - public function setId( $v ) { $this->mId = $v; }
63 - public function getType() { return $this->mType; }
64 - public function setType( $v ) { $this->mType = $v; }
65 - public function getNamespace() { return $this->mNamespace; }
66 - public function setNamespace( $v ) { $this->mNamespace = $v; }
67 - public function getPage() { return $this->mPage; }
68 - public function setPage( $v ) { $this->mPage = $v; }
69 - public function getSubjectId() { return $this->mSubjectId; }
70 - public function setSubjectId( $v ) { $this->mSubjectId = $v; }
71 - public function getSubjectText() { return $this->mSubjectText; }
72 - public function setSubjectText( $v ) { $this->mSubjectText = $v; }
73 - public function getBlockerId() { return $this->mBlockerId; }
74 - public function setBlockerId( $v ) { $this->mBlockerId = $v; }
75 - public function getBlockerText() { return $this->mBlockerText; }
76 - public function setBlockerText( $v ) { $this->mBlockerText = $v; }
77 - public function getReason() { return $this->mReason; }
78 - public function setReason( $v ) { $this->mReason = $v; }
79 - public function getTimestamp() { return $this->mTimestamp; }
80 - public function setTimestamp( $v ) { $this->mTimestamp = $v; }
81 - public function getExpiry() { return $this->mExpiry; }
82 - public function setExpiry( $v ) { $this->mExpiry = $v; }
83 -
84 - public function isPage() {
85 - return $this->mType == self::PAGE;
86 - }
87 - public function isNamespace() {
88 - return $this->mType == self::NAMESPACE;
89 - }
90 -
91 - public function isExpired() {
92 - return is_numeric( $this->mExpiry ) && $this->mExpiry < wfTimestampNow( TS_MW );
93 - }
94 -
95 - public function deleteIfExpired() {
96 - if( $this->isExpired() ) {
97 - $this->delete();
98 - return true;
99 - } else {
100 - return false;
101 - }
102 - }
103 -
104 - public function delete() {
105 - $dbw = wfGetDB( DB_MASTER );
106 - $dbw->delete( 'user_restrictions', array( 'ur_id' => $this->mId ), __METHOD__ );
107 - return $dbw->affectedRows();
108 - }
109 -
110 - public static function purgeExpired() {
111 - $dbw = wfGetDB( DB_MASTER );
112 - $dbw->delete( 'user_restrictions', array( 'ur_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ );
113 - }
114 -
115 - public function commit() {
116 - $dbw = wfGetDB( DB_MASTER );
117 - $this->setId( $dbw->nextSequenceValue('user_restrictions_ur_id_val') );
118 - $row = array(
119 - 'ur_id' => $this->mId,
120 - 'ur_type' => $this->mType,
121 - 'ur_user' => $this->mSubjectId,
122 - 'ur_user_text' => $this->mSubjectText,
123 - 'ur_by' => $this->mBlockerId,
124 - 'ur_by_text' => $this->mBlockerText,
125 - 'ur_reason' => $this->mReason,
126 - 'ur_timestamp' => $dbw->timestamp( $this->mTimestamp ),
127 - 'ur_expiry' => $this->mExpiry,
128 - );
129 - if( $this->isPage() ) {
130 - $row['ur_page_namespace'] = $this->mPage->getNamespace();
131 - $row['ur_page_title'] = $this->mPage->getDbKey();
132 - }
133 - if( $this->isNamespace() ) {
134 - $row['ur_namespace'] = $this->mNamespace;
135 - }
136 - $dbw->insert( 'user_restrictions', $row, __METHOD__ );
137 - }
138 -
139 - public static function formatType( $type ) {
140 - return wfMsg( 'userrestrictiontype-' . $type );
141 - }
142 -
143 - /**
144 - * Converts expiry which user input to the internal representation.
145 - * Returns false if invalid expiry is set, Block::infinity() on empty value,
146 - * Block::infinity() on infinity or 14-symbol timestamp
147 - */
148 - public static function convertExpiry( $expiry ) {
149 - if( !$expiry )
150 - return Block::infinity();
151 - if( in_array( $expiry, array( 'infinite', 'infinity', 'indefinite' ) ) )
152 - return Block::infinity();
153 - $unix = @strtotime( $expiry );
154 - if( !$unix || $unix === -1 )
155 - return false;
156 - else
157 - return wfTimestamp( TS_MW, $unix );
158 - }
159 -}
Index: trunk/phase3/includes/User.php
@@ -14,7 +14,7 @@
1515 * \type{\int} Serialized record version.
1616 * @ingroup Constants
1717 */
18 -define( 'MW_USER_VERSION', 7 );
 18+define( 'MW_USER_VERSION', 6 );
1919
2020 /**
2121 * \type{\string} Some punctuation to prevent editing from broken text-mangling proxies.
@@ -118,8 +118,6 @@
119119 'mEditCount',
120120 // user_group table
121121 'mGroups',
122 - // user_restrictions table
123 - 'mRestrictions',
124122 );
125123
126124 /**
@@ -158,7 +156,6 @@
159157 'proxyunbannable',
160158 'purge',
161159 'read',
162 - 'restrict',
163160 'reupload',
164161 'reupload-shared',
165162 'rollback',
@@ -180,8 +177,7 @@
181178 //@{
182179 var $mId, $mName, $mRealName, $mPassword, $mNewpassword, $mNewpassTime,
183180 $mEmail, $mOptions, $mTouched, $mToken, $mEmailAuthenticated,
184 - $mEmailToken, $mEmailTokenExpires, $mRegistration, $mGroups,
185 - $mRestrictions;
 181+ $mEmailToken, $mEmailTokenExpires, $mRegistration, $mGroups;
186182 //@}
187183
188184 /**
@@ -301,7 +297,6 @@
302298 function saveToCache() {
303299 $this->load();
304300 $this->loadGroups();
305 - $this->loadRestrictions();
306301 if ( $this->isAnon() ) {
307302 // Anonymous users are uncached
308303 return;
@@ -883,7 +878,6 @@
884879 # Initialise user table data
885880 $this->loadFromRow( $s );
886881 $this->mGroups = null; // deferred
887 - $this->mRestrictions = null;
888882 $this->getEditCount(); // revalidation for nulls
889883 return true;
890884 } else {
@@ -3243,50 +3237,4 @@
32443238 return true;
32453239 }
32463240
3247 - // Restrictions-related block
3248 -
3249 - public function loadRestrictions() {
3250 - if( is_null( $this->mRestrictions ) )
3251 - $this->mRestrictions = UserRestriction::fetchForUser( $this->isLoggedIn() ?
3252 - intval( $this->getId() ) : $this->getName() );
3253 - }
3254 -
3255 - public function getRestrictions() {
3256 - $this->loadRestrictions();
3257 -
3258 - // Check for expired restrictions. Recache if found expired ones
3259 - static $checked = false;
3260 - if( !$checked ) {
3261 - $expired = false;
3262 - $old = $this->mRestrictions;
3263 - $this->mRestrictions = array();
3264 - foreach( $old as $restriction ) {
3265 - if( $restriction->deleteIfExpired() )
3266 - $expired = true;
3267 - else
3268 - $this->mRestrictions[] = $restriction;
3269 - }
3270 - if( $expired )
3271 - $this->saveToCache();
3272 - $checked = true;
3273 - }
3274 -
3275 - return $this->mRestrictions;
3276 - }
3277 -
3278 - public function getRestrictionForPage( Title $page ) {
3279 - foreach( $this->getRestrictions() as $r ) {
3280 - if( $r->isPage() && $page->equals( $r->getPage() ) )
3281 - return $r;
3282 - }
3283 - return null;
3284 - }
3285 -
3286 - public function getRestrictionForNamespace( $nsid ) {
3287 - foreach( $this->getRestrictions() as $r ) {
3288 - if( $r->isNamespace() && $r->getNamespace() == $nsid )
3289 - return $r;
3290 - }
3291 - return null;
3292 - }
32933241 }
Index: trunk/phase3/includes/SpecialPage.php
@@ -126,9 +126,6 @@
127127 'Allpages' => 'SpecialAllpages',
128128 'Prefixindex' => 'SpecialPrefixindex',
129129 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
130 - 'ListUserRestrictions' => array( 'SpecialPage', 'ListUserRestrictions' ),
131 - 'RemoveRestrictions' => array( 'UnlistedSpecialPage', 'RemoveRestrictions', 'restrict' ),
132 - 'RestrictUser' => array( 'SpecialPage', 'RestrictUser', 'restrict' ),
133130 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
134131 'Contributions' => array( 'SpecialPage', 'Contributions' ),
135132 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
Index: trunk/phase3/includes/Title.php
@@ -1011,7 +1011,9 @@
10121012 }
10131013 $errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
10141014
1015 - global $wgContLang, $wgLang, $wgEmailConfirmToEdit;
 1015+ global $wgContLang;
 1016+ global $wgLang;
 1017+ global $wgEmailConfirmToEdit;
10161018
10171019 if ( $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount' ) {
10181020 $errors[] = array( 'confirmedittext' );
@@ -1043,7 +1045,20 @@
10441046 $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
10451047
10461048 if ( $blockExpiry == 'infinity' ) {
1047 - $blockExpiry = wfMsg( 'ipbinfinite' );
 1049+ // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
 1050+ $scBlockExpiryOptions = wfMsg( 'ipboptions' );
 1051+
 1052+ foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
 1053+ if ( strpos( $option, ':' ) == false )
 1054+ continue;
 1055+
 1056+ list ($show, $value) = explode( ":", $option );
 1057+
 1058+ if ( $value == 'infinite' || $value == 'indefinite' ) {
 1059+ $blockExpiry = $show;
 1060+ break;
 1061+ }
 1062+ }
10481063 } else {
10491064 $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
10501065 }
@@ -1053,9 +1068,9 @@
10541069 $errors[] = array( ($block->mAuto ? 'autoblockedtext' : 'blockedtext'), $link, $reason, $ip, $name,
10551070 $blockid, $blockExpiry, $intended, $blockTimestamp );
10561071 }
1057 -
 1072+
10581073 // Remove the errors being ignored.
1059 -
 1074+
10601075 foreach( $errors as $index => $error ) {
10611076 $error_key = is_array($error) ? $error[0] : $error;
10621077
@@ -1078,8 +1093,6 @@
10791094 * @return \type{\array} Array of arrays of the arguments to wfMsg to explain permissions problems.
10801095 */
10811096 private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
1082 - global $wgLang;
1083 -
10841097 wfProfileIn( __METHOD__ );
10851098
10861099 $errors = array();
@@ -1225,31 +1238,6 @@
12261239 $errors[] = $return;
12271240 }
12281241
1229 - // Check per-user restrictions
1230 - if( $action != 'read' ) {
1231 - $r = $user->getRestrictionForPage( $this );
1232 - if( !$r )
1233 - $r = $user->getRestrictionForNamespace( $this->getNamespace() );
1234 - if( $r ) {
1235 - $error = array();
1236 - $start = array( $wgLang->date( $r->getTimestamp() ), $wgLang->time( $r->getTimestamp() ) );
1237 - if( $r->isPage() )
1238 - $error = array( 'userrestricted-page', $this->getFullText(),
1239 - $r->getBlockerText(), $r->getReason(), $start[0], $start[1] );
1240 - elseif( $r->isNamespace() )
1241 - $error = array( 'userrestricted-namespace', $wgLang->getDisplayNsText( $this->getNamespace() ),
1242 - $r->getBlockerText(), $r->getReason(), $start[0], $start[1] );
1243 -
1244 - if( $r->getExpiry() == 'infinity' ) {
1245 - $error[0] .= '-indef';
1246 - } else {
1247 - $error[] = $wgLang->date( $r->getExpiry() );
1248 - $error[] = $wgLang->time( $r->getExpiry() );
1249 - }
1250 - $errors[] = $error;
1251 - }
1252 - }
1253 -
12541242 wfProfileOut( __METHOD__ );
12551243 return $errors;
12561244 }
Index: trunk/phase3/includes/AutoLoader.php
@@ -198,7 +198,6 @@
199199 'UserArray' => 'includes/UserArray.php',
200200 'UserArrayFromResult' => 'includes/UserArray.php',
201201 'UserMailer' => 'includes/UserMailer.php',
202 - 'UserRestriction' => 'includes/UserRestriction.php',
203202 'UserRightsProxy' => 'includes/UserRightsProxy.php',
204203 'WatchedItem' => 'includes/WatchedItem.php',
205204 'WatchlistEditor' => 'includes/WatchlistEditor.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1183,7 +1183,6 @@
11841184 $wgGroupPermissions['sysop']['apihighlimits'] = true;
11851185 $wgGroupPermissions['sysop']['browsearchive'] = true;
11861186 $wgGroupPermissions['sysop']['noratelimit'] = true;
1187 -$wgGroupPermissions['sysop']['restrict'] = true;
11881187 #$wgGroupPermissions['sysop']['mergehistory'] = true;
11891188
11901189 // Permission to change users' group assignments
@@ -2669,7 +2668,6 @@
26702669 'patrol',
26712670 'merge',
26722671 'suppress',
2673 - 'restrict',
26742672 );
26752673
26762674 /**
@@ -2700,7 +2698,6 @@
27012699 'patrol' => 'patrol-log-page',
27022700 'merge' => 'mergelog',
27032701 'suppress' => 'suppressionlog',
2704 - 'restrict' => 'restrictionlog',
27052702 );
27062703
27072704 /**
@@ -2721,7 +2718,6 @@
27222719 'patrol' => 'patrol-log-header',
27232720 'merge' => 'mergelogpagetext',
27242721 'suppress' => 'suppressionlogtext',
2725 - 'restrict' => 'restrictionlogtext',
27262722 );
27272723
27282724 /**
@@ -2755,8 +2751,6 @@
27562752 'suppress/event' => 'logdelete-logentry',
27572753 'suppress/delete' => 'suppressedarticle',
27582754 'suppress/block' => 'blocklogentry',
2759 - 'restrict/restrict' => 'restrictentry',
2760 - 'restrict/remove' => 'restrictremoveentry',
27612755 );
27622756
27632757 /**
@@ -2827,8 +2821,6 @@
28282822 'Preferences' => 'users',
28292823 'Resetpass' => 'users',
28302824 'DeletedContributions' => 'users',
2831 - 'ListUserRestrictions' => 'users',
2832 - 'RestrictUser' => 'users',
28332825
28342826 'Mostlinked' => 'highuse',
28352827 'Mostlinkedcategories' => 'highuse',
Index: trunk/phase3/includes/specials/SpecialRemoveRestrictions.php
@@ -56,7 +56,5 @@
5757 if( $r->isNamespace() )
5858 $params[] = $r->getNamespace();
5959 $log->addEntry( 'remove', Title::makeTitle( NS_USER, $r->getSubjectText() ), $reason, $params );
60 - $userObj = User::newFromName( $r->getSubjectText(), false );
61 - $userObj->invalidateCache();
6260 return $result;
6361 }
Index: trunk/phase3/includes/specials/SpecialListUserRestrictions.php
@@ -134,7 +134,7 @@
135135 $subjlink = $sk->userLink( $r->getSubjectId(), $r->getSubjectText() ) .
136136 $sk->userToolLinks( $r->getSubjectId(), $r->getSubjectText() );
137137 $expiry = is_numeric( $r->getExpiry() ) ?
138 - wfMsg( 'listuserrestrictions-row-expiry', $wgLang->date( $r->getExpiry() ), $wgLang->time( $r->getExpiry() ) ) :
 138+ wfMsg( 'listuserrestrictions-row-expiry', $wgLang->timeanddate( $r->getExpiry() ) ) :
139139 wfMsg( 'ipbinfinite' );
140140 $msg = '';
141141 if( $r->isNamespace() ) {
Index: trunk/phase3/includes/specials/SpecialListusers.php
@@ -123,13 +123,10 @@
124124 }
125125
126126 $item = wfSpecialList( $name, $groups );
127 - $edits = '';
128 - if ( $row->edits ) {
129 - $editCount = $wgLang->formatNum( $row->edits );
130 - $edits = ' [' . wfMsgExt( 'usereditcount', 'parsemag', $editCount ) . ']';
131 - }
 127+ $editCount = $wgLang->formatNum( $row->edits );
 128+ $edits = wfMsgExt( 'usereditcount', 'parsemag', $editCount );
132129 wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
133 - return "<li>{$item}{$edits}</li>";
 130+ return "<li>{$item} [$edits]</li>";
134131 }
135132
136133 function getBody() {
Index: trunk/phase3/includes/specials/SpecialRestrictUser.php
@@ -106,7 +106,7 @@
107107 if ( $error )
108108 $wgOut->wrapWikiMsg( '<strong class="error">$1</strong>', $error );
109109 if ( $success )
110 - $wgOut->wrapWikiMsg( '<strong class="success">$1</strong>', $success );
 110+ $wgOut->wrapWikiMsg( '<strong class="success">$1/strong>', $success );
111111 }
112112
113113 public static function doPageRestriction( $uid, $user ) {
@@ -126,7 +126,6 @@
127127 $l = new LogPage( 'restrict' );
128128 $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(),
129129 array( $r->getType(), $r->getPage()->getFullText(), $logExpiry) );
130 - self::invalidateCache( $user );
131130 }
132131
133132 public static function namespaceRestrictionForm( $uid, $user, $oldRestrictions ) {
@@ -137,13 +136,13 @@
138137 $wgUser->matchEditToken( $wgRequest->getVal( 'edittoken' ) ) ) {
139138 $ns = $wgRequest->getVal( 'namespace' );
140139 if( $wgContLang->getNsText( $ns ) === false )
141 - $error = array( 'restrictuser-badnamespace' );
 140+ $error = wfMsgExt( 'restrictuser-badnamespace', 'parseinline' );
142141 elseif( UserRestriction::convertExpiry( $wgRequest->getVal( 'expiry' ) ) === false )
143 - $error = array( 'restrictuser-badexpiry', $wgRequest->getVal( 'expiry' ) );
 142+ $error = wfMsgExt( 'restrictuser-badexpiry', 'parseinline', $wgRequest->getVal( 'expiry' ) );
144143 else
145144 foreach( $oldRestrictions as $r )
146145 if( $r->isNamespace() && $r->getNamespace() == $ns )
147 - $error = array( 'restrictuser-dupnamespace' );
 146+ $error = wfMsgExt( 'restrictuser-dupnamespace', 'parse' );
148147 if( !$error ) {
149148 self::doNamespaceRestriction( $uid, $user );
150149 $success = array('restrictuser-success', $user);
@@ -186,11 +185,5 @@
187186 $l = new LogPage( 'restrict' );
188187 $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(),
189188 array( $r->getType(), $r->getNamespace(), $logExpiry ) );
190 - self::invalidateCache( $user );
191189 }
192 -
193 - private static function invalidateCache( $user ) {
194 - $userObj = User::newFromName( $user, false );
195 - $userObj->invalidateCache();
196 - }
197190 }
Index: trunk/phase3/includes/LogPage.php
@@ -193,19 +193,6 @@
194194 } else {
195195 $rv = wfMsgForContent( $wgLogActions[$key], $titleLink );
196196 }
197 - } elseif( $type == 'restrict' ) {
198 - if( $params[0] == UserRestriction::PAGE )
199 - $subj = wfMsgExt( 'restrictlogpage', 'parseinline', $params[1] );
200 - if( $params[0] == UserRestriction::NAMESPACE )
201 - $subj = wfMsgExt( 'restrictlognamespace', 'parseinline', $wgLang->getDisplayNsText( $params[1] ) );
202 - $expiry = '';
203 - if( $key == 'restrict/restrict' )
204 - $expiry = $wgLang->translateBlockExpiry( $params[2] );
205 - if ( $skin ) {
206 - $rv = wfMsg( $wgLogActions[$key], $titleLink, $subj, $expiry );
207 - } else {
208 - $rv = wfMsgForContent( $wgLogActions[$key], $titleLink, $subj, $expiry );
209 - }
210197 } else {
211198 $details = '';
212199 array_unshift( $params, $titleLink );
@@ -273,7 +260,6 @@
274261 }
275262 break;
276263 case 'rights':
277 - case 'restrict':
278264 $text = $wgContLang->ucfirst( $title->getText() );
279265 $titleLink = $skin->makeLinkObj( Title::makeTitle( NS_USER, $text ) );
280266 break;

Follow-up revisions

RevisionCommit summaryAuthorDate
r41507Reverting r41410 -- broke interwikis totally in parser tests....brion16:59, 1 October 2008
r53118follow-up r53116: let's just delete the files since the feature was reverted ...ialex19:07, 11 July 2009
r63979Unused file. Feature was reverted in r41405. Other files were removed on r53118.platonides14:51, 20 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41352* (bug 674) Allow users to be blocked from editing a specific article...vasilievvv16:08, 28 September 2008
r41362* Fix caching...vasilievvv19:34, 28 September 2008

Comments

#Comment by VasilievVV (talk | contribs)   21:41, 30 September 2008

I have actually fixed parser test breakage in my local copy. Please, tell me when you review the schema change (if you have some notes about it, you may email them to me) so I can put it back to trunk.

Status & tagging log