Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -1310,9 +1310,16 @@ |
1311 | 1311 | return true; |
1312 | 1312 | } |
1313 | 1313 | |
| 1314 | + /** |
| 1315 | + * @param $dbr DatabaseBase |
| 1316 | + * @param $query |
| 1317 | + * @param $cat |
| 1318 | + * @return int |
| 1319 | + */ |
1314 | 1320 | function query_count( $dbr, $query, $cat ) { |
1315 | | - $q = $dbr->strencode( str_replace( ' ' , '_' , wfMsgForContent( $cat ) ) ); |
1316 | | - $res = $dbr->query( str_replace( '###', $q, $query ), __METHOD__ ); |
| 1321 | + $query['conds']['cl_to'] = $str_replace( ' ' , '_' , wfMsgForContent( $cat ) ); |
| 1322 | + $res = $dbr->select( $query['tables'], $query['fields'], $query['conds'], __METHOD__, $query['joins'] ); |
| 1323 | + |
1317 | 1324 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1318 | 1325 | $row = $dbr->fetchObject( $res ); |
1319 | 1326 | $n = $row->count; |
— | — | @@ -1375,6 +1382,7 @@ |
1376 | 1383 | array( 'page_namespace' => $page_ns_index, 'page_title' => $pages ), |
1377 | 1384 | __METHOD__ |
1378 | 1385 | ); |
| 1386 | + |
1379 | 1387 | if( $res && $dbr->numRows( $res ) > 0 ) { |
1380 | 1388 | $row = $dbr->fetchObject( $res ); |
1381 | 1389 | $total = $row->count; |
— | — | @@ -1383,17 +1391,18 @@ |
1384 | 1392 | return; |
1385 | 1393 | } |
1386 | 1394 | |
1387 | | - $pagelist = "'".implode( "', '", $pages)."'"; |
1388 | | - $catlinks = $dbr->tableName( 'categorylinks' ); |
1389 | | - $page = $dbr->tableName( 'page' ); |
1390 | | - |
1391 | 1395 | // proofreading status of pages |
1392 | | - $query = "SELECT COUNT(page_id) AS count FROM $page LEFT JOIN $catlinks ON cl_from=page_id WHERE cl_to='###' AND page_namespace=$page_ns_index AND page_title IN ( $pagelist )" ; |
| 1396 | + $queryArr = array( |
| 1397 | + 'tables' => array( 'page', 'categorylinks' ), |
| 1398 | + 'fields' => array( 'COUNT(page_id) AS count' ), |
| 1399 | + 'conds' => array( 'cl_to' => '', 'page_namespace' => $page_ns_index, 'page_title' => $pages ), |
| 1400 | + 'joins' => array( 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ) ) |
| 1401 | + ); |
1393 | 1402 | |
1394 | | - $n0 = $this->query_count( $dbr, $query, 'proofreadpage_quality0_category' ); |
1395 | | - $n2 = $this->query_count( $dbr, $query, 'proofreadpage_quality2_category' ); |
1396 | | - $n3 = $this->query_count( $dbr, $query, 'proofreadpage_quality3_category' ); |
1397 | | - $n4 = $this->query_count( $dbr, $query, 'proofreadpage_quality4_category' ); |
| 1403 | + $n0 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality0_category' ); |
| 1404 | + $n2 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality2_category' ); |
| 1405 | + $n3 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality3_category' ); |
| 1406 | + $n4 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality4_category' ); |
1398 | 1407 | $n1 = $total - $n0 - $n2 - $n3 - $n4; |
1399 | 1408 | |
1400 | 1409 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -1424,9 +1433,6 @@ |
1425 | 1434 | } |
1426 | 1435 | |
1427 | 1436 | $dbr = wfGetDB( DB_SLAVE ); |
1428 | | - $page = $dbr->tableName( 'page' ); |
1429 | | - $templatelinks = $dbr->tableName( 'templatelinks' ); |
1430 | | - $catlinks = $dbr->tableName( 'categorylinks' ); |
1431 | 1437 | |
1432 | 1438 | // find the index page |
1433 | 1439 | $indextitle = null; |
— | — | @@ -1497,11 +1503,20 @@ |
1498 | 1504 | $dbr->freeResult( $res ); |
1499 | 1505 | } |
1500 | 1506 | // find the proofreading status of transclusions |
1501 | | - $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title AND page_namespace=tl_namespace LEFT JOIN $catlinks ON cl_from=page_id WHERE tl_from=$id AND tl_namespace=$page_ns_index AND cl_to='###'"; |
1502 | | - $n0 = $this->query_count( $dbr, $query, 'proofreadpage_quality0_category' ); |
1503 | | - $n2 = $this->query_count( $dbr, $query, 'proofreadpage_quality2_category' ); |
1504 | | - $n3 = $this->query_count( $dbr, $query, 'proofreadpage_quality3_category' ); |
1505 | | - $n4 = $this->query_count( $dbr, $query, 'proofreadpage_quality4_category' ); |
| 1507 | + $queryArr = array( |
| 1508 | + 'tables' => array( 'templatelinks', 'page', 'categorylinks' ), |
| 1509 | + 'fields' => array( 'COUNT(page_id) AS count' ), |
| 1510 | + 'conds' => array( 'cl_to' => '', 'page_namespace' => $page_ns_index, 'page_title' => $pages ), |
| 1511 | + 'joins' => array( |
| 1512 | + 'page' => array( 'LEFT JOIN', 'page_title=tl_title AND page_namespace=tl_namespace' ), |
| 1513 | + 'categorylinks' => array( 'LEFT JOIN', 'cl_from=page_id' ), |
| 1514 | + ) |
| 1515 | + ); |
| 1516 | + |
| 1517 | + $n0 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality0_category' ); |
| 1518 | + $n2 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality2_category' ); |
| 1519 | + $n3 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality3_category' ); |
| 1520 | + $n4 = $this->query_count( $dbr, $queryArr, 'proofreadpage_quality4_category' ); |
1506 | 1521 | // quality1 is the default value |
1507 | 1522 | $n1 = $n - $n0 - $n2 - $n3 - $n4; |
1508 | 1523 | $ne = 0; |