r88283 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88282‎ | r88283 | r88284 >
Date:00:59, 17 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
Fix to also display pages that are approvable because they contain the __APPROVEDREVS__ magic word
Modified paths:
  • /trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php
@@ -140,6 +140,7 @@
141141 $dbr = wfGetDB( DB_SLAVE );
142142 $approved_revs = $dbr->tableName( 'approved_revs' );
143143 $page = $dbr->tableName( 'page' );
 144+ $page_props = $dbr->tableName( 'page_props' );
144145
145146 if ( $this->mMode == 'notlatest' ) {
146147 return "SELECT 'Page' AS type,
@@ -148,21 +149,30 @@
149150 p.page_latest AS latest_id
150151 FROM $approved_revs ar JOIN $page p
151152 ON ar.page_id = p.page_id
152 - WHERE p.page_latest != ar.rev_id AND $nsCond";
 153+ LEFT OUTER JOIN $page_props pp
 154+ ON ar.page_id = pp_page
 155+ WHERE p.page_latest != ar.rev_id
 156+ AND ($nsCond OR (pp_propname = 'approvedrevs' AND pp_value = 'y'))";
153157 } elseif ( $this->mMode == 'unapproved' ) {
154158 return "SELECT 'Page' AS type,
155159 p.page_id AS id,
156160 p.page_latest AS latest_id
157161 FROM $approved_revs ar RIGHT OUTER JOIN $page p
158162 ON ar.page_id = p.page_id
159 - WHERE ar.page_id IS NULL AND $nsCond";
 163+ LEFT OUTER JOIN $page_props pp
 164+ ON ar.page_id = pp_page
 165+ WHERE ar.page_id IS NULL
 166+ AND ($nsCond OR (pp_propname = 'approvedrevs' AND pp_value = 'y'))";
160167 } else { // all approved pages
161168 return "SELECT 'Page' AS type,
162169 p.page_id AS id,
163170 ar.rev_id AS rev_id,
164171 p.page_latest AS latest_id
165172 FROM $approved_revs ar JOIN $page p
166 - ON ar.page_id = p.page_id AND $nsCond";
 173+ ON ar.page_id = p.page_id
 174+ LEFT OUTER JOIN $page_props pp
 175+ ON ar.page_id = pp_page
 176+ WHERE ($nsCond OR (pp_propname = 'approvedrevs' AND pp_value = 'y'))";
167177 }
168178 }
169179
@@ -174,10 +184,15 @@
175185 */
176186 function getQueryInfo() {
177187 global $egApprovedRevsNamespaces;
178 -
 188+
 189+ $namespacesString = '(' . implode( ',', $egApprovedRevsNamespaces ) . ')';
179190 if ( $this->mMode == 'notlatest' ) {
180191 return array(
181 - 'tables' => array( 'ar' => 'approved_revs', 'p' => 'page' ),
 192+ 'tables' => array(
 193+ 'ar' => 'approved_revs',
 194+ 'p' => 'page',
 195+ 'pp' => 'page_props',
 196+ ),
182197 'fields' => array(
183198 'p.page_id AS id',
184199 'ar.rev_id AS rev_id',
@@ -186,30 +201,41 @@
187202 'join_conds' => array(
188203 'p' => array(
189204 'JOIN', 'ar.page_id=p.page_id'
190 - )
 205+ ),
 206+ 'pp' => array(
 207+ 'LEFT OUTER JOIN', 'ar.page_id=pp_page'
 208+ ),
191209 ),
192 - 'conds' => array(
193 - 'p.page_latest != ar.rev_id',
194 - 'p.page_namespace' => $egApprovedRevsNamespaces
195 - )
 210+ 'conds' => "p.page_latest != ar.rev_id AND ((p.page_namespace IN $namespacesString) OR (pp_propname = 'approvedrevs' AND pp_value = 'y'))",
196211 );
197212 } elseif ( $this->mMode == 'unapproved' ) {
198213 return array(
199 - 'tables' => array( 'ar' => 'approved_revs', 'p' => 'page' ),
200 - 'fields' => array( 'p.page_id AS id', 'p.page_latest AS latest_id' ),
 214+ 'tables' => array(
 215+ 'ar' => 'approved_revs',
 216+ 'p' => 'page',
 217+ 'pp' => 'page_props',
 218+ ),
 219+ 'fields' => array(
 220+ 'p.page_id AS id',
 221+ 'p.page_latest AS latest_id'
 222+ ),
201223 'join_conds' => array(
202224 'p' => array(
203225 'RIGHT OUTER JOIN', 'ar.page_id=p.page_id'
204 - )
 226+ ),
 227+ 'pp' => array(
 228+ 'LEFT OUTER JOIN', 'ar.page_id=pp_page'
 229+ ),
205230 ),
206 - 'conds' => array(
207 - 'ar.page_id IS NULL',
208 - 'p.page_namespace' => $egApprovedRevsNamespaces
209 - )
 231+ 'conds' => "ar.page_id IS NULL AND ((p.page_namespace IN $namespacesString) OR (pp_propname = 'approvedrevs' AND pp_value = 'y'))",
210232 );
211233 } else { // all approved pages
212234 return array(
213 - 'tables' => array( 'ar' => 'approved_revs', 'p' => 'page' ),
 235+ 'tables' => array(
 236+ 'ar' => 'approved_revs',
 237+ 'p' => 'page',
 238+ 'pp' => 'page_props',
 239+ ),
214240 'fields' => array(
215241 'p.page_id AS id',
216242 'ar.rev_id AS rev_id',
@@ -218,9 +244,12 @@
219245 'join_conds' => array(
220246 'p' => array(
221247 'JOIN', 'ar.page_id=p.page_id',
222 - 'p.page_namespace' => $egApprovedRevsNamespaces
223 - )
 248+ ),
 249+ 'pp' => array(
 250+ 'LEFT OUTER JOIN', 'ar.page_id=pp_page'
 251+ ),
224252 ),
 253+ 'conds' => "(p.page_namespace IN $namespacesString) OR (pp_propname = 'approvedrevs' AND pp_value = 'y')",
225254 );
226255 }
227256 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r88284Small fix to r88283yaron01:22, 17 May 2011

Status & tagging log