• 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:

    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. However, I’m not proficient enough at PHP to determine if there is something that can be hacked in the WP code to fix this problem.

    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.

    Is this just an inherent bug in WP, or is there something else at issue here that can be resolved (both the funky weeks and the database error)? If it is a bug in WP, are there any hacks that could be applied to fix this?

    The site in question is located at https://ssip.unchost.org.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Weekly archives start_of_week flaws and DB errors’ is closed to new replies.