Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -39,194 +39,192 @@ |
40 | 40 | parent :: __construct($query, $moduleName, 'dr');
|
41 | 41 | }
|
42 | 42 |
|
43 | | - public function execute() {
|
44 | | - $this->run();
|
45 | | - }
|
| 43 | + private function execute() {
|
46 | 44 |
|
47 | | - private function run() {
|
48 | | -
|
49 | 45 | global $wgUser;
|
50 | 46 | // Before doing anything at all, let's check permissions
|
51 | 47 | if(!$wgUser->isAllowed('deletedhistory'))
|
52 | | - $this->dieUsage('You don\'t have permission to view deleted revisions', 'permissiondenied');
|
| 48 | + $this->dieUsage('You don\'t have permission to view deleted revision information', 'permissiondenied');
|
53 | 49 |
|
54 | | - $db = $this->getDB();
|
55 | | - $params = $this->extractRequestParams();
|
56 | | - $prop = array_flip($params['prop']);
|
57 | | - $fld_revid = isset($prop['revid']);
|
58 | | - $fld_user = isset($prop['user']);
|
59 | | - $fld_comment = isset($prop['comment']);
|
60 | | - $fld_minor = isset($prop['minor']);
|
61 | | - $fld_len = isset($prop['len']);
|
62 | | - $fld_content = isset($prop['content']);
|
63 | | - $fld_token = isset($prop['token']);
|
| 50 | + $db = $this->getDB();
|
| 51 | + $params = $this->extractRequestParams();
|
| 52 | + $prop = array_flip($params['prop']);
|
| 53 | + $fld_revid = isset($prop['revid']);
|
| 54 | + $fld_user = isset($prop['user']);
|
| 55 | + $fld_comment = isset($prop['comment']);
|
| 56 | + $fld_minor = isset($prop['minor']);
|
| 57 | + $fld_len = isset($prop['len']);
|
| 58 | + $fld_content = isset($prop['content']);
|
| 59 | + $fld_token = isset($prop['token']);
|
64 | 60 |
|
65 | | - $result = $this->getResult();
|
66 | | - $pageSet = $this->getPageSet();
|
67 | | - $titles = $pageSet->getTitles();
|
68 | | - $data = array();
|
| 61 | + $result = $this->getResult();
|
| 62 | + $pageSet = $this->getPageSet();
|
| 63 | + $titles = $pageSet->getTitles();
|
| 64 | + $data = array();
|
69 | 65 |
|
70 | | - $this->addTables('archive');
|
71 | | - $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp'));
|
72 | | - if($fld_revid)
|
73 | | - $this->addFields('ar_rev_id');
|
74 | | - if($fld_user)
|
75 | | - $this->addFields('ar_user_text');
|
76 | | - if($fld_comment)
|
77 | | - $this->addFields('ar_comment');
|
78 | | - if($fld_minor)
|
79 | | - $this->addFields('ar_minor_edit');
|
80 | | - if($fld_len)
|
81 | | - $this->addFields('ar_len');
|
82 | | - if($fld_content)
|
83 | | - {
|
84 | | - $this->addTables('text');
|
85 | | - $this->addFields(array('ar_text', 'ar_text_id', 'old_text', 'old_flags'));
|
86 | | - $this->addWhere('ar_text_id = old_id');
|
87 | | -
|
88 | | - // This also means stricter limits
|
89 | | - $userMax = 50;
|
90 | | - $botMax = 200;
|
91 | | - $this->validateLimit('limit', $params['limit'], 1, $userMax, $botMax);
|
92 | | - }
|
93 | | - if($fld_token)
|
94 | | - // Undelete tokens are identical for all pages, so we cache one here
|
95 | | - $token = $wgUser->editToken();
|
96 | | -
|
97 | | - // We need a custom WHERE clause that matches all titles.
|
98 | | - if(count($titles) > 0)
|
99 | | - {
|
100 | | - $lb = new LinkBatch($titles);
|
101 | | - $where = $lb->constructSet('ar', $db);
|
102 | | - $this->addWhere($where);
|
103 | | - }
|
104 | | -
|
105 | | - $this->addOption('LIMIT', $params['limit'] + 1);
|
106 | | - $this->addWhereRange('ar_timestamp', $params['dir'], $params['start'], $params['end']);
|
107 | | - if(isset($params['namespace']))
|
108 | | - $this->addWhereFld('ar_namespace', $params['namespace']);
|
109 | | - $res = $this->select(__METHOD__);
|
110 | | - $pages = array();
|
111 | | - $count = 0;
|
112 | | - // First populate the $pages array
|
113 | | - while($row = $db->fetchObject($res))
|
114 | | - {
|
115 | | - if($count++ == $params['limit'])
|
116 | | - {
|
117 | | - // We've had enough
|
118 | | - $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
|
119 | | - break;
|
120 | | - }
|
121 | | -
|
122 | | - $rev = array();
|
123 | | - $rev['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ar_timestamp);
|
| 66 | + $this->addTables('archive');
|
| 67 | + $this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp'));
|
124 | 68 | if($fld_revid)
|
125 | | - $rev['revid'] = $row->ar_rev_id;
|
| 69 | + $this->addFields('ar_rev_id');
|
126 | 70 | if($fld_user)
|
127 | | - $rev['user'] = $row->ar_user_text;
|
| 71 | + $this->addFields('ar_user_text');
|
128 | 72 | if($fld_comment)
|
129 | | - $rev['comment'] = $row->ar_comment;
|
| 73 | + $this->addFields('ar_comment');
|
130 | 74 | if($fld_minor)
|
131 | | - if($row->ar_minor_edit == 1)
|
132 | | - $rev['minor'] = '';
|
| 75 | + $this->addFields('ar_minor_edit');
|
133 | 76 | if($fld_len)
|
134 | | - $rev['len'] = $row->ar_len;
|
| 77 | + $this->addFields('ar_len');
|
135 | 78 | if($fld_content)
|
136 | | - ApiResult::setContent($rev, Revision::getRevisionText($row));
|
137 | | -
|
138 | | - $t = Title::makeTitle($row->ar_namespace, $row->ar_title);
|
139 | | - if(!isset($pages[$t->getPrefixedText()]))
|
140 | 79 | {
|
141 | | - $pages[$t->getPrefixedText()] = array(
|
142 | | - 'title' => $t->getPrefixedText(),
|
143 | | - 'ns' => intval($row->ar_namespace),
|
144 | | - 'revisions' => array($rev)
|
145 | | - );
|
| 80 | + $this->addTables('text');
|
| 81 | + $this->addFields(array('ar_text', 'ar_text_id', 'old_text', 'old_flags'));
|
| 82 | + $this->addWhere('ar_text_id = old_id');
|
| 83 | +
|
| 84 | + // This also means stricter limits and stricter restrictions
|
| 85 | + if(!$wgUser->isAllowed('undelete'))
|
| 86 | + $this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
|
| 87 | + $userMax = 50;
|
| 88 | + $botMax = 200;
|
| 89 | + $this->validateLimit('limit', $params['limit'], 1, $userMax, $botMax);
|
| 90 | + }
|
146 | 91 | if($fld_token)
|
147 | | - $pages[$t->getPrefixedText()]['token'] = $token;
|
| 92 | + // Undelete tokens are identical for all pages, so we cache one here
|
| 93 | + $token = $wgUser->editToken();
|
| 94 | +
|
| 95 | + // We need a custom WHERE clause that matches all titles.
|
| 96 | + if(count($titles) > 0)
|
| 97 | + {
|
| 98 | + $lb = new LinkBatch($titles);
|
| 99 | + $where = $lb->constructSet('ar', $db);
|
| 100 | + $this->addWhere($where);
|
148 | 101 | }
|
149 | | - else
|
150 | | - $pages[$t->getPrefixedText()]['revisions'][] = $rev;
|
151 | | - }
|
152 | | - $db->freeResult($res);
|
153 | 102 |
|
154 | | - // We don't want entire pagenames as keys, so let's make this array indexed
|
155 | | - foreach($pages as $page)
|
156 | | - {
|
157 | | - $result->setIndexedTagName($page['revisions'], 'rev');
|
158 | | - $data[] = $page;
|
159 | | - }
|
160 | | - $result->setIndexedTagName($data, 'page');
|
161 | | - $result->addValue('query', $this->getModuleName(), $data);
|
162 | | - }
|
| 103 | + $this->addOption('LIMIT', $params['limit'] + 1);
|
| 104 | + $this->addWhereRange('ar_timestamp', $params['dir'], $params['start'], $params['end']);
|
| 105 | + if(isset($params['namespace']))
|
| 106 | + $this->addWhereFld('ar_namespace', $params['namespace']);
|
| 107 | + $res = $this->select(__METHOD__);
|
| 108 | + $pages = array();
|
| 109 | + $count = 0;
|
| 110 | + // First populate the $pages array
|
| 111 | + while($row = $db->fetchObject($res))
|
| 112 | + {
|
| 113 | + if($count++ == $params['limit'])
|
| 114 | + {
|
| 115 | + // We've had enough
|
| 116 | + $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
|
| 117 | + break;
|
| 118 | + }
|
163 | 119 |
|
| 120 | + $rev = array();
|
| 121 | + $rev['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ar_timestamp);
|
| 122 | + if($fld_revid)
|
| 123 | + $rev['revid'] = $row->ar_rev_id;
|
| 124 | + if($fld_user)
|
| 125 | + $rev['user'] = $row->ar_user_text;
|
| 126 | + if($fld_comment)
|
| 127 | + $rev['comment'] = $row->ar_comment;
|
| 128 | + if($fld_minor)
|
| 129 | + if($row->ar_minor_edit == 1)
|
| 130 | + $rev['minor'] = '';
|
| 131 | + if($fld_len)
|
| 132 | + $rev['len'] = $row->ar_len;
|
| 133 | + if($fld_content)
|
| 134 | + ApiResult::setContent($rev, Revision::getRevisionText($row));
|
| 135 | +
|
| 136 | + $t = Title::makeTitle($row->ar_namespace, $row->ar_title);
|
| 137 | + if(!isset($pages[$t->getPrefixedText()]))
|
| 138 | + {
|
| 139 | + $pages[$t->getPrefixedText()] = array(
|
| 140 | + 'title' => $t->getPrefixedText(),
|
| 141 | + 'ns' => intval($row->ar_namespace),
|
| 142 | + 'revisions' => array($rev)
|
| 143 | + );
|
| 144 | + if($fld_token)
|
| 145 | + $pages[$t->getPrefixedText()]['token'] = $token;
|
| 146 | + }
|
| 147 | + else
|
| 148 | + $pages[$t->getPrefixedText()]['revisions'][] = $rev;
|
| 149 | + }
|
| 150 | + $db->freeResult($res);
|
| 151 | +
|
| 152 | + // We don't want entire pagenames as keys, so let's make this array indexed
|
| 153 | + foreach($pages as $page)
|
| 154 | + {
|
| 155 | + $result->setIndexedTagName($page['revisions'], 'rev');
|
| 156 | + $data[] = $page;
|
| 157 | + }
|
| 158 | + $result->setIndexedTagName($data, 'page');
|
| 159 | + $result->addValue('query', $this->getModuleName(), $data);
|
| 160 | + }
|
| 161 | +
|
164 | 162 | protected function getAllowedParams() {
|
165 | | - return array (
|
166 | | - 'start' => array(
|
167 | | - ApiBase :: PARAM_TYPE => 'timestamp'
|
168 | | - ),
|
169 | | - 'end' => array(
|
170 | | - ApiBase :: PARAM_TYPE => 'timestamp',
|
171 | | - ),
|
172 | | - 'dir' => array(
|
173 | | - ApiBase :: PARAM_TYPE => array(
|
174 | | - 'newer',
|
175 | | - 'older'
|
176 | | - ),
|
177 | | - ApiBase :: PARAM_DFLT => 'older'
|
178 | | - ),
|
179 | | - 'namespace' => array(
|
180 | | - ApiBase :: PARAM_ISMULTI => true,
|
181 | | - ApiBase :: PARAM_TYPE => 'namespace'
|
182 | | - ),
|
183 | | - 'limit' => array(
|
184 | | - ApiBase :: PARAM_DFLT => 10,
|
185 | | - ApiBase :: PARAM_TYPE => 'limit',
|
186 | | - ApiBase :: PARAM_MIN => 1,
|
187 | | - ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
|
188 | | - ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
|
189 | | - ),
|
190 | | - 'prop' => array(
|
191 | | - ApiBase :: PARAM_DFLT => 'user|comment',
|
192 | | - ApiBase :: PARAM_TYPE => array(
|
193 | | - 'revid',
|
194 | | - 'user',
|
195 | | - 'comment',
|
196 | | - 'minor',
|
197 | | - 'len',
|
198 | | - 'content',
|
199 | | - 'token'
|
| 163 | + return array (
|
| 164 | + 'start' => array(
|
| 165 | + ApiBase :: PARAM_TYPE => 'timestamp'
|
200 | 166 | ),
|
201 | | - ApiBase :: PARAM_ISMULTI => true
|
202 | | - )
|
203 | | - );
|
| 167 | + 'end' => array(
|
| 168 | + ApiBase :: PARAM_TYPE => 'timestamp',
|
| 169 | + ),
|
| 170 | + 'dir' => array(
|
| 171 | + ApiBase :: PARAM_TYPE => array(
|
| 172 | + 'newer',
|
| 173 | + 'older'
|
| 174 | + ),
|
| 175 | + ApiBase :: PARAM_DFLT => 'older'
|
| 176 | + ),
|
| 177 | + 'namespace' => array(
|
| 178 | + ApiBase :: PARAM_ISMULTI => true,
|
| 179 | + ApiBase :: PARAM_TYPE => 'namespace'
|
| 180 | + ),
|
| 181 | + 'limit' => array(
|
| 182 | + ApiBase :: PARAM_DFLT => 10,
|
| 183 | + ApiBase :: PARAM_TYPE => 'limit',
|
| 184 | + ApiBase :: PARAM_MIN => 1,
|
| 185 | + ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
|
| 186 | + ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
|
| 187 | + ),
|
| 188 | + 'prop' => array(
|
| 189 | + ApiBase :: PARAM_DFLT => 'user|comment',
|
| 190 | + ApiBase :: PARAM_TYPE => array(
|
| 191 | + 'revid',
|
| 192 | + 'user',
|
| 193 | + 'comment',
|
| 194 | + 'minor',
|
| 195 | + 'len',
|
| 196 | + 'content',
|
| 197 | + 'token'
|
| 198 | + ),
|
| 199 | + ApiBase :: PARAM_ISMULTI => true
|
| 200 | + )
|
| 201 | + );
|
204 | 202 | }
|
205 | 203 |
|
206 | 204 | protected function getParamDescription() {
|
207 | | - return array (
|
208 | | - 'start' => 'The timestamp to start enumerating from',
|
209 | | - 'end' => 'The timestamp to stop enumerating at',
|
210 | | - 'dir' => 'The direction in which to enumerate',
|
211 | | - 'namespace' => 'The namespaces to search in',
|
212 | | - 'limit' => 'The maximum amount of revisions to list',
|
213 | | - 'prop' => 'Which properties to get'
|
214 | | - );
|
| 205 | + return array (
|
| 206 | + 'start' => 'The timestamp to start enumerating from',
|
| 207 | + 'end' => 'The timestamp to stop enumerating at',
|
| 208 | + 'dir' => 'The direction in which to enumerate',
|
| 209 | + 'namespace' => 'The namespaces to search in',
|
| 210 | + 'limit' => 'The maximum amount of revisions to list',
|
| 211 | + 'prop' => 'Which properties to get'
|
| 212 | + );
|
215 | 213 | }
|
216 | 214 |
|
217 | 215 | protected function getDescription() {
|
218 | | - return 'List deleted revisions.';
|
| 216 | + return 'List deleted revisions.';
|
219 | 217 | }
|
220 | 218 |
|
221 | 219 | protected function getExamples() {
|
222 | | - return array (
|
223 | | - 'List the first 50 deleted revisions in the Category and Category talk namespaces',
|
224 | | - ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=14|15',
|
225 | | - 'List the last deleted revisions of Main Page and Talk:Main Page, with content:',
|
226 | | - ' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
|
227 | | - );
|
| 220 | + return array (
|
| 221 | + 'List the first 50 deleted revisions in the Category and Category talk namespaces',
|
| 222 | + ' api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=14|15',
|
| 223 | + 'List the last deleted revisions of Main Page and Talk:Main Page, with content:',
|
| 224 | + ' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content'
|
| 225 | + );
|
228 | 226 | }
|
229 | 227 |
|
230 | 228 | public function getVersion() {
|
231 | | - return __CLASS__ . ': $Id: ApiQueryDeletedrevs.php 23531 2007-06-30 01:19:14Z simetrical $';
|
| 229 | + return __CLASS__ . ': $Id: ApiQueryDeletedrevs.php 23531 2007-06-30 01:19:14Z simetrical $';
|
232 | 230 | }
|
233 | 231 | }
|
Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | if(!isset($params['token']))
|
49 | 49 | $this->dieUsage('The token parameter must be set', 'notoken');
|
50 | 50 |
|
51 | | - if(!$wgUser->isAllowed('delete'))
|
| 51 | + if(!$wgUser->isAllowed('undelete'))
|
52 | 52 | $this->dieUsage('You don\'t have permission to restore deleted revisions', 'permissiondenied');
|
53 | 53 | if($wgUser->isBlocked())
|
54 | 54 | $this->dieUsage('You have been blocked from editing', 'blocked');
|
Index: trunk/phase3/includes/SpecialUndelete.php |
— | — | @@ -544,7 +544,7 @@ |
545 | 545 | if( $par != "" ) { |
546 | 546 | $this->mTarget = $par; |
547 | 547 | } |
548 | | - if ( $wgUser->isAllowed( 'delete' ) && !$wgUser->isBlocked() ) { |
| 548 | + if ( $wgUser->isAllowed( 'undelete' ) && !$wgUser->isBlocked() ) { |
549 | 549 | $this->mAllowed = true; |
550 | 550 | } else { |
551 | 551 | $this->mAllowed = false; |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1085,6 +1085,7 @@ |
1086 | 1086 | $wgGroupPermissions['sysop']['createaccount'] = true; |
1087 | 1087 | $wgGroupPermissions['sysop']['delete'] = true; |
1088 | 1088 | $wgGroupPermissions['sysop']['deletedhistory'] = true; // can view deleted history entries, but not see or restore the text |
| 1089 | +$wgGroupPermissions['sysop']['undelete'] = true; |
1089 | 1090 | $wgGroupPermissions['sysop']['editinterface'] = true; |
1090 | 1091 | $wgGroupPermissions['sysop']['editusercssjs'] = true; |
1091 | 1092 | $wgGroupPermissions['sysop']['import'] = true; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -87,6 +87,7 @@ |
88 | 88 | does not exists |
89 | 89 | * (bug 8396) Ignore out-of-date serialised message caches |
90 | 90 | * Add descriptive <title> to revision difference page |
| 91 | +* (bug 12195) Undeleting pages now requires 'undelete' permission |
91 | 92 | |
92 | 93 | === Bug fixes in 1.12 === |
93 | 94 | |