From: Brion Vibber Date: Thu, 25 Nov 2004 12:18:46 +0000 (+0000) Subject: * Force index selection, MySQL may pick cur_namespace when using the new namespace... X-Git-Tag: 1.5.0alpha1~1239 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=0ab5d236f8c23039fd3be43ab4846a6a4014b609;p=lhc%2Fweb%2Fwiklou.git * Force index selection, MySQL may pick cur_namespace when using the new namespace selector, which is bad bad mojo on a large site * Fix missing tag which broke layout --- diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index b0d7ff9a4f..fa5a1635cb 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -89,25 +89,31 @@ function wfSpecialContributions( $par = '' ) { $cmq .= " AND cur_namespace = {$namespace}"; $omq .= " AND old_namespace = {$namespace}"; } - + + # We may have to force the index, as some options will cause + # MySQL to incorrectly pick eg the namespace index. + list( $useIndex, $tailOpts ) = $dbr->makeSelectOptions( array( + 'USE INDEX' => 'usertext_timestamp', + 'LIMIT' => $querylimit ) ); + extract( $dbr->tableNames( 'old', 'cur' ) ); if ( $userCond == '' ) { - $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " . + $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur $useIndex " . "WHERE cur_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$cmq} " . - "ORDER BY inverse_timestamp LIMIT {$querylimit}"; + "ORDER BY inverse_timestamp $tailOpts"; $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old $useIndex " . "WHERE old_user_text='" . $dbr->strencode( $nt->getText() ) . "' {$omq} " . - "ORDER BY inverse_timestamp LIMIT {$querylimit}"; + "ORDER BY inverse_timestamp $tailOpts"; $res2 = $dbr->query( $sql, $fname ); } else { - $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur " . - "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; + $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit,cur_is_new,cur_user_text FROM $cur $useIndex " . + "WHERE cur_user {$userCond} {$cmq} ORDER BY inverse_timestamp $tailOpts"; $res1 = $dbr->query( $sql, $fname ); - $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old " . - "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp LIMIT {$querylimit}"; + $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit,old_user_text,old_id FROM $old $useIndex " . + "WHERE old_user {$userCond} {$omq} ORDER BY inverse_timestamp $tailOpts"; $res2 = $dbr->query( $sql, $fname ); } $nCur = $dbr->numRows( $res1 ); @@ -305,7 +311,7 @@ function namespaceForm ( $target, $hideminor, $namespace ) { $out .= ''; $out .= ''; $out .= wfMsg ( 'allpagesformtext2', $namespaceselect, $submitbutton ); - $out .= ''; + $out .= ''; return $out; } ?>