From: Sam Reed Date: Sun, 5 Jun 2011 17:49:00 +0000 (+0000) Subject: * (bug 25734) API: possible issue with revids validation X-Git-Tag: 1.31.0-rc.0~29704 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=a5b8ef1056276c7cb2597ec5ea816209cb06305e;p=lhc%2Fweb%2Fwiklou.git * (bug 25734) API: possible issue with revids validation It seems, on databases with loads of revision rows (ie enwiki, not testwiki), although the EXPLAIN is sane, it's doing something stupid (table scan? I've nfi). So, as any revision id's less than 0 aren't valid, just prefilter them from the database SQL query mysql> DESCRIBE SELECT /* ApiPageSet::initFromRevIDs */ rev_id,rev_page FROM `revision`,`page` WHERE rev_id IN ('10','20','30','40','-50','60') AND (rev_page = page_id); +----+-------------+----------+-------+-------------------------------+---------+---------+-----------------------+-------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+----------+-------+-------------------------------+---------+---------+-----------------------+-------+--------------------------+ | 1 | SIMPLE | page | index | PRIMARY | PRIMARY | 4 | NULL | 22982 | Using index | | 1 | SIMPLE | revision | ref | PRIMARY,rev_id,page_timestamp | PRIMARY | 4 | testwiki.page.page_id | 1 | Using where; Using index | +----+-------------+----------+-------+-------------------------------+---------+---------+-----------------------+-------+--------------------------+ --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 3d0bf2c79a..00db195244 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -96,6 +96,7 @@ production. * (bug 29221) Expose oldrevid in watchlist output * (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag * (bug 28897) rvparse doesn’t seem to work with rvsection +* (bug 25734) API: possible issue with revids validation === Languages updated in 1.19 === diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index caa1dc08d6..cfee7a4225 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -535,6 +535,15 @@ class ApiPageSet extends ApiQueryBase { $pageids = array(); $remaining = array_flip( $revids ); + // bug 25734 API: possible issue with revids validation + // It seems with a load of revision rows, MySQL gets upset + // Remove any < 0 revids, as they can't be valid + foreach( $revids as $i => $revid ) { + if ( $revid < 0 ) { + unset( $revids[$i] ); + } + } + $tables = array( 'revision', 'page' ); $fields = array( 'rev_id', 'rev_page' ); $where = array( 'rev_id' => $revids, 'rev_page = page_id' );