Index: trunk/extensions/FlaggedRevs/FRUserActivity.php |
— | — | @@ -55,6 +55,16 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | /* |
| 59 | + * Check is someone is currently reviewing a page |
| 60 | + * @param int $pageId |
| 61 | + * @return bool |
| 62 | + */ |
| 63 | + public static function pageIsUnderReview( $pageId ) { |
| 64 | + $m = self::getUserReviewingPage( $pageId ); |
| 65 | + return ( $m[0] !== null ); |
| 66 | + } |
| 67 | + |
| 68 | + /* |
59 | 69 | * Set the flag for who is reviewing a page if not already set by someone |
60 | 70 | * @param User $user |
61 | 71 | * @param int $pageId |
— | — | @@ -112,6 +122,17 @@ |
113 | 123 | } |
114 | 124 | |
115 | 125 | /* |
| 126 | + * Check is someone is currently reviewing a diff |
| 127 | + * @param int $oldId |
| 128 | + * @param int $newId |
| 129 | + * @return bool |
| 130 | + */ |
| 131 | + public static function diffIsUnderReview( $oldId, $newId ) { |
| 132 | + $m = self::getUserReviewingDiff( $oldId, $newId ); |
| 133 | + return ( $m[0] !== null ); |
| 134 | + } |
| 135 | + |
| 136 | + /* |
116 | 137 | * Set the flag for who is reviewing a diff if not already set by someone |
117 | 138 | * @param User $user |
118 | 139 | * @param int $pageId |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryFlagged.php |
— | — | @@ -45,15 +45,15 @@ |
46 | 46 | |
47 | 47 | $result = $this->getResult(); |
48 | 48 | foreach( $res as $row ) { |
49 | | - $pageid = $row->fp_page_id; |
50 | 49 | $data = array( |
51 | | - 'stable_revid' => intval( $row->fp_stable ), |
52 | | - 'level' => intval( $row->fp_quality ), |
53 | | - 'level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
| 50 | + 'stable_revid' => intval( $row->fp_stable ), |
| 51 | + 'level' => intval( $row->fp_quality ), |
| 52 | + 'level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
54 | 53 | ); |
55 | | - if ( $row->fp_pending_since ) |
| 54 | + if ( $row->fp_pending_since ) { |
56 | 55 | $data['pending_since'] = wfTimestamp( TS_ISO_8601, $row->fp_pending_since ); |
57 | | - $result->addValue( array( 'query', 'pages', $pageid ), 'flagged', $data ); |
| 56 | + } |
| 57 | + $result->addValue( array( 'query', 'pages', $row->fp_page_id ), 'flagged', $data ); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryOldreviewedpages.php |
— | — | @@ -48,15 +48,18 @@ |
49 | 49 | $this->addTables( array( 'page', 'flaggedpages', 'revision' ) ); |
50 | 50 | $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
51 | 51 | $useIndex = array( 'flaggedpages' => 'fp_pending_since' ); |
52 | | - if ( $params['filterredir'] == 'redirects' ) |
| 52 | + if ( $params['filterredir'] == 'redirects' ) { |
53 | 53 | $this->addWhereFld( 'page_is_redirect', 1 ); |
54 | | - if ( $params['filterredir'] == 'nonredirects' ) |
| 54 | + } |
| 55 | + if ( $params['filterredir'] == 'nonredirects' ) { |
55 | 56 | $this->addWhereFld( 'page_is_redirect', 0 ); |
56 | | - if ( $params['maxsize'] !== null ) |
| 57 | + } |
| 58 | + if ( $params['maxsize'] !== null ) { |
57 | 59 | # Get absolute difference for comparison. ABS(x-y) |
58 | 60 | # is broken due to mysql unsigned int design. |
59 | 61 | $this->addWhere( 'GREATEST(page_len,rev_len)-LEAST(page_len,rev_len) <= ' . |
60 | 62 | intval( $params['maxsize'] ) ); |
| 63 | + } |
61 | 64 | if ( $params['filterwatched'] == 'watched' ) { |
62 | 65 | if ( !( $uid = $wgUser->getId() ) ) { |
63 | 66 | $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
— | — | @@ -72,6 +75,7 @@ |
73 | 76 | $this->addWhereFld( 'cl_to', $params['category'] ); |
74 | 77 | $useIndex['categorylinks'] = 'cl_from'; |
75 | 78 | } |
| 79 | + |
76 | 80 | $this->addWhereRange( |
77 | 81 | 'fp_pending_since', |
78 | 82 | $params['dir'], |
— | — | @@ -80,13 +84,13 @@ |
81 | 85 | ); |
82 | 86 | $this->addWhere( 'page_id=fp_page_id' ); |
83 | 87 | $this->addWhere( 'rev_id=fp_stable' ); |
84 | | - if ( !isset( $params['start'] ) && !isset( $params['end'] ) ) |
| 88 | + if ( !isset( $params['start'] ) && !isset( $params['end'] ) ) { |
85 | 89 | $this->addWhere( 'fp_pending_since IS NOT NULL' ); |
86 | | - |
| 90 | + } |
87 | 91 | $this->addOption( 'USE INDEX', $useIndex ); |
88 | 92 | |
89 | 93 | if ( is_null( $resultPageSet ) ) { |
90 | | - $this->addFields( array ( |
| 94 | + $this->addFields( array( |
91 | 95 | 'page_id', |
92 | 96 | 'page_namespace', |
93 | 97 | 'page_title', |
— | — | @@ -106,7 +110,7 @@ |
107 | 111 | $this->addOption( 'LIMIT', $limit + 1 ); |
108 | 112 | $res = $this->select( __METHOD__ ); |
109 | 113 | |
110 | | - $data = array (); |
| 114 | + $data = array(); |
111 | 115 | $count = 0; |
112 | 116 | foreach( $res as $row ) { |
113 | 117 | if ( ++$count > $limit ) { |
— | — | @@ -121,19 +125,19 @@ |
122 | 126 | |
123 | 127 | if ( is_null( $resultPageSet ) ) { |
124 | 128 | $title = Title::newFromRow( $row ); |
125 | | - $key = wfMemcKey( 'stableDiffs', 'underReview', |
| 129 | + $underReview = FRUserActivity::diffIsUnderReview( |
126 | 130 | $row->fp_stable, $row->page_latest ); |
127 | 131 | $data[] = array( |
128 | | - 'pageid' => intval( $row->page_id ), |
129 | | - 'ns' => intval( $title->getNamespace() ), |
130 | | - 'title' => $title->getPrefixedText(), |
131 | | - 'revid' => intval( $row->page_latest ), |
132 | | - 'stable_revid' => intval( $row->fp_stable ), |
133 | | - 'pending_since' => wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
134 | | - 'flagged_level' => intval( $row->fp_quality ), |
| 132 | + 'pageid' => intval( $row->page_id ), |
| 133 | + 'ns' => intval( $row->page_namespace ), |
| 134 | + 'title' => $title->getPrefixedText(), |
| 135 | + 'revid' => intval( $row->page_latest ), |
| 136 | + 'stable_revid' => intval( $row->fp_stable ), |
| 137 | + 'pending_since' => wfTimestamp( TS_ISO_8601, $row->fp_pending_since ), |
| 138 | + 'flagged_level' => intval( $row->fp_quality ), |
135 | 139 | 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ), |
136 | | - 'diff_size' => (int)$row->page_len - (int)$row->rev_len, |
137 | | - 'under_review' => (bool)$wgMemc->get( $key ) |
| 140 | + 'diff_size' => (int)$row->page_len - (int)$row->rev_len, |
| 141 | + 'under_review' => $underReview |
138 | 142 | ); |
139 | 143 | } else { |
140 | 144 | $resultPageSet->processDbRow( $row ); |
— | — | @@ -158,51 +162,50 @@ |
159 | 163 | |
160 | 164 | public function getAllowedParams() { |
161 | 165 | $namespaces = FlaggedRevs::getReviewNamespaces(); |
162 | | - return array ( |
163 | | - 'start' => array ( |
| 166 | + return array( |
| 167 | + 'start' => array( |
164 | 168 | ApiBase::PARAM_TYPE => 'timestamp' |
165 | 169 | ), |
166 | | - 'end' => array ( |
| 170 | + 'end' => array( |
167 | 171 | ApiBase::PARAM_TYPE => 'timestamp' |
168 | 172 | ), |
169 | | - 'dir' => array ( |
| 173 | + 'dir' => array( |
170 | 174 | ApiBase::PARAM_DFLT => 'newer', |
171 | 175 | ApiBase::PARAM_TYPE => array( 'newer', 'older' ) |
172 | 176 | ), |
173 | | - 'maxsize' => array ( |
| 177 | + 'maxsize' => array( |
174 | 178 | ApiBase::PARAM_TYPE => 'integer', |
175 | 179 | ApiBase::PARAM_DFLT => null, |
176 | 180 | ApiBase::PARAM_MIN => 0 |
177 | 181 | ), |
178 | | - 'filterwatched' => array ( |
| 182 | + 'filterwatched' => array( |
179 | 183 | ApiBase::PARAM_DFLT => 'all', |
180 | 184 | ApiBase::PARAM_TYPE => array( 'watched', 'all' ) |
181 | 185 | ), |
182 | | - 'namespace' => array ( |
183 | | - ApiBase::PARAM_DFLT => !$namespaces ? |
184 | | - NS_MAIN : $namespaces[0], |
| 186 | + 'namespace' => array( |
| 187 | + ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
185 | 188 | ApiBase::PARAM_TYPE => 'namespace', |
186 | 189 | ApiBase::PARAM_ISMULTI => true, |
187 | 190 | ), |
188 | 191 | 'category' => array( |
189 | 192 | ApiBase::PARAM_TYPE => 'string' |
190 | 193 | ), |
191 | | - 'filterredir' => array ( |
| 194 | + 'filterredir' => array( |
192 | 195 | ApiBase::PARAM_DFLT => 'all', |
193 | 196 | ApiBase::PARAM_TYPE => array( 'redirects', 'nonredirects', 'all' ) |
194 | 197 | ), |
195 | | - 'limit' => array ( |
| 198 | + 'limit' => array( |
196 | 199 | ApiBase::PARAM_DFLT => 10, |
197 | 200 | ApiBase::PARAM_TYPE => 'limit', |
198 | | - ApiBase::PARAM_MIN => 1, |
199 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 201 | + ApiBase::PARAM_MIN => 1, |
| 202 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
200 | 203 | ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
201 | 204 | ) |
202 | 205 | ); |
203 | 206 | } |
204 | 207 | |
205 | 208 | public function getParamDescription() { |
206 | | - return array ( |
| 209 | + return array( |
207 | 210 | 'start' => 'Start listing at this timestamp.', |
208 | 211 | 'end' => 'Stop listing at this timestamp.', |
209 | 212 | 'namespace' => 'The namespaces to enumerate.', |
— | — | @@ -220,12 +223,9 @@ |
221 | 224 | } |
222 | 225 | |
223 | 226 | public function getDescription() { |
224 | | - return array( |
225 | | - 'Returns a list of pages, that have an outdated review flag,', |
226 | | - 'sorted by timestamp of the first unreviewed edit of that page.' |
227 | | - ); |
| 227 | + return 'Enumerates pages that have changes pending review'; |
228 | 228 | } |
229 | | - |
| 229 | + |
230 | 230 | public function getPossibleErrors() { |
231 | 231 | return array_merge( parent::getPossibleErrors(), array( |
232 | 232 | array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ), |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | } |
235 | 235 | |
236 | 236 | protected function getExamples() { |
237 | | - return array ( |
| 237 | + return array( |
238 | 238 | 'Show a list of pages with pending unreviewed changes', |
239 | 239 | ' api.php?action=query&list=oldreviewedpages&ornamespace=0', |
240 | 240 | 'Show info about some old reviewed pages', |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryReviewedpages.php |
— | — | @@ -46,12 +46,15 @@ |
47 | 47 | // Construct SQL Query |
48 | 48 | $this->addTables( array( 'page', 'flaggedpages' ) ); |
49 | 49 | $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
50 | | - if ( $params['filterredir'] == 'redirects' ) |
| 50 | + if ( $params['filterredir'] == 'redirects' ) { |
51 | 51 | $this->addWhereFld( 'page_is_redirect', 1 ); |
52 | | - if ( $params['filterredir'] == 'nonredirects' ) |
| 52 | + } |
| 53 | + if ( $params['filterredir'] == 'nonredirects' ) { |
53 | 54 | $this->addWhereFld( 'page_is_redirect', 0 ); |
54 | | - if ( $params['filterlevel'] !== null ) |
| 55 | + } |
| 56 | + if ( $params['filterlevel'] !== null ) { |
55 | 57 | $this->addWhereFld( 'fp_quality', $params['filterlevel'] ); |
| 58 | + } |
56 | 59 | $this->addWhereRange( |
57 | 60 | 'fp_page_id', |
58 | 61 | $params['dir'], |
— | — | @@ -97,11 +100,11 @@ |
98 | 101 | if ( is_null( $resultPageSet ) ) { |
99 | 102 | $title = Title::newFromRow( $row ); |
100 | 103 | $data[] = array( |
101 | | - 'pageid' => intval( $row->page_id ), |
102 | | - 'ns' => intval( $title->getNamespace() ), |
103 | | - 'title' => $title->getPrefixedText(), |
104 | | - 'revid' => intval( $row->page_latest ), |
105 | | - 'stable_revid' => intval( $row->fp_stable ), |
| 104 | + 'pageid' => intval( $row->page_id ), |
| 105 | + 'ns' => intval( $title->getNamespace() ), |
| 106 | + 'title' => $title->getPrefixedText(), |
| 107 | + 'revid' => intval( $row->page_latest ), |
| 108 | + 'stable_revid' => intval( $row->fp_stable ), |
106 | 109 | 'flagged_level' => intval( $row->fp_quality ), |
107 | 110 | 'flagged_level_text' => FlaggedRevs::getQualityLevelText( $row->fp_quality ) |
108 | 111 | ); |
— | — | @@ -169,13 +172,13 @@ |
170 | 173 | |
171 | 174 | public function getParamDescription() { |
172 | 175 | return array ( |
173 | | - 'start' => 'Start listing at this page id.', |
174 | | - 'end' => 'Stop listing at this page id.', |
175 | | - 'namespace' => 'The namespaces to enumerate.', |
176 | | - 'filterredir' => 'How to filter for redirects', |
177 | | - 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
178 | | - 'limit' => 'How many total pages to return.', |
179 | | - 'dir' => array( |
| 176 | + 'start' => 'Start listing at this page id.', |
| 177 | + 'end' => 'Stop listing at this page id.', |
| 178 | + 'namespace' => 'The namespaces to enumerate.', |
| 179 | + 'filterredir' => 'How to filter for redirects', |
| 180 | + 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
| 181 | + 'limit' => 'How many total pages to return.', |
| 182 | + 'dir' => array( |
180 | 183 | 'In which direction to list.', |
181 | 184 | '*newer: list the newest pages first', |
182 | 185 | '*older: list the oldest pages first' |
— | — | @@ -184,10 +187,7 @@ |
185 | 188 | } |
186 | 189 | |
187 | 190 | public function getDescription() { |
188 | | - return array( |
189 | | - 'Returns a list of pages, that have been reviewed,', |
190 | | - 'sorted by page id.' |
191 | | - ); |
| 191 | + return 'Enumerates pages that have a reviewed version'; |
192 | 192 | } |
193 | 193 | |
194 | 194 | protected function getExamples() { |
Index: trunk/extensions/FlaggedRevs/api/ApiQueryUnreviewedpages.php |
— | — | @@ -47,10 +47,13 @@ |
48 | 48 | // Construct SQL Query |
49 | 49 | $this->addTables( array( 'page', 'flaggedpages' ) ); |
50 | 50 | $this->addWhereFld( 'page_namespace', $params['namespace'] ); |
51 | | - if ( $params['filterredir'] == 'redirects' ) |
| 51 | + if ( $params['filterredir'] == 'redirects' ) { |
52 | 52 | $this->addWhereFld( 'page_is_redirect', 1 ); |
53 | | - if ( $params['filterredir'] == 'nonredirects' ) |
| 53 | + } |
| 54 | + if ( $params['filterredir'] == 'nonredirects' ) { |
54 | 55 | $this->addWhereFld( 'page_is_redirect', 0 ); |
| 56 | + } |
| 57 | + |
55 | 58 | $this->addWhereRange( |
56 | 59 | 'page_title', |
57 | 60 | 'newer', |
— | — | @@ -95,13 +98,12 @@ |
96 | 99 | |
97 | 100 | if ( is_null( $resultPageSet ) ) { |
98 | 101 | $title = Title::newFromRow( $row ); |
99 | | - $key = wfMemcKey( 'unreviewedPages', 'underReview', $row->page_id ); |
100 | 102 | $data[] = array( |
101 | 103 | 'pageid' => intval( $row->page_id ), |
102 | 104 | 'ns' => intval( $title->getNamespace() ), |
103 | 105 | 'title' => $title->getPrefixedText(), |
104 | 106 | 'revid' => intval( $row->page_latest ), |
105 | | - 'under_review' => (bool)$wgMemc->get( $key ) |
| 107 | + 'under_review' => FRUserActivity::pageIsUnderReview( $row->page_id ) |
106 | 108 | ); |
107 | 109 | } else { |
108 | 110 | $resultPageSet->processDbRow( $row ); |
— | — | @@ -129,8 +131,7 @@ |
130 | 132 | ApiBase::PARAM_TYPE => 'string' |
131 | 133 | ), |
132 | 134 | 'namespace' => array ( |
133 | | - ApiBase::PARAM_DFLT => !$namespaces ? |
134 | | - NS_MAIN : $namespaces[0], |
| 135 | + ApiBase::PARAM_DFLT => !$namespaces ? NS_MAIN : $namespaces[0], |
135 | 136 | ApiBase::PARAM_TYPE => 'namespace', |
136 | 137 | ApiBase::PARAM_ISMULTI => true, |
137 | 138 | ), |
— | — | @@ -160,20 +161,17 @@ |
161 | 162 | |
162 | 163 | public function getParamDescription() { |
163 | 164 | return array ( |
164 | | - 'start' => 'Start listing at this page title.', |
165 | | - 'end' => 'Stop listing at this page title.', |
166 | | - 'namespace' => 'The namespaces to enumerate.', |
167 | | - 'filterredir' => 'How to filter for redirects', |
168 | | - 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
169 | | - 'limit' => 'How many total pages to return.', |
| 165 | + 'start' => 'Start listing at this page title.', |
| 166 | + 'end' => 'Stop listing at this page title.', |
| 167 | + 'namespace' => 'The namespaces to enumerate.', |
| 168 | + 'filterredir' => 'How to filter for redirects', |
| 169 | + 'filterlevel' => 'How to filter by quality (0=checked,1=quality)', |
| 170 | + 'limit' => 'How many total pages to return.', |
170 | 171 | ); |
171 | 172 | } |
172 | 173 | |
173 | 174 | public function getDescription() { |
174 | | - return array( |
175 | | - 'Returns a list of pages, that have not been reviewed (to "filterlevel"),', |
176 | | - 'sorted by page title.' |
177 | | - ); |
| 175 | + return 'Enumerates pages that have not been reviewed to a given quality level ("filterlevel")'; |
178 | 176 | } |
179 | 177 | |
180 | 178 | protected function getExamples() { |
Index: trunk/extensions/FlaggedRevs/api/ApiStabilize.php |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | } |
253 | 253 | |
254 | 254 | public function getDescription() { |
255 | | - return 'Configure review-protection settings.'; |
| 255 | + return 'Configure review-protection settings for a page'; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // @TODO: fill in stabilize_* values from PageStabilityProtectForm |