https://bugzilla.wikimedia.org/show_bug.cgi?id=31534
Web browser: ---
Bug #: 31534
Summary: SQL errors with corrupted table name aliases
Database::select() generated queries
Product: MediaWiki
Version: 1.19-svn
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: Database
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
My extension has the following PHP code:
function getIntervalResults( $offset, $limit ) {
$result = array();
$db = & wfGetDB( DB_SLAVE );
$qp_users = $db->tableName( 'qp_users' );
$qp_users_polls = $db->tableName( 'qp_users_polls' );
$res = $db->select( "$qp_users_polls qup, $qp_users qu",
array( 'qu.uid as uid', 'name as username', 'count(pid) as
pidcount' ),
'qu.uid=qup.uid',
__METHOD__,
array( 'GROUP BY' => 'qup.uid',
'ORDER BY' => $this->order_by,
'OFFSET' => intval( $offset ),
'LIMIT' => intval( $limit ) )
);
while ( $row = $db->fetchObject( $res ) ) {
$result[] = $row;
}
return $result;
}
It used to work with 1.15, works with 1.17 (right now), however with current
trunk it produces the following broken query (copypasted from log):
SELECT /* qp_UsersList::getIntervalResults QuestPC */ qu.uid as uid,name as
username,count(pid) as pidcount FROM `wiki_`wiki_qp_users_polls` qup,
`wiki_qp_users` qu` WHERE qu.uid=qup.uid GROUP BY qup.uid ORDER BY count(pid)
DESC, name ASC LIMIT 50
As you probably see, the FROM arguments are corrupted:
FROM `wiki_`wiki_qp_users_polls` qup, `wiki_qp_users` qu`
especially `wiki_`wiki_qp_users_polls`
which causes:
(SQL запрос скрыт)
произошёл из функции «qp_UsersList::getIntervalResults». База данных возвратила
ошибку «1064: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '`
qup, `wiki_qp_users` qu` WHERE qu.uid=qup.uid GROUP BY qup.uid ORDER BY coun'
at line 1 (127.0.0.1)».
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l