Opened 20 years ago
Closed 19 years ago
#1217 closed defect (bug) (fixed)
Weekly archives cause DB errors and incorrect weeks shown
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 1.5 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
If I set my weeks to start on Sundays instead of Mondays via the General options, I receive a database error for the weekly archives in my sidebar that are being called using <?php wp_get_archives('type=weekly'); ?>:
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 ') AS week, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-]
SELECT DISTINCT WEEK(post_date, ) AS week, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM wp_posts WHERE post_date < '2005-04-04 10:41:40' AND post_status = 'publish' ORDER BY post_date DESC
This seems to be a reference to wp-includes/template-functions-general.php around line 330.
As a point of reference, when the starting day is set to Monday in the General options, the string is set to 1 on the All Options page, when set to Sunday, the string is blank.
Strange thing, though: if I change the string for start_of_week to '0' (zero) using the All Options page, I get my weeks to start on a Sunday, but I then have two overlapping and too-long weeks listed in my sidebar: Sunday, March 27 - Saturday, April 2 (this one is fine) and then another 8-day week of Sunday, March 27 - Sunday, April 3. First of all, it seems strange that there is a Sunday to Sunday week; and second, it is odd that there are these two overlapping weeks. When clicking on the link for the 8-day week, the entry for April 4 (which isn't even in that date range) is shown.
Changing the start_of_week string to '7' creates an 8-day week and a 9-day week that overlap one another, neither of which start on Sunday: Monday, April 4 - Monday, April 11 and Saturday, April 2 - Sunday, April 10. Neither of these date ranges covers the bulk of my entries, which were posted April 1, but these get lumped into the April 2 - April 10 group.
http://trac.wordpress.org/changeset/2526
This fixes most of the problems. However, I still get a long week for the week that includes the DST change. All other weeks are fine.