I've identified a large number of unnecessary database queries being triggered by WooCommerce Germanized, and I traced the problem to the fact that the WooCommerce function wc_get_page_id() can return -1 if a given page does not exist. Germanized doesn't check for this and the result is that if some pages are not configured, for example the "Terms & Conditions" page, Germanized ultimately causes the following database query to be called repeatedly:
SELECT *
FROM wp_posts
WHERE ID = -1
LIMIT 1
This is because wc_gzd_get_page_permalink() does not expect wc_get_page_id() to return -1 and therefore passes it through to get_permalink() which will perform a database query looking for a post with an ID of -1.
Impact
On this particular client site we're seeing this unnecessary query being performed over 25 times on every page load.
To reproduce
Configure Germanized but don't select any pages on the WooCommerce -> Settings -> Germanized -> General screen
Install the Query Monitor plugin for debugging purposes
View a page and observe the unnecessary queries in the Query Monitor -> Queries panel
Results will probably differ on different sites and with a different number of pages either configured or not configured.
I've identified a large number of unnecessary database queries being triggered by WooCommerce Germanized, and I traced the problem to the fact that the WooCommerce function
wc_get_page_id()
can return-1
if a given page does not exist. Germanized doesn't check for this and the result is that if some pages are not configured, for example the "Terms & Conditions" page, Germanized ultimately causes the following database query to be called repeatedly:This is because
wc_gzd_get_page_permalink()
does not expectwc_get_page_id()
to return-1
and therefore passes it through toget_permalink()
which will perform a database query looking for a post with an ID of-1
.Impact
On this particular client site we're seeing this unnecessary query being performed over 25 times on every page load.
To reproduce
Results will probably differ on different sites and with a different number of pages either configured or not configured.
Screenshot