[wp-trac] [WordPress Trac] #44752: wp_get_archives() with the parameter limit = 0 generates an error
WordPress Trac
noreply at wordpress.org
Wed Aug 8 08:52:28 UTC 2018
#44752: wp_get_archives() with the parameter limit = 0 generates an error
---------------------------+-----------------------------
Reporter: campusboy1987 | Owner: (none)
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.9.8
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
Hello.
I'm working on an extension of the `WP_Widget_Archives` class, in which I
implement the ability to specify the archive type and the limit of output
links. These parameters are then passed to the `wp_get_archives()`
function.
It is noticed that if the parameter `limit=0`, then the query to the
database turns out to be wrong and the following error is generated:
{{{
[You have an error in your SQL syntax; check the manual that corresponds
to your MariaDB server version for the right syntax to use near '0' at
line 1]
SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM wp_posts WHERE
post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date)
ORDER BY post_date DESC 0
}}}
Of course, I can check this parameter from my side and zero is replaced by
an empty string, but it is logical that the function itself does this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44752>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list