Package: mediawiki Version: 1:1.11.1-1 Tags: patch
Coin fellow DD, I've managed to fix a few problems in the pg support (but still many remains). This patch would solve SELECT requests with ORDER BY or GROUP BY, which request having the fields of these options be added in the fetched fields in certains conditions. I'm not sure all cases are matched, but the most usual ones are. Regards.
--- includes/DatabasePostgres.php.orig 2008-03-05 14:45:05.000000000 +0100 +++ includes/DatabasePostgres.php 2008-03-07 13:59:57.000000000 +0100 @@ -87,6 +87,44 @@ } + /** + * SELECT wrapper + * + * @param mixed $table Array or string, table name(s) (prefix auto-added) + * @param mixed $vars Array or string, field name(s) to be retrieved + * @param mixed $conds Array or string, condition(s) for WHERE + * @param string $fname Calling function name (use __METHOD__) for logs/profiling + * @param array $options Associative array of options (e.g. array('GROUP BY' => 'page_title')), + * see Database::makeSelectOptions code for list of supported stuff + * @return mixed Database result resource (feed to Database::fetchObject or whatever), or false on failure + */ + function select( $table, $vars, $conds='', $fname = 'Database::select', $options = array() ) + { + $noKeyOptions = array(); + foreach ( $options as $key => $option ) { + if ( is_numeric( $key ) ) { + $noKeyOptions[$option] = true; + } + } + + if (is_array($vars) === false) { + $vars = (string)$vars; + $var_list = explode(',', $vars); + } + else { + $var_list = $vars; + $vars = implode(',', $var_list); + } + + ## in certain conditions with ORDER BY and GROUP BY, the specified fields *MUST* be included in fetched data + if (array_key_exists('ORDER BY', $options) && (strpos($vars, '(') === false) && ((stripos($vars, "DISTINCT ") !== false) || (array_key_exists('DISTINCT', $noKeyOptions)))) + $var_list[] = preg_replace("/ (ASC|DESC|USING .*?)(,| |$)/i", "", $options['ORDER BY']); + else if (array_key_exists('GROUP BY', $options)) + $var_list[] = $options['GROUP BY']; + + return parent::select( $table, $var_list, $conds, $fname, $options ); + } + function cascadingDeletes() { return true; }
-- Marc Dequènes Homepage: http://www.proformatique.com/ Proformatique - 67 rue Voltaire - 92800 Puteaux Tel. : 01 41 38 99 64 - Fax. : 01 41 38 99 70
pgpdxOMLBNNqP.pgp
Description: PGP signature