stephenharris / Event-Organiser

WordPress plug-in, Event Organiser, development repository
http://wordpress.org/extend/plugins/event-organiser/
GNU General Public License v3.0
100 stars 76 forks source link

Admin calendar: Avoid duplicate database query #522

Open zosterops-lateralis opened 2 years ago

zosterops-lateralis commented 2 years ago

Hello,

It seems that the eventorganiser_admin_calendar() function (which handles the event-admin-cal Ajax action) always performs the same database query twice.

In fact, the constructor for WP_Query calls the query() method, which itself already calls the get_posts() method. Therefore, calling $query->get_posts() after contructing the $query object is unnecessary, as all the posts are already available in the $query object, and it will needlessly repeat the previous database query.

This PR simply proposes to remove the call to $query->get_posts().

Thanks!

Zosterops