[fixed] Next Postgres-query failed (plugin_internal.inc.php)

Found a bug? Tell us!!
Post Reply
CaptainCrunch
Regular
Posts: 34
Joined: Thu Oct 20, 2005 4:51 pm
Contact:

[fixed] Next Postgres-query failed (plugin_internal.inc.php)

Post by CaptainCrunch »

Playing around with another testblog (S9Y 0.9beta3), I found another Postgres-related "error" within plugin_internal.inc.php. When the categories-sidebar-plugin was activated, PHP throws out an error within a "GROUP BY"-statement
Warning: pg_query(): Query failed: ERROR: column "c.categoryid" must appear in the GROUP BY clause or be used in an aggregate function in /var/www/cmstest/include/db/postgres.inc.php on line 113
Error in SELECT c.categoryid, c.category_name, count(e.id) as postings FROM roothell_entrycat ec, roothell_category c, roothell_entries e WHERE ec.categoryid = c.categoryid AND ec.entryid = e.id GROUP BY ec.categoryid, c.category_name ORDER BY postings DESC
ERROR: column "c.categoryid" must appear in the GROUP BY clause or be used in an aggregate function
Here's the fix that works for me. Please check:

Code: Select all

--- include/plugin_internal.inc.php.old 2005-10-26 07:50:53.000000000 +0200
+++ include/plugin_internal.inc.php     2005-10-26 07:51:01.000000000 +0200
@@ -1281,7 +1281,7 @@
                                                  {$serendipity['dbPrefix']}category c,
                                                  {$serendipity['dbPrefix']}entries e
                                             WHERE ec.categoryid = c.categoryid AND ec.entryid = e.id
-                                            GROUP BY ec.categoryid, c.category_name
+                                            GROUP BY c.categoryid, c.category_name
                                             ORDER BY postings DESC";
             $category_rows  = serendipity_db_query($cat_sql);
             if (is_array($category_rows)) {
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Next Postgres-query failed (plugin_internal.inc.php)

Post by garvinhicking »

Hi!

Great, fixed that bug. :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply