Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -125,23 +125,12 @@ |
126 | 126 | $result->addValue('query', $this->getModuleName(), $data); |
127 | 127 | } |
128 | 128 | |
129 | | - /** |
130 | | - * Security overview: As implemented, any change to a restricted page (userCanRead() == false) |
131 | | - * is hidden from the client, except when a page is being moved to a non-restricted name, |
132 | | - * or when a non-restricted becomes restricted. When shown, all other fields are shown as well. |
133 | | - */ |
134 | 129 | private function extractRowInfo($row) { |
135 | | - $title = Title :: makeTitle($row->rc_namespace, $row->rc_title); |
136 | 130 | $movedToTitle = false; |
137 | 131 | if (!empty($row->rc_moved_to_title)) |
138 | 132 | $movedToTitle = Title :: makeTitle($row->rc_moved_to_ns, $row->rc_moved_to_title); |
139 | 133 | |
140 | | - // If either this is an edit of a restricted page, |
141 | | - // or a move where both to and from names are restricted, skip |
142 | | - if (!$title->userCanRead() && (!$movedToTitle || |
143 | | - ($movedToTitle && !$movedToTitle->userCanRead()))) |
144 | | - return false; |
145 | | - |
| 134 | + $title = Title :: makeTitle($row->rc_namespace, $row->rc_title); |
146 | 135 | $vals = array (); |
147 | 136 | |
148 | 137 | $vals['type'] = intval($row->rc_type); |
— | — | @@ -149,7 +138,7 @@ |
150 | 139 | if ($this->fld_title) { |
151 | 140 | ApiQueryBase :: addTitleInfo($vals, $title); |
152 | 141 | if ($movedToTitle) |
153 | | - ApiQueryBase :: addTitleInfo($vals, $movedToTitle, false, "new_"); |
| 142 | + ApiQueryBase :: addTitleInfo($vals, $movedToTitle, "new_"); |
154 | 143 | } |
155 | 144 | |
156 | 145 | if ($this->fld_ids) { |
Index: trunk/phase3/includes/api/ApiQueryAllLinks.php |
— | — | @@ -101,17 +101,15 @@ |
102 | 102 | } |
103 | 103 | |
104 | 104 | if (is_null($resultPageSet)) { |
105 | | - $title = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
106 | | - if ($title->userCanRead()) { |
107 | | - $vals = array(); |
108 | | - if ($fld_ids) |
109 | | - $vals['fromid'] = intval($row->pl_from); |
110 | | - if ($fld_title) { |
111 | | - $vals['ns'] = intval($title->getNamespace()); |
112 | | - $vals['title'] = $title->getPrefixedText(); |
113 | | - } |
114 | | - $data[] = $vals; |
| 105 | + $vals = array(); |
| 106 | + if ($fld_ids) |
| 107 | + $vals['fromid'] = intval($row->pl_from); |
| 108 | + if ($fld_title) { |
| 109 | + $title = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
| 110 | + $vals['ns'] = intval($title->getNamespace()); |
| 111 | + $vals['title'] = $title->getPrefixedText(); |
115 | 112 | } |
| 113 | + $data[] = $vals; |
116 | 114 | } else { |
117 | 115 | $pageids[] = $row->pl_from; |
118 | 116 | } |
Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | // Report any missing titles |
295 | 295 | foreach ($pageSet->getMissingTitles() as $fakeId => $title) { |
296 | 296 | $vals = array(); |
297 | | - ApiQueryBase :: addTitleInfo($vals, $title, true); |
| 297 | + ApiQueryBase :: addTitleInfo($vals, $title); |
298 | 298 | $vals['missing'] = ''; |
299 | 299 | $pages[$fakeId] = $vals; |
300 | 300 | } |
— | — | @@ -310,7 +310,7 @@ |
311 | 311 | foreach ($pageSet->getGoodTitles() as $pageid => $title) { |
312 | 312 | $vals = array(); |
313 | 313 | $vals['pageid'] = $pageid; |
314 | | - ApiQueryBase :: addTitleInfo($vals, $title, true); |
| 314 | + ApiQueryBase :: addTitleInfo($vals, $title); |
315 | 315 | $pages[$pageid] = $vals; |
316 | 316 | } |
317 | 317 | |
Index: trunk/phase3/includes/api/ApiQueryLinks.php |
— | — | @@ -102,9 +102,8 @@ |
103 | 103 | $lastId = $row->pl_from; |
104 | 104 | } |
105 | 105 | |
106 | | - $title = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
107 | 106 | $vals = array(); |
108 | | - ApiQueryBase :: addTitleInfo($vals, $title, true); |
| 107 | + ApiQueryBase :: addTitleInfo($vals, Title :: makeTitle($row->pl_namespace, $row->pl_title)); |
109 | 108 | $data[] = $vals; |
110 | 109 | } |
111 | 110 | |
— | — | @@ -116,9 +115,7 @@ |
117 | 116 | |
118 | 117 | $titles = array(); |
119 | 118 | while ($row = $db->fetchObject($res)) { |
120 | | - $title = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
121 | | - if($title->userCanRead()) |
122 | | - $titles[] = $title; |
| 119 | + $titles[] = Title :: makeTitle($row->pl_namespace, $row->pl_title); |
123 | 120 | } |
124 | 121 | $resultPageSet->populateFromTitles($titles); |
125 | 122 | } |
Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php |
— | — | @@ -110,19 +110,17 @@ |
111 | 111 | } |
112 | 112 | |
113 | 113 | if (is_null($resultPageSet)) { |
114 | | - $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
115 | | - if ($title->userCanRead()) { |
116 | | - $vals = array(); |
117 | | - if ($fld_ids) |
118 | | - $vals['pageid'] = intval($row->page_id); |
119 | | - if ($fld_title) { |
120 | | - $vals['ns'] = intval($title->getNamespace()); |
121 | | - $vals['title'] = $title->getPrefixedText(); |
122 | | - } |
123 | | - if ($fld_url) |
124 | | - $vals['url'] = $row->el_to; |
125 | | - $data[] = $vals; |
| 114 | + $vals = array(); |
| 115 | + if ($fld_ids) |
| 116 | + $vals['pageid'] = intval($row->page_id); |
| 117 | + if ($fld_title) { |
| 118 | + $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
| 119 | + $vals['ns'] = intval($title->getNamespace()); |
| 120 | + $vals['title'] = $title->getPrefixedText(); |
126 | 121 | } |
| 122 | + if ($fld_url) |
| 123 | + $vals['url'] = $row->el_to; |
| 124 | + $data[] = $vals; |
127 | 125 | } else { |
128 | 126 | $resultPageSet->processDbRow($row); |
129 | 127 | } |
— | — | @@ -197,7 +195,7 @@ |
198 | 196 | } |
199 | 197 | |
200 | 198 | public function getVersion() { |
201 | | - return __CLASS__ . ': $Id:$'; |
| 199 | + return __CLASS__ . ': $Id$'; |
202 | 200 | } |
203 | 201 | } |
204 | 202 | ?> |
Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -94,12 +94,10 @@ |
95 | 95 | |
96 | 96 | if (is_null($resultPageSet)) { |
97 | 97 | $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
98 | | - if ($title->userCanRead()) { |
99 | | - $data[] = array( |
100 | | - 'pageid' => intval($row->page_id), |
101 | | - 'ns' => intval($title->getNamespace()), |
102 | | - 'title' => $title->getPrefixedText()); |
103 | | - } |
| 98 | + $data[] = array( |
| 99 | + 'pageid' => intval($row->page_id), |
| 100 | + 'ns' => intval($title->getNamespace()), |
| 101 | + 'title' => $title->getPrefixedText()); |
104 | 102 | } else { |
105 | 103 | $resultPageSet->processDbRow($row); |
106 | 104 | } |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -96,8 +96,8 @@ |
97 | 97 | |
98 | 98 | // Impose module restrictions. |
99 | 99 | // If the current user cannot read, |
100 | | - // Remove all modules other than login & help |
101 | | - global $wgUser, $wgWhitelistRead; |
| 100 | + // Remove all modules other than login |
| 101 | + global $wgUser; |
102 | 102 | if (!$wgUser->isAllowed('read')) { |
103 | 103 | self::$Modules = array( |
104 | 104 | 'login' => self::$Modules['login'], |
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php |
— | — | @@ -186,13 +186,9 @@ |
187 | 187 | |
188 | 188 | private function extractRowInfo($row) { |
189 | 189 | |
190 | | - $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
191 | | - if (!$title->userCanRead()) |
192 | | - return false; |
193 | | - |
194 | 190 | $vals = array(); |
195 | 191 | $vals['pageid'] = intval($row->page_id); |
196 | | - ApiQueryBase :: addTitleInfo($vals, $title); |
| 192 | + ApiQueryBase :: addTitleInfo($vals, Title :: makeTitle($row->page_namespace, $row->page_title)); |
197 | 193 | |
198 | 194 | return $vals; |
199 | 195 | } |
— | — | @@ -239,7 +235,7 @@ |
240 | 236 | $rootNs = intval($continueList[0]); |
241 | 237 | if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) { |
242 | 238 | $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]); |
243 | | - if ($this->rootTitle && $this->rootTitle->userCanRead()) { |
| 239 | + if ($this->rootTitle) { |
244 | 240 | |
245 | 241 | $step = intval($continueList[2]); |
246 | 242 | if ($step === 1 || $step === 2) { |
— | — | @@ -287,7 +283,7 @@ |
288 | 284 | $rootNs = intval($continueList[0]); |
289 | 285 | if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) { |
290 | 286 | $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]); |
291 | | - if ($this->rootTitle && $this->rootTitle->userCanRead()) { |
| 287 | + if ($this->rootTitle) { |
292 | 288 | |
293 | 289 | $contID = intval($continueList[2]); |
294 | 290 | if ($contID !== 0) { |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -157,14 +157,10 @@ |
158 | 158 | if ($vals) |
159 | 159 | $data[] = $vals; |
160 | 160 | } else { |
161 | | - $title = Title :: makeTitle($row->rc_namespace, $row->rc_title); |
162 | | - // skip any pages that user has no rights to read |
163 | | - if ($title->userCanRead()) { |
164 | | - if ($allrev) { |
165 | | - $data[] = intval($row->rc_this_oldid); |
166 | | - } else { |
167 | | - $data[] = intval($row->rc_cur_id); |
168 | | - } |
| 161 | + if ($allrev) { |
| 162 | + $data[] = intval($row->rc_this_oldid); |
| 163 | + } else { |
| 164 | + $data[] = intval($row->rc_cur_id); |
169 | 165 | } |
170 | 166 | } |
171 | 167 | } |
— | — | @@ -184,10 +180,6 @@ |
185 | 181 | |
186 | 182 | private function extractRowInfo($row) { |
187 | 183 | |
188 | | - $title = Title :: makeTitle($row->rc_namespace, $row->rc_title); |
189 | | - if (!$title->userCanRead()) |
190 | | - return false; |
191 | | - |
192 | 184 | $vals = array (); |
193 | 185 | |
194 | 186 | if ($this->fld_ids) { |
— | — | @@ -196,7 +188,7 @@ |
197 | 189 | } |
198 | 190 | |
199 | 191 | if ($this->fld_title) |
200 | | - ApiQueryBase :: addTitleInfo($vals, $title); |
| 192 | + ApiQueryBase :: addTitleInfo($vals, Title :: makeTitle($row->rc_namespace, $row->rc_title)); |
201 | 193 | |
202 | 194 | if ($this->fld_user) { |
203 | 195 | $vals['user'] = $row->rc_user_text; |
Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -297,22 +297,18 @@ |
298 | 298 | // Store Title object in various data structures |
299 | 299 | $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
300 | 300 | |
301 | | - // skip any pages that user has no rights to read |
302 | | - if ($title->userCanRead()) { |
| 301 | + $pageId = intval($row->page_id); |
| 302 | + $this->mAllPages[$row->page_namespace][$row->page_title] = $pageId; |
| 303 | + $this->mTitles[] = $title; |
303 | 304 | |
304 | | - $pageId = intval($row->page_id); |
305 | | - $this->mAllPages[$row->page_namespace][$row->page_title] = $pageId; |
306 | | - $this->mTitles[] = $title; |
307 | | - |
308 | | - if ($this->mResolveRedirects && $row->page_is_redirect == '1') { |
309 | | - $this->mPendingRedirectIDs[$pageId] = $title; |
310 | | - } else { |
311 | | - $this->mGoodTitles[$pageId] = $title; |
312 | | - } |
313 | | - |
314 | | - foreach ($this->mRequestedPageFields as $fieldName => & $fieldValues) |
315 | | - $fieldValues[$pageId] = $row-> $fieldName; |
| 305 | + if ($this->mResolveRedirects && $row->page_is_redirect == '1') { |
| 306 | + $this->mPendingRedirectIDs[$pageId] = $title; |
| 307 | + } else { |
| 308 | + $this->mGoodTitles[$pageId] = $title; |
316 | 309 | } |
| 310 | + |
| 311 | + foreach ($this->mRequestedPageFields as $fieldName => & $fieldValues) |
| 312 | + $fieldValues[$pageId] = $row-> $fieldName; |
317 | 313 | } |
318 | 314 | |
319 | 315 | public function finishPageSetGeneration() { |
— | — | @@ -595,8 +591,6 @@ |
596 | 592 | // Validation |
597 | 593 | if ($titleObj->getNamespace() < 0) |
598 | 594 | $this->dieUsage("No support for special page $titleString has been implemented", 'unsupportednamespace'); |
599 | | - if (!$titleObj->userCanRead()) |
600 | | - $this->dieUsage("No read permission for $titleString", 'titleaccessdenied'); |
601 | 595 | |
602 | 596 | $linkBatch->addObj($titleObj); |
603 | 597 | } |
Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -128,13 +128,9 @@ |
129 | 129 | return $res; |
130 | 130 | } |
131 | 131 | |
132 | | - public static function addTitleInfo(&$arr, $title, $includeRestricted=false, $prefix='') { |
133 | | - if ($includeRestricted || $title->userCanRead()) { |
134 | | - $arr[$prefix . 'ns'] = intval($title->getNamespace()); |
135 | | - $arr[$prefix . 'title'] = $title->getPrefixedText(); |
136 | | - } |
137 | | - if (!$title->userCanRead()) |
138 | | - $arr[$prefix . 'inaccessible'] = ""; |
| 132 | + public static function addTitleInfo(&$arr, $title, $prefix='') { |
| 133 | + $arr[$prefix . 'ns'] = intval($title->getNamespace()); |
| 134 | + $arr[$prefix . 'title'] = $title->getPrefixedText(); |
139 | 135 | } |
140 | 136 | |
141 | 137 | /** |
Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -90,6 +90,15 @@ |
91 | 91 | $this->fld_user = true; |
92 | 92 | } |
93 | 93 | if (isset ($prop['content'])) { |
| 94 | + |
| 95 | + // For each page we will request, the user must have read rights for that page |
| 96 | + foreach ($pageSet->getGoodTitles() as $title) { |
| 97 | + if( !$title->userCanRead() ) |
| 98 | + $this->dieUsage( |
| 99 | + 'The current user is not allowed to read ' . $title->getPrefixedText(), |
| 100 | + 'accessdenied'); |
| 101 | + } |
| 102 | + |
94 | 103 | $this->addTables('text'); |
95 | 104 | $this->addWhere('rev_text_id=old_id'); |
96 | 105 | $this->addFields('old_id'); |
— | — | @@ -132,7 +141,7 @@ |
133 | 142 | |
134 | 143 | // There is only one ID, use it |
135 | 144 | $this->addWhereFld('rev_page', current(array_keys($pageSet->getGoodTitles()))); |
136 | | - |
| 145 | + |
137 | 146 | if(!is_null($user)) { |
138 | 147 | $this->addWhereFld('rev_user_text', $user); |
139 | 148 | } elseif (!is_null( $excludeuser)) { |
Index: trunk/phase3/includes/api/ApiQueryCategories.php |
— | — | @@ -95,11 +95,9 @@ |
96 | 96 | } |
97 | 97 | |
98 | 98 | $title = Title :: makeTitle(NS_CATEGORY, $row->cl_to); |
99 | | - // do not check userCanRead() -- page content is already accessible, |
100 | | - // and category is listed there. |
101 | 99 | |
102 | 100 | $vals = array(); |
103 | | - ApiQueryBase :: addTitleInfo($vals, $title, true); |
| 101 | + ApiQueryBase :: addTitleInfo($vals, $title); |
104 | 102 | if ($fld_sortkey) |
105 | 103 | $vals['sortkey'] = $row->cl_sortkey; |
106 | 104 | |
— | — | @@ -114,9 +112,7 @@ |
115 | 113 | |
116 | 114 | $titles = array(); |
117 | 115 | while ($row = $db->fetchObject($res)) { |
118 | | - $title = Title :: makeTitle(NS_CATEGORY, $row->cl_to); |
119 | | - if($title->userCanRead()) |
120 | | - $titles[] = $title; |
| 116 | + $titles[] = Title :: makeTitle(NS_CATEGORY, $row->cl_to); |
121 | 117 | } |
122 | 118 | $resultPageSet->populateFromTitles($titles); |
123 | 119 | } |
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -100,19 +100,17 @@ |
101 | 101 | $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys |
102 | 102 | |
103 | 103 | if (is_null($resultPageSet)) { |
104 | | - $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
105 | | - if ($title->userCanRead()) { |
106 | | - $vals = array(); |
107 | | - if ($fld_ids) |
108 | | - $vals['pageid'] = intval($row->page_id); |
109 | | - if ($fld_title) { |
110 | | - $vals['ns'] = intval($title->getNamespace()); |
111 | | - $vals['title'] = $title->getPrefixedText(); |
112 | | - } |
113 | | - if ($fld_sortkey) |
114 | | - $vals['sortkey'] = $row->cl_sortkey; |
115 | | - $data[] = $vals; |
| 104 | + $vals = array(); |
| 105 | + if ($fld_ids) |
| 106 | + $vals['pageid'] = intval($row->page_id); |
| 107 | + if ($fld_title) { |
| 108 | + $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
| 109 | + $vals['ns'] = intval($title->getNamespace()); |
| 110 | + $vals['title'] = $title->getPrefixedText(); |
116 | 111 | } |
| 112 | + if ($fld_sortkey) |
| 113 | + $vals['sortkey'] = $row->cl_sortkey; |
| 114 | + $data[] = $vals; |
117 | 115 | } else { |
118 | 116 | $resultPageSet->processDbRow($row); |
119 | 117 | } |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -172,10 +172,6 @@ |
173 | 173 | */ |
174 | 174 | private function extractRowInfo($row) { |
175 | 175 | |
176 | | - $title = Title :: makeTitle($row->page_namespace, $row->page_title); |
177 | | - if (!$title->userCanRead()) |
178 | | - return false; |
179 | | - |
180 | 176 | $vals = array(); |
181 | 177 | |
182 | 178 | if ($this->fld_ids) { |
— | — | @@ -185,7 +181,8 @@ |
186 | 182 | } |
187 | 183 | |
188 | 184 | if ($this->fld_title) |
189 | | - ApiQueryBase :: addTitleInfo($vals, $title); |
| 185 | + ApiQueryBase :: addTitleInfo($vals, |
| 186 | + Title :: makeTitle($row->page_namespace, $row->page_title)); |
190 | 187 | |
191 | 188 | if ($this->fld_timestamp) |
192 | 189 | $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rev_timestamp); |
Index: trunk/phase3/includes/api/ApiQueryImages.php |
— | — | @@ -77,12 +77,8 @@ |
78 | 78 | $lastId = $row->il_from; |
79 | 79 | } |
80 | 80 | |
81 | | - $title = Title :: makeTitle(NS_IMAGE, $row->il_to); |
82 | | - // do not check userCanRead() -- page content is already accessible, |
83 | | - // and images are listed there. |
84 | | - |
85 | 81 | $vals = array(); |
86 | | - ApiQueryBase :: addTitleInfo($vals, $title, true); |
| 82 | + ApiQueryBase :: addTitleInfo($vals, Title :: makeTitle(NS_IMAGE, $row->il_to)); |
87 | 83 | $data[] = $vals; |
88 | 84 | } |
89 | 85 | |
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php |
— | — | @@ -108,13 +108,10 @@ |
109 | 109 | } |
110 | 110 | |
111 | 111 | private function extractRowInfo($row) { |
112 | | - $title = Title :: makeTitle($row->log_namespace, $row->log_title); |
113 | | - if (!$title->userCanRead()) |
114 | | - return false; |
115 | | - |
116 | 112 | $vals = array(); |
117 | 113 | |
118 | 114 | $vals['pageid'] = intval($row->page_id); |
| 115 | + $title = Title :: makeTitle($row->log_namespace, $row->log_title); |
119 | 116 | ApiQueryBase :: addTitleInfo($vals, $title); |
120 | 117 | $vals['type'] = $row->log_type; |
121 | 118 | $vals['action'] = $row->log_action; |
— | — | @@ -126,7 +123,7 @@ |
127 | 124 | if (isset ($params[0])) { |
128 | 125 | $title = Title :: newFromText($params[0]); |
129 | 126 | if ($title) { |
130 | | - ApiQueryBase :: addTitleInfo($vals, $title, false, "new_"); |
| 127 | + ApiQueryBase :: addTitleInfo($vals, $title, "new_"); |
131 | 128 | $params = null; |
132 | 129 | } |
133 | 130 | } |