[EventCalendar] Conflict with WP-Sticky

Chris Janton face at CentosPrime.COM
Thu Aug 30 12:58:34 UTC 2007


On 2007-08-29 , at 20:24 , Cris McConkey wrote:

>  I've had to de-activcate wp-sticky as it conflics with  
> eventcalendar3 plugin. Actually, the two will work togerher as long  
> as the ec3 option "Show events as blog entries" is set to: "Events  
> are Normal Posts".
>
> Once set to "Keep Events Seperate", which changes the event  
> category to display only events in the future in chronological  
> order (earlier events first), an error occurs when a link in the  
> sidebar calendar is activated.
>
> Is this a fault with event calendar 3, WP-Sticky, or both?

At the moment it looks like EC3.
>
> Here is the error message that is displayed:
>
>       WordPress database error: [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 'DESC,'%Y-%m-%d') DESC,  
> (wp_sticky.sticky_status = 1 AND wp_sticky.sticky_status ' at line 1]
>       SELECT SQL_CALC_FOUND_ROWS wp_posts.*,  
> wp_sticky.sticky_status FROM wp_posts LEFT JOIN wp_post2cat ON  
> (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_ec3_schedule  
> ec3_sch ON ec3_sch.post_id=id LEFT JOIN wp_sticky ON  
> wp_sticky.sticky_post_id = wp_posts.ID WHERE 1=1 AND  
> wp_post2cat.category_id IN (10) AND (post_type = 'post' AND  
> (post_status = 'publish' OR post_status = 'private')) AND ((YEAR 
> (start)=2007 AND MONTH(start)=09 AND DAYOFMONTH(start)=08) OR  
> (start<='2007-09-08 0:0:0' AND end>='2007-09-08 0:0:0')) GROUP BY  
> wp_posts.ID ORDER BY (wp_sticky.sticky_status = 2 AND  
> wp_sticky.sticky_status IS NOT NULL) DESC, DATE_FORMAT 
> (wp_posts.ec3_sch.start DESC,'%Y-%m-%d') DESC,  
> (wp_sticky.sticky_status = 1 AND wp_sticky.sticky_status IS NULL)  
> DESC, DATE_FORMAT(wp_posts.ec3_sch.start DESC,'%T') DESC LIMIT 0, 10

WP-Sticky adds the following "ORDER BY" to the query (slightly edited)

	DATE_FORMAT($wpdb->posts.post_date,'%Y-%m-%d') DESC,
	... DATE_FORMAT($wpdb->posts.post_date,'%T') DESC

EC3 happily changes the ".post_date" part of the order by to  
"ec3_sch.start DESC" giving us the illegal construct

	DATE_FORMAT(wp_posts.ec3_sch.start DESC, '%T')

for example.

When you set the option "Keep Events Separate" the ec3->advanced flag  
is set to true. When the advanced flag is true EC3 summarily rewrites  
the ORDER BY clause.

This is something you could try (I don't use WP-sticky, so I can't)

in eventcalendar3.php on approximately line 266 you should see this

	$regexp='/\bpost_date\b( DESC\b| ASC\b)?/i';

you could try changing the post_date to posts.post_date - this would  
have the effect of matching the entire name of the column and replace  
the complete name with the ec3_sch.start -

	$regexp='/\bposts.post_date\b( DESC\b| ASC\b)?/i';

I suspect this will fix the syntax error in the SQL, but I have no  
idea what the effect will be. ;-)


8)
----------------------------------
Chris Janton  - face at CentosPrime dot COM
Netminder for Opus1.COM





More information about the EventCalendar mailing list