r68100 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68099‎ | r68100 | r68101 >
Date:18:52, 15 June 2010
Author:demon
Status:deferred (Comments)
Tags:
Comment:
(bug 23773) SQL syntax issues with Postgres
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1821,7 +1821,18 @@
18221822 $tables[] = 'flaggedrevs';
18231823 $fields[] = 'MAX(fr_quality) AS fr_quality';
18241824 # Avoid duplicate rows due to multiple revs with the same sha-1 key
1825 - $opts['GROUP BY'] = 'oi_name,oi_timestamp';
 1825+
 1826+ # This is a stupid hack to get all the field names in our GROUP BY
 1827+ # clause. Postgres yells at you for not including all of the selected
 1828+ # columns, so grab the full list, unset the two we actually want to
 1829+ # order by, then append the rest of them to our two. It would be
 1830+ # REALLY nice if we handled this automagically in makeSelectOptions()
 1831+ # or something *sigh*
 1832+ $groupBy = OldLocalFile::selectFields();
 1833+ unset( $groupBy[ array_search( 'oi_name', $groupBy ) ] );
 1834+ unset( $groupBy[ array_search( 'oi_timestamp', $groupBy ) ] );
 1835+ $opts['GROUP BY'] = 'oi_name,oi_timestamp,' . implode( ',', $groupBy );
 1836+
18261837 $join_conds['flaggedrevs'] = array( 'LEFT JOIN',
18271838 'oi_sha1 = fr_img_sha1 AND oi_timestamp = fr_img_timestamp' );
18281839 }

Comments

#Comment by Catrope (talk | contribs)   13:37, 7 December 2010
+			unset( $groupBy[ array_search( 'oi_name', $groupBy ) ] );
+			unset( $groupBy[ array_search( 'oi_timestamp', $groupBy ) ] );

How about $groupBy = array_diff( $groupBy, array( 'oi_name', 'oi_timestamp' ) ); ?

+			# REALLY nice if we handled this automagically in makeSelectOptions()
+			# or something *sigh*

bug 26273

+			$opts['GROUP BY'] = 'oi_name,oi_timestamp,' . implode( ',', $groupBy );

We should allow specifying this as an array. bug 26274

Status & tagging log