Index: trunk/phase3/includes/Article.php |
— | — | @@ -3631,7 +3631,7 @@ |
3632 | 3632 | */ |
3633 | 3633 | public static function incViewCount( $id ) { |
3634 | 3634 | $id = intval( $id ); |
3635 | | - global $wgHitcounterUpdateFreq, $wgDBtype; |
| 3635 | + global $wgHitcounterUpdateFreq; |
3636 | 3636 | |
3637 | 3637 | $dbw = wfGetDB( DB_MASTER ); |
3638 | 3638 | $pageTable = $dbw->tableName( 'page' ); |
— | — | @@ -3662,23 +3662,23 @@ |
3663 | 3663 | wfProfileIn( 'Article::incViewCount-collect' ); |
3664 | 3664 | $old_user_abort = ignore_user_abort( true ); |
3665 | 3665 | |
3666 | | - if($wgDBtype == 'mysql') |
3667 | | - $dbw->query("LOCK TABLES $hitcounterTable WRITE"); |
3668 | | - $tabletype = $wgDBtype == 'mysql' ? "ENGINE=HEAP " : ''; |
3669 | | - $dbw->query("CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ". |
| 3666 | + $dbType = $dbw->getType(); |
| 3667 | + $dbw->lockTables( array(), array( 'hitcounter' ), __METHOD__, false ); |
| 3668 | + $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : ''; |
| 3669 | + $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ". |
3670 | 3670 | "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ". |
3671 | | - 'GROUP BY hc_id'); |
3672 | | - $dbw->query("DELETE FROM $hitcounterTable"); |
3673 | | - if($wgDBtype == 'mysql') { |
3674 | | - $dbw->query('UNLOCK TABLES'); |
3675 | | - $dbw->query("UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ". |
3676 | | - 'WHERE page_id = hc_id'); |
| 3671 | + 'GROUP BY hc_id', __METHOD__ ); |
| 3672 | + $dbw->delete( 'hitcounter', '*', __METHOD__ ); |
| 3673 | + $dbw->unlockTables( __METHOD__ ); |
| 3674 | + if( $dbType == 'mysql' ) { |
| 3675 | + $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ". |
| 3676 | + 'WHERE page_id = hc_id', __METHOD__ ); |
3677 | 3677 | } |
3678 | 3678 | else { |
3679 | | - $dbw->query("UPDATE $pageTable SET page_counter=page_counter + hc_n ". |
3680 | | - "FROM $acchitsTable WHERE page_id = hc_id"); |
| 3679 | + $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n ". |
| 3680 | + "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ ); |
3681 | 3681 | } |
3682 | | - $dbw->query("DROP TABLE $acchitsTable"); |
| 3682 | + $dbw->query( "DROP TABLE $acchitsTable", __METHOD__ ); |
3683 | 3683 | |
3684 | 3684 | ignore_user_abort( $old_user_abort ); |
3685 | 3685 | wfProfileOut( 'Article::incViewCount-collect' ); |