Index: trunk/extensions/ApprovedRevs/SpecialApprovedRevs.php |
— | — | @@ -140,6 +140,7 @@ |
141 | 141 | $dbr = wfGetDB( DB_SLAVE ); |
142 | 142 | $approved_revs = $dbr->tableName( 'approved_revs' ); |
143 | 143 | $page = $dbr->tableName( 'page' ); |
| 144 | + $page_props = $dbr->tableName( 'page_props' ); |
144 | 145 | |
145 | 146 | if ( $this->mMode == 'notlatest' ) { |
146 | 147 | return "SELECT 'Page' AS type, |
— | — | @@ -148,21 +149,30 @@ |
149 | 150 | p.page_latest AS latest_id |
150 | 151 | FROM $approved_revs ar JOIN $page p |
151 | 152 | 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'))"; |
153 | 157 | } elseif ( $this->mMode == 'unapproved' ) { |
154 | 158 | return "SELECT 'Page' AS type, |
155 | 159 | p.page_id AS id, |
156 | 160 | p.page_latest AS latest_id |
157 | 161 | FROM $approved_revs ar RIGHT OUTER JOIN $page p |
158 | 162 | 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'))"; |
160 | 167 | } else { // all approved pages |
161 | 168 | return "SELECT 'Page' AS type, |
162 | 169 | p.page_id AS id, |
163 | 170 | ar.rev_id AS rev_id, |
164 | 171 | p.page_latest AS latest_id |
165 | 172 | 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'))"; |
167 | 177 | } |
168 | 178 | } |
169 | 179 | |
— | — | @@ -174,10 +184,15 @@ |
175 | 185 | */ |
176 | 186 | function getQueryInfo() { |
177 | 187 | global $egApprovedRevsNamespaces; |
178 | | - |
| 188 | + |
| 189 | + $namespacesString = '(' . implode( ',', $egApprovedRevsNamespaces ) . ')'; |
179 | 190 | if ( $this->mMode == 'notlatest' ) { |
180 | 191 | 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 | + ), |
182 | 197 | 'fields' => array( |
183 | 198 | 'p.page_id AS id', |
184 | 199 | 'ar.rev_id AS rev_id', |
— | — | @@ -186,30 +201,41 @@ |
187 | 202 | 'join_conds' => array( |
188 | 203 | 'p' => array( |
189 | 204 | 'JOIN', 'ar.page_id=p.page_id' |
190 | | - ) |
| 205 | + ), |
| 206 | + 'pp' => array( |
| 207 | + 'LEFT OUTER JOIN', 'ar.page_id=pp_page' |
| 208 | + ), |
191 | 209 | ), |
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'))", |
196 | 211 | ); |
197 | 212 | } elseif ( $this->mMode == 'unapproved' ) { |
198 | 213 | 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 | + ), |
201 | 223 | 'join_conds' => array( |
202 | 224 | 'p' => array( |
203 | 225 | 'RIGHT OUTER JOIN', 'ar.page_id=p.page_id' |
204 | | - ) |
| 226 | + ), |
| 227 | + 'pp' => array( |
| 228 | + 'LEFT OUTER JOIN', 'ar.page_id=pp_page' |
| 229 | + ), |
205 | 230 | ), |
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'))", |
210 | 232 | ); |
211 | 233 | } else { // all approved pages |
212 | 234 | 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 | + ), |
214 | 240 | 'fields' => array( |
215 | 241 | 'p.page_id AS id', |
216 | 242 | 'ar.rev_id AS rev_id', |
— | — | @@ -218,9 +244,12 @@ |
219 | 245 | 'join_conds' => array( |
220 | 246 | 'p' => array( |
221 | 247 | '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 | + ), |
224 | 252 | ), |
| 253 | + 'conds' => "(p.page_namespace IN $namespacesString) OR (pp_propname = 'approvedrevs' AND pp_value = 'y')", |
225 | 254 | ); |
226 | 255 | } |
227 | 256 | } |