Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -1263,9 +1263,10 @@ |
1264 | 1264 | $catlinks = $dbr->tableName( 'categorylinks' ); |
1265 | 1265 | $page = $dbr->tableName( 'page' ); |
1266 | 1266 | $pagelist = "'".implode( "', '", $pages)."'"; |
1267 | | - |
1268 | | - $query = "SELECT COUNT(page_id) AS count FROM $page WHERE page_namespace=$page_ns_index AND page_title IN ( $pagelist )" ; |
1269 | | - $res = $dbr->query( $query , __METHOD__ ); |
| 1267 | + $res = $dbr->select( array( 'page' ), |
| 1268 | + array( 'COUNT(page_id) AS count'), |
| 1269 | + array( "page_namespace=$page_ns_index", "page_title IN ( $pagelist )"), |
| 1270 | + __METHOD__ ); |
1270 | 1271 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1271 | 1272 | $row = $dbr->fetchObject( $res ); |
1272 | 1273 | $total = $row->count; |
— | — | @@ -1319,8 +1320,11 @@ |
1320 | 1321 | $catlinks = $dbr->tableName( 'categorylinks' ); |
1321 | 1322 | |
1322 | 1323 | // count transclusions from page namespace |
1323 | | - $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title AND page_namespace=tl_namespace WHERE tl_from=$id AND tl_namespace=$page_ns_index"; |
1324 | | - $res = $dbr->query( $query , __METHOD__ ); |
| 1324 | + $res = $dbr->select( array( 'templatelinks', 'page' ), |
| 1325 | + array( 'COUNT(page_id) AS count' ), |
| 1326 | + array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
| 1327 | + __METHOD__, null, |
| 1328 | + array( 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ) ) ) ; |
1325 | 1329 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1326 | 1330 | $row = $dbr->fetchObject( $res ); |
1327 | 1331 | $n = $row->count; |
— | — | @@ -1340,23 +1344,31 @@ |
1341 | 1345 | $n1 = $n - $n0 - $n2 - $n3 - $n4; |
1342 | 1346 | |
1343 | 1347 | // find the index page |
1344 | | - $indexlink=""; |
1345 | | - $query1 = "SELECT tl_title AS title FROM $templatelinks WHERE tl_from=$id AND tl_namespace=$page_ns_index LIMIT 1"; |
1346 | | - $res = $dbr->query( $query1 , __METHOD__ ); |
| 1348 | + $indextitle = null; |
| 1349 | + $res = $dbr->select( array( 'templatelinks' ), |
| 1350 | + array( 'tl_title AS title' ), |
| 1351 | + array( "tl_from=$id", "tl_namespace=$page_ns_index" ), |
| 1352 | + __METHOD__, array( 'LIMIT' => 1 ) ); |
1347 | 1353 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1348 | 1354 | $row = $dbr->fetchObject( $res ); |
1349 | 1355 | $title = $dbr->strencode( $row->title ); |
1350 | 1356 | $dbr->freeResult( $res ); |
1351 | | - $query2 = "SELECT page_title AS title FROM $pagelinks LEFT JOIN $page ON page_id=pl_from WHERE pl_title=\"$title\" AND pl_namespace=$page_ns_index AND page_namespace=$index_ns_index LIMIT 1"; |
1352 | | - $res2 = $dbr->query( $query2 , __METHOD__ ); |
| 1357 | + $res2 = $dbr->select( array( 'pagelinks', 'page' ), |
| 1358 | + array( 'page_title AS title' ), |
| 1359 | + array( "pl_title='$title'","pl_namespace=$page_ns_index","page_namespace=$index_ns_index"), |
| 1360 | + __METHOD__, array( 'LIMIT' => 1 ), |
| 1361 | + array( 'page' => array( 'LEFT JOIN', 'page_id=pl_from' ) ) ) ; |
1353 | 1362 | if( $res2 && $dbr->numRows( $res2 ) > 0 ) { |
1354 | 1363 | $row = $dbr->fetchObject( $res2 ); |
1355 | 1364 | $indextitle = $row->title; |
1356 | 1365 | $dbr->freeResult( $res2 ); |
1357 | | - $sk = $wgUser->getSkin(); |
1358 | | - $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", "[index]" ); |
1359 | 1366 | } |
1360 | 1367 | } |
| 1368 | + $indexlink = ''; |
| 1369 | + if( $indextitle ) { |
| 1370 | + $sk = $wgUser->getSkin(); |
| 1371 | + $indexlink = $sk->makeKnownLink( "$index_namespace:$indextitle", "[index]" ); |
| 1372 | + } |
1361 | 1373 | $output = wfMsgForContent( 'proofreadpage_quality_message', $n0*100/$n, $n1*100/$n, $n2*100/$n, $n3*100/$n, $n4*100/$n, $n, $indexlink ); |
1362 | 1374 | $out->setSubtitle( $out->getSubtitle() . $output ); |
1363 | 1375 | return true; |