Index: trunk/phase3/includes/QueryPage.php |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | function recache( $limit, $ignoreErrors = true ) { |
208 | 208 | $fname = get_class( $this ) . '::recache'; |
209 | 209 | $dbw = wfGetDB( DB_MASTER ); |
210 | | - $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); |
| 210 | + $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) ); |
211 | 211 | if ( !$dbw || !$dbr ) { |
212 | 212 | return false; |
213 | 213 | } |
— | — | @@ -229,30 +229,23 @@ |
230 | 230 | if ( $res ) { |
231 | 231 | $num = $dbr->numRows( $res ); |
232 | 232 | # Fetch results |
233 | | - $insertSql = "INSERT INTO $querycache (qc_type,qc_namespace,qc_title,qc_value) VALUES "; |
234 | | - $first = true; |
| 233 | + $vals = array(); |
235 | 234 | while ( $res && $row = $dbr->fetchObject( $res ) ) { |
236 | | - if ( $first ) { |
237 | | - $first = false; |
238 | | - } else { |
239 | | - $insertSql .= ','; |
240 | | - } |
241 | 235 | if ( isset( $row->value ) ) { |
242 | 236 | $value = intval( $row->value ); // @bug 14414 |
243 | 237 | } else { |
244 | 238 | $value = 0; |
245 | 239 | } |
246 | | - |
247 | | - $insertSql .= '(' . |
248 | | - $dbw->addQuotes( $row->type ) . ',' . |
249 | | - $dbw->addQuotes( $row->namespace ) . ',' . |
250 | | - $dbw->addQuotes( $row->title ) . ',' . |
251 | | - $dbw->addQuotes( $value ) . ')'; |
| 240 | + |
| 241 | + $vals[] = array('qc_type' => $row->type, |
| 242 | + 'qc_namespace' => $row->namespace, |
| 243 | + 'qc_title' => $row->title, |
| 244 | + 'qc_value' => $value); |
252 | 245 | } |
253 | 246 | |
254 | 247 | # Save results into the querycache table on the master |
255 | | - if ( !$first ) { |
256 | | - if ( !$dbw->query( $insertSql, $fname ) ) { |
| 248 | + if ( count( $vals ) ) { |
| 249 | + if ( !$dbw->insert( 'querycache', $vals, __METHOD__ ) { |
257 | 250 | // Set result to false to indicate error |
258 | 251 | $dbr->freeResult( $res ); |
259 | 252 | $res = false; |