[EventCalendar] Small post saving buglet/ other notes

David Nutter dnutter at hemswell.lincoln.ac.uk
Thu Aug 24 15:49:50 UTC 2006


While hacking around with EventCalendar3 I stumbled upon a bug which
in certain circumstances leads to duplicate schedule entries being

Steps to replicate:

1) Create a new post (not in the events category) and save it
2) Edit the post, put it into the events category and add a single schedule
3) Save it. 
4) Post should now have two identical schedule entries in
wp_ec3_schedule table

The reason appears to be these two lines at the end of admin.php:

add_action('save_post',         array(&$ec3_admin,'save_post')); 
add_action('edit_post',         array(&$ec3_admin,'save_post')); 

In the case of a pre-existing post, _both_ these actions are executed,
resulting in two calls to save_post. This isn't a problem when
UPDATEing an existing event schedule entry, but INSERTing a new one
occurs twice, leading to duplicate schedule entries. Creating a
brand-new post doesn't call edit_post actions, so the solution is
easy, just comment out the second line. 

I've added a few things to my local copy of event calendar (alluded to
in the comments thread here
firstly moving the code to update post dates out of the upgrade()
function as running this causes date-based permalinks to break. 

Secondly, adding a config option to turn the content filter which adds
the schedule to the post body on and off. This is for users who want
more flexibility in designing their templates. 

Finally, I've updated the schedule entry dialog box to be more "user

Currently I'm tidying these up and producing separate patches for each
and a further patch containing my local bugfixes. These should be
ready tomorrow. 


David Nutter

More information about the EventCalendar mailing list