Index: trunk/extensions/Contributors/Contributors.page.php |
— | — | @@ -144,16 +144,21 @@ |
145 | 145 | $contributors = $wgMemc->get( $k ); |
146 | 146 | if( !$contributors ) { |
147 | 147 | $contributors = array(); |
148 | | - $dbr =& wfGetDB( DB_SLAVE ); |
149 | | - $rev = $dbr->tableName( 'revision' ); |
150 | | - $aid = $this->target->getArticleId(); |
151 | | - $sql = "SELECT COUNT(*) AS count, rev_user, rev_user_text FROM {$rev} WHERE rev_page = {$aid}"; |
152 | | - $groupby = "GROUP BY rev_user_text"; |
153 | | - if( !$dbr->implicitGroupby() ) |
154 | | - $groupby .= ",rev_user"; |
155 | | - $orderby = "ORDER BY count DESC"; |
156 | | - $sql .= " $groupby $orderby"; |
157 | | - $res = $dbr->query( $sql, __METHOD__ ); |
| 148 | + $dbr = wfGetDB( DB_SLAVE ); |
| 149 | + $res = $dbr->select( |
| 150 | + 'revision', |
| 151 | + array( |
| 152 | + 'COUNT(*) AS count', |
| 153 | + 'rev_user', |
| 154 | + 'rev_user_text', |
| 155 | + ), |
| 156 | + $this->getConditions(), |
| 157 | + __METHOD__, |
| 158 | + array( |
| 159 | + 'GROUP BY' => 'rev_user_text', |
| 160 | + 'ORDER BY' => 'count DESC', |
| 161 | + ) |
| 162 | + ); |
158 | 163 | if( $res && $dbr->numRows( $res ) > 0 ) { |
159 | 164 | while( $row = $dbr->fetchObject( $res ) ) |
160 | 165 | $contributors[ $row->rev_user_text ] = array( $row->rev_user, $row->count ); |
— | — | @@ -165,6 +170,19 @@ |
166 | 171 | } |
167 | 172 | |
168 | 173 | /** |
| 174 | + * Get conditions for the main query |
| 175 | + * |
| 176 | + * @return array |
| 177 | + */ |
| 178 | + private function getConditions() { |
| 179 | + global $wgVersion; |
| 180 | + $conds['rev_page'] = $this->target->getArticleId(); |
| 181 | + if( version_compare( $wgVersion, '1.11alpha', '>=' ) ) |
| 182 | + $conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0'; |
| 183 | + return $conds; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
169 | 187 | * Given the web request, and a possible override from a subpage, work |
170 | 188 | * out which we want to use |
171 | 189 | * |