Issue:Crash on ordermethod=category,sortkey on PostgreSQL-based Mediawiki (patch included)
From FollowTheScore
Description: | SQL errors when using DPL with PostgreSQL (8.4.6) - easy to fix |
Extension / Version: | DPL / 1.8.9 |
Type / Status: | Bug / open |
Problem
1.8.9 fails agains a PostgreSQL-based wiki. Example:
<dpl> category = Part I ordermethod = category </dpl>
...produces:
The DPL extension (version 1.8.9) produced a SQL statement which lead to a Database error. The reason may be an internal error of DPL or an error which you made, especially when using DPL options like titleregexp. Query text is: SELECT DISTINCT cl_head.cl_to, page.page_namespace as page_namespace,page.page_title as page_title,page.page_id as page_id FROM page LEFT OUTER JOIN (categorylinks AS cl_head) ON (page_id=cl_head.cl_from) INNER JOIN categorylinks AS cl0 ON page.page_id=cl0.cl_from AND (cl0.cl_to='Deel_I') WHERE 1=1 AND page.page_is_redirect=0 ORDER BY cl_head.cl_to ASC OFFSET 0 LIMIT 500 Error message is: ERROR: syntax error at or near ")" LINE 1: ...ROM page LEFT OUTER JOIN (categorylinks AS cl_head) ON (page...
This patch (of DPLMain.php) corrects the problem and it also works in MySQL (I have DLP in production use with this patch with MySQL and PostgreSQL).
diff DPLMain.php{.orig,} 2248c2248 < $sSqlSelectFrom .= ' LEFT OUTER JOIN (' . $sSqlClHeadTable . ($b2tables ? ', ' : '') . $sSqlClTableForGC . ') ON (' . $sSqlCond_page_cl_head . ($b2tables ? ' AND ' : '') . $sSqlCond_page_cl_gc . ')'; --- > $sSqlSelectFrom .= ' LEFT OUTER JOIN ' . $sSqlClHeadTable . ($b2tables ? ', ' : '') . $sSqlClTableForGC . ' ON (' . $sSqlCond_page_cl_head . ($b2tables ? ' AND ' : '') . $sSqlCond_page_cl_gc . ')';